stlehmann / mkdocs-rtd-lightbox

Readthedocs theme for mkdocs with Lightbox support
4 stars 0 forks source link

MkDocs 1.0 causes serialization error #1

Open jstieger opened 6 years ago

jstieger commented 6 years ago

After updating MkDocs to version 1.0 from last friday, building the documentation will fail with a typeerror "TypeError: Undefined is not JSON serializable". Removing rtd-lightbox as custom theme removes the issue.

I cannot be certain if this is a general issue or localized to me. If it is a general issue I hope my description helps. errorlog.txt

colinbourassa commented 5 years ago

I believe this is a general issue. I saw the same error with Markdown 2.6.11 and pymdown-extensions 5.0. I noticed a discrepancy in base.html between the official readthedocs and mkdocs-rtd-lightbox, and after I patched it (see below), everything worked fine.

diff --git a/base.html b/base.html
index a10cb85..c3acf85 100644
--- a/base.html
+++ b/base.html
@@ -33,7 +33,7 @@
   <script>
     // Current page data
     var mkdocs_page_name = {{ page.title|tojson|safe }};
-    var mkdocs_page_input_path = {{ page.input_path|tojson|safe }};
+    var mkdocs_page_input_path = {{ page.file.src_path|string|tojson|safe }};
     var mkdocs_page_url = {{ page.abs_url|tojson|safe }};
   </script>
   {% endif %}

(Note that I was running older releases of Markdown and pymdown-extensions to work around this other issue.)