tomduck / pandoc-eqnos

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

xnos-number-sections and unnumbered equations #30

Closed Gjacquenot closed 6 years ago

Gjacquenot commented 6 years ago

When using xnos-number-sections: On, it seems like all equations need an identifier {#eq:}. If not, an error is thrown. When NOT using this option, equation is not numbered and that is fine. We would expect the same behaviour with this option

Below is minimal markdown file that reproduce the error:

I use the latest versions of pandoc-eqnos with command

pip install -U pandoc-eqnos

File bug.md

---
xnos-number-sections: On
...

# Title 1

$$ x $$ {#eq:}

Symbol $x$ has no reference

Pandoc command:

pandoc --mathml --filter pandoc-eqnos -o bug.html bug.md

Error message:

Traceback (most recent call last):
  File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python36\Scripts\pandoc-eqnos.exe\__main__.py", line 9, in <module>
  File "c:\program files\python36\lib\site-packages\pandoc_eqnos.py", line 301, in main
    detach_attrs_math], blocks)
  File "c:\program files\python36\lib\site-packages\pandoc_eqnos.py", line 298, in <lambda>
    altered = functools.reduce(lambda x, action: walk(x, action, fmt, meta),
  File "c:\program files\python36\lib\site-packages\pandocfilters.py", line 113, in walk
    array.append(walk(item, action, format, meta))
  File "c:\program files\python36\lib\site-packages\pandocfilters.py", line 124, in walk
    x[k] = walk(x[k], action, format, meta)
  File "c:\program files\python36\lib\site-packages\pandocfilters.py", line 111, in walk
    item['c'] if 'c' in item else None, format, meta)
  File "c:\program files\python36\lib\site-packages\pandocxnos\core.py", line 893, in insert_secnos
    value[0][2].insert(0, ['secno', s])
KeyError: 2
Error running filter pandoc-eqnos:
Filter returned error status 1
Gjacquenot commented 6 years ago

A patch to this bug has been proposed in repository https://github.com/tomduck/pandoc-xnos: https://github.com/tomduck/pandoc-xnos/pull/5

Gjacquenot commented 6 years ago

Hello @tomduck , could you have a look, please?

tomduck commented 6 years ago

Sorry: We're right at the end of term and I teach a massive first-year class. I appreciate your contribution and will get to this as soon as I can. Cheers, Tom.

tomduck commented 6 years ago

This is now fixed in the pandoc-xnos nextrelease branch. I expect to merge it into the master branch then push it out to pypi within the next few days.

Thanks for identifying the problem, and also for your patience. :o)

Cheers, Tom

tomduck commented 6 years ago

I'm closing this in anticipation of a new release today. Thanks again for the feedback.

Cheers, Tom

Gjacquenot commented 6 years ago

Thanks for your work Tom.