tomduck / pandoc-eqnos

A pandoc filter for numbering equations and equation references.
GNU General Public License v3.0
221 stars 27 forks source link

Cannot determine pandoc version when run with panzer #12

Closed fredcallaway closed 8 years ago

fredcallaway commented 8 years ago

https://github.com/msprev/panzer

ERROR:     !Traceback (most recent call last):
ERROR:     !  File "/Users/fred/anaconda/bin/pandoc-eqnos", line 7, in <module>
ERROR:     !    from pandoc_eqnos import main
ERROR:     !  File "/Users/fred/anaconda/lib/python3.5/site-packages/pandoc_eqnos.py", line 88, in <module>
ERROR:     !    raise RuntimeError('Cannot determine pandoc version.  '\
ERROR:     !RuntimeError: Cannot determine pandoc version.  Please file an issue at https://github.com/tomduck/pandoc-eqnos/issues
fredcallaway commented 8 years ago

I just hardcoded my pandoc version into the file.

I wonder if it might be better to just assume the most recent version if you can't get the version, with a warning message of course.

tomduck commented 8 years ago

Thanks for the feedback, @fredcallaway. This is an issue because pandoc doesn't provide filter authors with version information. See pandoc Issue #2640.

Can you please tell me how panzer calls pandoc with the pandoc-fignos filter? e.g., Is python's subprocess module used? If so, what does the call look like?

Pandoc-eqnos checks for version information by testing for:

1) A command-line argument to pandoc-fignos (used with pipe chains in my regression tests); 2) The version of the parent process (usually pandoc); and 3) The version of whatever pandoc is available from the command line.

These are in order of precedence. The first check that succeeds wins.

If none of these checks can be made to work for you then we will add another. There should be no need to hard-code version information into pandoc-fignos itself.

fredcallaway commented 8 years ago

subprocess is used. Here's an excerpt:

command = [entry['command']] + entry['arguments']
...
process = subprocess.Popen(command,
                           stderr=subprocess.PIPE,
                           stdin=subprocess.PIPE,
                           stdout=subprocess.PIPE)

I think entry['command'] is "pandoc-eqnos". I'm not sure about arguments. I think the writer is the first argument.

It seems that (3) should work here though, because I can indeed call pandoc -v from a terminal.

tomduck commented 8 years ago

I see the problem. You are using pandoc-fignos in a pipe chain, and so the parent process is panzer. (2) is succeeding when it should not. (1) is an option, but (3) would be better. Let me get back to you.

tomduck commented 8 years ago

I reworked the version detection code (again!) and posted pandoc-eqnos 0.10 to pypi. It should work for you. Can you give it a test and let me know?

fredcallaway commented 8 years ago

Well done! Will you port this to fignos as well? If so, I’ll start tracking version there as well.

Cheers, Fred

On Apr 27, 2016, at 9:25 PM, Thomas J. Duck notifications@github.com wrote:

I reworked the version detection code (again!) and posted pandoc-eqnos 0.10 to pypi. It should work for you. Can you give it a test and let me know?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/tomduck/pandoc-eqnos/issues/12#issuecomment-215280564

tomduck commented 8 years ago

Thanks! Yes, I have already pushed the updated code for fignos and tablenos to GitHub. I'm working on a few other fignos Issues, and expect to have a new release ready in the next few days. Soon enough?

Cheers, Tom

tomduck commented 8 years ago

I'm refactoring pandoc-fignos to support some fancy new features. The updates for this Issue will go out at the same time. Stay tuned...

fredcallaway commented 8 years ago

Oh boy! I'm crossing my fingers for "Figure 2 on page 4"

tomduck commented 8 years ago

I just posted a new release to pypi that has this feature. Thanks again for your feedback. Please let me know if you have any trouble with it.

Note that pandoc-fignos/eqnos/tablenos now have clever referencing. Fun!