tomduck / pandoc-tablenos

A pandoc filter for numbering tables and table references.
GNU General Public License v3.0
108 stars 8 forks source link

Bug with pandoc 2.11.1.1 ? #24

Closed PeterSommerlad closed 3 years ago

PeterSommerlad commented 3 years ago

I get a problem that might stem from the changes in pandoc's table AST:

Traceback (most recent call last):
  File "/usr/local/bin/pandoc-tablenos", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/pandoc_tablenos.py", line 684, in main
    altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
  File "/usr/local/lib/python3.9/site-packages/pandoc_tablenos.py", line 684, in <lambda>
    altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
  File "/usr/local/lib/python3.9/site-packages/pandocfilters.py", line 110, in walk
    res = action(item['t'],
  File "/usr/local/lib/python3.9/site-packages/pandoc_tablenos.py", line 124, in attach_attrs_table
    assert value[1][1][0]['t'] == 'Plain'
AssertionError
Error running filter pandoc-tablenos:
Filter returned error status 1

pandoc version:

pandoc 2.11.1.1
Compiled with pandoc-types 1.22, texmath 0.12.0.3, skylighting 0.10.0.3,
citeproc 0.1.1.1, ipynb 0.1.0.1
tomduck commented 3 years ago

Thanks for the report, @PeterSommerlad. Could you please provide some markdown that exposes the problem? Cheers, Tom.

PeterSommerlad commented 3 years ago

started more debugging. seems to be related to my own filter. However, tablenos seems to be more stringent what a Caption value could be than the pandoc/panflute API seems to permit: Plain vs. Inline

caption ([Inline]) – The caption of the table

tomduck commented 3 years ago

Thanks, @PeterSommerlad. I'm not sure where that quote comes from. Can you please let me know?

The xnos filters were designed to process test case json produced during pandoc markdown processing. This allows support for older versions of pandoc that some people need (things have changed a lot since pandoc 1.15.2!). I think that the test cases are fairly comprehensive, but there is always the possibility that something was missed.

For your particular application, if there is json input that pandoc processes that the filters will not, then I can use that to update the filters.

Cheers, Tom

PeterSommerlad commented 3 years ago

I fixed my filter (that I hacked together from a filter by someone else for my purposes...) . It used a blockquote within a span to mark a table caption and the rest to form a table with the panflute library. If ran in separate pandoc calls via intermediate markdown it worked with pandoc-tablenos, but not internally, because the caption remained as a blockquote. while pandoc/panflute seem to have been happy with that and generated a caption on markdown output, pandoc-tablenos asserted on expecting a Plain entry. I could fix my filter by creating the caption content as type Plain and now pandoc-tablenos is happy. I will close the bug, but you might consider to be a bit less stringent on what a table caption could be beyond just asserting 'Plain'.