DCsunset / pandoc-include

A pandoc filter to allow file and header inclusion

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: invalid api version

msoutopico opened this issue · comments

Hi there,

I've tried to run a very simple test but I got the error below.

> python -V
Python 3.9.2
> pip -V
pip 22.3.1 from /home/souto/.local/lib/python3.9/site-packages/pip (python 3.9

> pip install --user pandoc-include
Collecting pandoc-include
  Downloading pandoc_include-1.2.0-py3-none-any.whl (10 kB)
Collecting panflute>=2.0.5
  Downloading panflute-2.2.3-py3-none-any.whl (36 kB)
Collecting natsort>=7
  Downloading natsort-8.2.0-py3-none-any.whl (37 kB)
Requirement already satisfied: pyyaml<7,>=3 in /home/souto/.local/lib/python3.9/site-packages (from panflute>=2.0.5->pandoc-include) (6.0)
Requirement already satisfied: click<9,>=6 in /home/souto/.local/lib/python3.9/site-packages (from panflute>=2.0.5->pandoc-include) (8.1.3)
Installing collected packages: panflute, natsort, pandoc-include
Successfully installed natsort-8.2.0 pandoc-include-1.2.0 panflute-2.2.3

> pip show pandoc-include
Name: pandoc-include
Version: 1.2.0
Summary: Pandoc filter to allow file and header includes
Home-page: https://github.com/DCsunset/pandoc-include
Author: DCsunset
Author-email: DCsunset@protonmail.com
License: MIT
Location: /home/souto/.local/lib/python3.9/site-packages
Requires: natsort, panflute
Required-by: 


> cat snippet.md             
## Hello world
> cat main.md 
# Main

!include snippet.md

> pandoc main.md --filter pandoc-include -o output.pdf
Traceback (most recent call last):
  File "/home/souto/.local/bin/pandoc-include", line 8, in <module>
    sys.exit(main())
  File "/home/souto/.local/lib/python3.9/site-packages/pandoc_include/main.py", line 333, in main
    return pf.run_filter(action, doc=doc)
  File "/home/souto/.local/lib/python3.9/site-packages/panflute/io.py", line 227, in run_filter
    return run_filters([action], *args, **kwargs)
  File "/home/souto/.local/lib/python3.9/site-packages/panflute/io.py", line 200, in run_filters
    doc = load(input_stream=input_stream)
  File "/home/souto/.local/lib/python3.9/site-packages/panflute/io.py", line 58, in load
    doc = json.load(input_stream, object_hook=from_json)
  File "/usr/lib/python3.9/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.9/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
  File "/home/souto/.local/lib/python3.9/site-packages/panflute/elements.py", line 1362, in from_json
    return Doc(*items, api_version=api, metadata=meta)
  File "/home/souto/.local/lib/python3.9/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

I'd be grateful for any tips.
Cheers, Manuel

Hi, can you show your pandoc version? It may be incompatible with old versions of pandoc.

I got the same error, just set up my writing environment on a new laptop with debian 11.6:

pip install --user pandoc-include

Successfully installed click-8.1.3 natsort-8.2.0 pandoc-include-1.2.0 panflute-2.3.0 pyyaml-6.0

Debian 11 had as expected not the latest version of pandoc in its stable repositories:

pandoc --version

pandoc 2.9.2.1

I ended up downloading the latest binary - .deb from pandoc.org and installed in manually:

dpkg -i pandoc-3.0.1-1-amd64.deb

Now running pandoc 3.0.1 which compiles the PDF perfectly as expected.

Perhaps a note about pandoc version requirements in the notes for pandoc-include?

Thanks for making this :-) I'm currently writing a fiction novelle, excited about using markdown with pandoc-include to accomplish this.

@orjanv Thanks for your feedback! On my side, it seems that the pandoc 2.17 is the minimum version that works. I'll add it to the README later.