Skip to content

"Invalid api version" when using a Panflute filter with Python version > 3.9 #246

Description

@rschram

Hi everyone,

When rendering a Quarto project with a new version of Python3 I can no longer use a Panflute filter which had worked with Python 3.9. The issue seems to be with the "api version" used in Panflute. These are the error messages from the RStudio (2022.07.2) console when run with Python 3.10.12, Pandoc 2.17.1.1, Panflute 2.3.1, and Quarto 1.2.269:

Traceback (most recent call last):
File "/home/rschram/Current/Pandoc/filters/quotable", line 84, in
main()
File "/home/rschram/Current/Pandoc/filters/quotable", line 78, in main
doc = doc.walk(find_passage,doc=doc)
File "/home/rschram/.local/lib/python3.10/site-packages/panflute/base.py", line 274, in walk
child = child.walk(action, doc, stop_if)
File "/home/rschram/.local/lib/python3.10/site-packages/panflute/containers.py", line 85, in walk
ans = list(chain.from_iterable(ans))
File "/home/rschram/.local/lib/python3.10/site-packages/panflute/containers.py", line 83, in
ans = ((item,) if type(item) is not list else item for item in ans)
File "/home/rschram/.local/lib/python3.10/site-packages/panflute/containers.py", line 81, in
ans = (item.walk(action, doc, stop_if) for item in self)
File "/home/rschram/.local/lib/python3.10/site-packages/panflute/base.py", line 282, in walk
altered = action(self, doc)
File "/home/rschram/Current/Pandoc/filters/quotable", line 48, in find_passage
caption = pf.convert_text(elem.attributes['caption'])
File "/home/rschram/.local/lib/python3.10/site-packages/panflute/tools.py", line 489, in convert_text
out = json.loads(out, object_hook=from_json)
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/rschram/.local/lib/python3.10/site-packages/panflute/elements.py", line 1362, in from_json
return Doc(*items, api_version=api, metadata=meta)
File "/home/rschram/.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 /home/rschram/Current/Pandoc/filters/quotable:
Filter returned error status 1

Apologies for not being able to produce a MWE or being able to provide more context. Any help would be appreciated because I would like to be reliably reproduce the Quarto project while keeping packages updated.

Best wishes,
Ryan

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions