Pandoc call generates an exception if uses filter pandoc-include for MD files that not contains blocs "!include . . ."
If the MD file does not contain any "!include . . ." blocks, then the next call:
pandoc.exe 1.md --filter pandoc-include -o 1.docx
where 1.md contains
Some text
generates an exception:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\venvs\base\Scripts\pandoc-include.exe\__main__.py", line 7, in <module>
File "C:\venvs\base\Lib\site-packages\pandoc_include\main.py", line 427, in main
return pf.run_filter(action, doc=doc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\venvs\base\Lib\site-packages\panflute\io.py", line 227, in run_filter
return run_filters([action], *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\venvs\base\Lib\site-packages\panflute\io.py", line 200, in run_filters
doc = load(input_stream=input_stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\venvs\base\Lib\site-packages\panflute\io.py", line 58, in load
doc = json.load(input_stream, object_hook=from_json)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\json\__init__.py", line 293, in load
return loads(fp.read(),
^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\json\__init__.py", line 359, in loads
return cls(**kw).decode(s)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\json\decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\venvs\base\Lib\site-packages\panflute\elements.py", line 1442, in from_json
return _res_func[tag](c)
^^^^^^^^^^^^^^^^^
File "C:\venvs\base\Lib\site-packages\panflute\table_elements.py", line 403, in table_from_json
return Table(*bodies, head=head, foot=foot, caption=caption, colspec=colspec, **ica)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\venvs\base\Lib\site-packages\panflute\table_elements.py", line 84, in __init__
self._validate_colspec()
File "C:\venvs\base\Lib\site-packages\panflute\table_elements.py", line 108, in _validate_colspec
raise IndexError(msg)
IndexError:
Invalid number of colspec tuples.Expected 0 but received 3
Error running filter pandoc-include:
Filter returned error status 1
Expected behavior - if the MD file does not contain "!include . . ." blocks, then the error is not generated and the filter ignores such files.
p.s. I found a bug on the latest version of pandoc-include v1.4.3 + pandoc v3.6.4. If the MD file contains a block "!include . . ." then the error is not generated and the insertion simply occurs. DA.DocBuilder.Client.zip - python virtual environment Tests.zip - test cases
Thanks a lot in advance for your support!
Hi, I tried the same input file and command in Linux and it works fine. This seems to be an issue of the panflute dependency.
Could you print the panflute version and try updating it?
Thank you very much. Updating panflute solved the problem.