Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dhimmel opened this issue Jan 17, 2020 · 4 comments
Closed

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

dhimmel opened this issue Jan 17, 2020 · 4 comments
Labels

Comments

@dhimmel
Copy link

dhimmel commented Jan 17, 2020

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
@tomduck tomduck added the bug label Jul 30, 2020
@tomduck
Copy link
Owner

tomduck commented Jul 30, 2020

Thank you for the report and sorry for the long wait. This is definitely a bug. I have fixed it in the nextrelease branch. If the problem should reappear following the next release, please feel welcome to re-open this issue.

Tom

@tomduck tomduck closed this as completed Jul 30, 2020
@dhimmel
Copy link
Author

dhimmel commented Jul 30, 2020

Thanks! Reference the commit at d479d14

@tomduck
Copy link
Owner

tomduck commented Jul 30, 2020

Sorry, Daniel, but I am not sure if you are asking me to do something here?

@dhimmel
Copy link
Author

dhimmel commented Jul 30, 2020 via email

dhimmel added a commit to dhimmel/manubot-rootstock that referenced this issue Oct 30, 2020
pandoc-eqnos upgrade addresses the following error:
tomduck/pandoc-eqnos#43
UnboundLocalError: local variable 'ret' referenced before assignment
dhimmel added a commit to dhimmel/manubot-rootstock that referenced this issue Oct 31, 2020
pandoc-eqnos upgrade addresses the following error:
tomduck/pandoc-eqnos#43
UnboundLocalError: local variable 'ret' referenced before assignment
dhimmel added a commit to manubot/rootstock that referenced this issue Nov 1, 2020
merges #383

pandoc-eqnos upgrade addresses the following error:
UnboundLocalError: local variable 'ret' referenced before assignment
tomduck/pandoc-eqnos#43

Hold back pandoc due to the lack of panflute support.

Switch commands in build/README.md to be relative to the repo root.
ploegieku added a commit to ploegieku/2023-functional-homology-paper that referenced this issue Aug 6, 2024
merges manubot/rootstock#383

pandoc-eqnos upgrade addresses the following error:
UnboundLocalError: local variable 'ret' referenced before assignment
tomduck/pandoc-eqnos#43

Hold back pandoc due to the lack of panflute support.

Switch commands in build/README.md to be relative to the repo root.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants