Skip to content

Unclear error message when used with pandoc --to=jats #43

Closed
@dhimmel

Description

@dhimmel

In a build for manubot/rootstock#82, I'm getting the following error:

  File "/home/appveyor/miniconda/envs/manubot/lib/python3.7/site-packages/pandoc_eqnos.py", line 213, in _add_markup
    return ret
UnboundLocalError: local variable 'ret' referenced before assignment

The corresponding pandoc-eqnos function is:

def _add_markup(fmt, eq, value):
"""Adds markup to the output."""
attrs = eq['attrs']
# Context-dependent output
if eq['is_unnumbered']: # Unnumbered is also unreferenceable
ret = None
elif fmt in ['latex', 'beamer']:
ret = RawInline('tex',
r'\begin{equation}%s\end{equation}'%value[-1])
elif fmt in ('html', 'html5', 'epub', 'epub2', 'epub3') and \
LABEL_PATTERN.match(attrs.id):
# Present equation and its number in a span
num = str(references[attrs.id].num)
outer = RawInline('html',
'<span%sclass="eqnos">' % \
(' ' if eq['is_unreferenceable'] else
' id="%s" '%attrs.id))
inner = RawInline('html', '<span class="eqnos-number">')
eqno = Math({"t":"InlineMath"}, '(%s)' % num[1:-1]) \
if num.startswith('$') and num.endswith('$') \
else Str('(%s)' % num)
endtags = RawInline('html', '</span></span>')
ret = [outer, AttrMath(*value), inner, eqno, endtags]
elif fmt == 'docx':
# As per http://officeopenxml.com/WPhyperlink.php
bookmarkstart = \
RawInline('openxml',
'<w:bookmarkStart w:id="0" w:name="%s"/><w:r><w:t>'
%attrs.id)
bookmarkend = \
RawInline('openxml',
'</w:t></w:r><w:bookmarkEnd w:id="0"/>')
ret = [bookmarkstart, AttrMath(*value), bookmarkend]
return ret

We're specifying pandoc's --to=jats, which does not appear to be supported by this function. Should there be a final else to capture unsupported formats and either:

  1. provide a more clear error message
  2. issue a warning that pandoc-eqnos does not support JATS, but proceed such that the pandoc command does not fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions