tomduck / pandoc-eqnos

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

Error on Windows with Python 3.5.0 :: Anaconda 2.4.0 (64-bit) #7

Closed degloff closed 8 years ago

degloff commented 8 years ago

Hi

I get the following error:

Traceback (most recent call last): File "c:\anaconda3\lib\runpy.py", line 170, in _run_module_as_main "main", mod_spec) File "c:\anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Anaconda3\Scripts\pandoc-eqnos.exemain.py", line 9, in File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 268, in main [preprocess, replace_attreqs, replace_refs], doc) File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 267, in altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta), File "c:\anaconda3\lib\site-packages\pandocfilters.py", line 34, in walk array.append(walk(item, action, format, meta)) File "c:\anaconda3\lib\site-packages\pandocfilters.py", line 25, in walk res = action(item['t'], item['c'], format, meta) File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 156, in preprocess newvalue = repair_broken_refs(value) File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 107, in repair_broken_refs value[i+1]['t'], value[i+1]['c']): File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 92, in is_broken_ref return key1 == 'Link' and value1[1][0]['c'].endswith('{@eq') \ TypeError: string indices must be integers pandoc: Error running filter pandoc-eqnos Filter returned error status 1

The equation numbers are however properly generated and also the link work.

Many thanks for a brief feedback.

Thanks, Daniel

tomduck commented 8 years ago

Thanks for your report. This looks like the problem happened with the latest pandoc-eqnos release (0.7). Were you using earlier versions with success?

In any case, could you please submit a short test file that exposes the problem, along with the shell command used to process it?

degloff commented 8 years ago

Hi Thomas

I isolated the problem. It is caused by a normal link that is processed incorrectly. I use the newest version of pandoc-eqnos.

Here is a minimal sample that replicates the problem that should illustrate the problem and help to fix it.

Markdown file doc_producing_error.md:

 This points to [here](https://msdn.microsoft.com/en-us/library/ms172192.aspx).

Call pandoc with the filter:

pandoc --version
pandoc doc_producing_error.md -s -t html --filter pandoc-eqnos -o doc_producing_error.html

It produces the output:

C:\eqno-bug>pandoc --version
pandoc 1.15.2
Compiled with texmath 0.8.4, highlighting-kate 0.6.
Syntax highlighting is supported for the following languages:
    abc, actionscript, ada, agda, apache, asn1, asp, awk, bash, bibtex, boo, c,
    changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css,
    curry, d, diff, djangotemplate, dockerfile, dot, doxygen, doxygenlua, dtd,
    eiffel, email, erlang, fasm, fortran, fsharp, gcc, glsl, gnuassembler, go,
    haskell, haxe, html, idris, ini, isocpp, java, javadoc, javascript, json,
    jsp, julia, kotlin, latex, lex, lilypond, literatecurry, literatehaskell,
    lua, m4, makefile, mandoc, markdown, mathematica, matlab, maxima, mediawiki,
    metafont, mips, modelines, modula2, modula3, monobasic, nasm, noweb,
    objectivec, objectivecpp, ocaml, octave, opencl, pascal, perl, php, pike,
    postscript, prolog, pure, python, r, relaxng, relaxngcompact, rest, rhtml,
    roff, ruby, rust, scala, scheme, sci, sed, sgml, sql, sqlmysql,
    sqlpostgresql, tcl, tcsh, texinfo, verilog, vhdl, xml, xorg, xslt, xul,
    yacc, yaml, zsh
Default user data directory: C:\xxxxxxxxx\Roaming\pandoc
Copyright (C) 2006-2015 John MacFarlane
Web:  http://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.

C:\eqno-bug>pandoc doc_producing_error.md -s -t html --filter pandoc-eqnos -o doc_producing_error.html
Traceback (most recent call last):
  File "c:\anaconda3\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Anaconda3\Scripts\pandoc-eqnos.exe\__main__.py", line 9, in <module>
  File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 268, in main
    [preprocess, replace_attreqs, replace_refs], doc)
  File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 267, in <lambda>
    altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
  File "c:\anaconda3\lib\site-packages\pandocfilters.py", line 34, in walk
    array.append(walk(item, action, format, meta))
  File "c:\anaconda3\lib\site-packages\pandocfilters.py", line 25, in walk
    res = action(item['t'], item['c'], format, meta)
  File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 156, in preprocess
    newvalue = repair_broken_refs(value)
  File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 107, in repair_broken_refs
    value[i+1]['t'], value[i+1]['c']):
  File "c:\anaconda3\lib\site-packages\pandoc_eqnos.py", line 92, in is_broken_ref
    return key1 == 'Link' and value1[1][0]['c'].endswith('{@eq') \
TypeError: string indices must be integers
pandoc: Error running filter pandoc-eqnos
Filter returned error status 1
degloff commented 8 years ago

Here is a zip archive containing the files

eqno-bug.zip

tomduck commented 8 years ago

I just posted pandoc-eqnos 0.7.1. Could you please test it? If everything works, please go ahead and close this Issue.

Thanks so much for your report and help. It turns out that pandoc-1.16, the version I originally tested against, had a somewhat different link format in its internal document representation. The problem for older versions of pandoc was exposed when you ran it against 1.15.2. A good catch!

I will be sure to test against both versions in the future. It seems that pandoc 1.16 introduced a number of API changes.

degloff commented 8 years ago

I tested pandoc-eqnos 0.7.1. as well on a larger set of markdown files and the problem is resolved. Many thanks for the quick fix. Great tool!

tomduck commented 8 years ago

Splendid. And thank you!