DCsunset / pandoc-include

A pandoc filter to allow file and header inclusion

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

invalid api version?

alcuinus opened this issue · comments

I am trying to run the example file provided in the project homepage and I get this error:

Traceback (most recent call last):
  File "/home/NAME/.local/bin/pandoc-include", line 8, in <module>
    sys.exit(main())
  File "/home/NAME/.local/lib/python3.10/site-packages/pandoc_include/main.py", line 333, in main
    return pf.run_filter(action, doc=doc)
  File "/home/NAME/.local/lib/python3.10/site-packages/panflute/io.py", line 227, in run_filter
    return run_filters([action], *args, **kwargs)
  File "/home/NAME/.local/lib/python3.10/site-packages/panflute/io.py", line 200, in run_filters
    doc = load(input_stream=input_stream)
  File "/home/NAME/.local/lib/python3.10/site-packages/panflute/io.py", line 58, in load
    doc = json.load(input_stream, object_hook=from_json)
  File "/usr/lib/python3.10/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.10/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
  File "/home/NAME/.local/lib/python3.10/site-packages/panflute/elements.py", line 1413, in from_json
    return Doc(*items, api_version=api, metadata=meta)
  File "/home/NAME/.local/lib/python3.10/site-packages/panflute/elements.py", line 66, in __init__
    raise TypeError("invalid api version", api_version)
TypeError: ('invalid api version', [1, 20])
Error running filter pandoc-include:
Filter returned error status 1

The installation is local (I edited the real folder name for security). The problem seems to be an invalid api version; I am almost illiterate insofar as Python is concerned and I ask your kind help.

  • Pandoc version: 2.9.2.1-3ubuntu2.
  • I am on Linux Mint 21.
  • pandoc-include version: 1.2.0

This filter looks excellent and I would really like to be able to use it.

Thank you.

Hi @alcuinus, I think the error here means that the pandoc version is too old. In README, it says that you should use pandoc with version greater than or equal to 2.17. Could you try a newer version of pandoc?

This was the problem, so sorry for my useless question. Unfortunately, the distribution repository was not updated and I did not check it, my fault indeed. Now I'm happily running pandoc version 3.1.6.1 and everything is working smoothly.
An additional question, if you do not mind (perhaps I should open a new thread?) Running pandoc, I explicitly call the filter. Would it not be possible to call the filter from the YAML header? I tried adding pandoc-options etc. in the YAML header, but nothing happened. May be tricking the default file?
I'm very interested also because next month I'm going to deliver a talk to an international conference where I will deal with a new workflow for humanists, and pandoc-include is a very important component of my new toolbox!

I tried using filters options in the yaml header but it doesn't work as well. My guess is that the filter is loaded at a different time compared to being used as an argument. I'm afraid it may not support it. But you may find a workaround if you are familiar with how pandoc works