tomduck / pandoc-tablenos

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

valid JSON value error when producing pdf #19

Closed mikebader closed 4 years ago

mikebader commented 4 years ago

Thank you for all of your work on pandoc-xnos. I have run into an issue attempting to convert markdown files to PDF. I tried converting the demo3.md file. It works correctly when converting to HTML, but does not work when converting to PDF.

The code that produced the error is pasted below.

% pandoc --version
pandoc 2.9.2.1
Compiled with pandoc-types 1.20, texmath 0.12.0.1, skylighting 0.8.3.2
Default user data directory: /Users/bader/.local/share/pandoc or /Users/bader/.pandoc
Copyright (C) 2006-2020 John MacFarlane
Web:  https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
% pandoc-tablenos --version
pandoc-tablenos 2.1.1
% pandoc demo3.md --filter pandoc-tablenos -o demo3.html
% pandoc demo3.md --filter pandoc-tablenos -o demo3.pdf 
Error running filter pandoc-tablenos:
Error in $: Failed reading: not a valid json value at 'pandoc-tablenos:Wrotethefollowingblockstoheader-includes.If'
tomduck commented 4 years ago

Thank you for this report and sorry for the long wait. I have not been able to reproduce this error. Note that there is a similar Issue filed against pandoc-eqnos: https://github.com/tomduck/pandoc-eqnos/issues/45

I have just released pandoc-tablenos 2.2.0. Could you please test against that? It is quite possible that this issue got resolved during other bug fixes. Pandoc 2.9 was not available at the time of the last release of pandoc-tablenos.

Thanks, Tom

fuhrmanator commented 4 years ago

I think this bug is related to warnings getting into stdout instead of stderr (I had this bug in another pandoc filter, because there was a call to an outside tool). It could be a pandoc problem, or maybe something else.

I'm pretty sure that a JSON processing of the warning generated at https://github.com/tomduck/pandoc-tablenos/blob/eb486fdd4460993b3ddd459e3fa02f513b5516e5/pandoc_tablenos.py#L536 is involved in the original issue. The code seems to be writing it to STDERR, but maybe the outer processing shell (or whatever) is not keeping them separate?

tomduck commented 4 years ago

Oh my. I will bet that you are using python 2. I can see the problem in the pandoc core. Can you please confirm?

tomduck commented 4 years ago

I am now able to reproduce the error under python 2.7.

fuhrmanator commented 4 years ago

To be clear - I don't actually have this issue - I found this months ago when stumbling on the problem in my own filter, and was trying to help out.

tomduck commented 4 years ago

Well, you definitely identified a problem. Thanks for your help!

Tom

tomduck commented 4 years ago

pandoc-xnos 2.4.1 is now released. --Tom

mikebader commented 4 years ago

Thank you for your attention to this! I need to upgrade my whole system to Python 3. I've been anticipating getting a new computer, so have been putting off doing it -- but then the pandemic hit so I haven't had a chance.

tomduck commented 4 years ago

All good. I expect to continue to support python 2.7 for the foreseeable future. :o) --Tom