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

FIX: Add mandatory attributes on enumerated_list #418

Merged

Conversation

cpitclaudel
Copy link
Contributor

@cpitclaudel cpitclaudel commented Aug 20, 2021

The doctrees that MyST generates are compatible with Sphinx but not with the normal Docutils pipeline. This PR fixes one of the incompatibilities. The first example of the API docs is enough to demonstrate the issue:

from myst_parser.main import to_docutils

document = to_docutils("""
Here's some *text*

1. a list

> a quote

{emphasis}`content`

```{sidebar} my sidebar
content
```
""")

from docutils.core import publish_from_doctree
print(publish_from_doctree(document, writer_name="latex").decode("utf-8"))
Traceback (most recent call last):
  File "./minimal.py", line 19, in <module>
    print(publish_from_doctree(document, writer_name="latex").decode("utf-8"))
  File "…/docutils/core.py", line 522, in publish_from_doctree
    return pub.publish(enable_exit_status=enable_exit_status)
  File "…/docutils/core.py", line 220, in publish
    output = self.writer.write(self.document, self.destination)
  File "…/docutils/writers/__init__.py", line 78, in write
    self.translate()
  File "…/docutils/writers/latex2e/__init__.py", line 251, in translate
    self.document.walkabout(visitor)
  File "…/docutils/nodes.py", line 214, in walkabout
    if child.walkabout(visitor):
  File "…/docutils/nodes.py", line 206, in walkabout
    visitor.dispatch_visit(self)
  File "…/docutils/nodes.py", line 1995, in dispatch_visit
    return method(node)
  File "…/docutils/writers/latex2e/__init__.py", line 2161, in visit_enumerated_list
    enumtype = types[node.get('enumtype' '')]
KeyError: None

The exact backtrace that docutils generates comes from a separate bug (https://sourceforge.net/p/docutils/patches/184/), but even with that fixed the LaTeX that gets generated is invalid, so it's probably worth fixing this here.

@chrisjsewell
Copy link
Member

Thanks, you just need to fix the tests

@cpitclaudel
Copy link
Contributor Author

Done, thanks

@codecov
Copy link

codecov bot commented Aug 27, 2021

Codecov Report

Merging #418 (0e98b28) into master (f799bcf) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #418   +/-   ##
=======================================
  Coverage   90.77%   90.78%           
=======================================
  Files          16       16           
  Lines        1875     1877    +2     
=======================================
+ Hits         1702     1704    +2     
  Misses        173      173           
Flag Coverage Δ
pytests 90.78% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
myst_parser/docutils_renderer.py 92.75% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f799bcf...0e98b28. Read the comment docs.

@chrisjsewell
Copy link
Member

thanks! look forward to the future docutils contributions 😄

@chrisjsewell chrisjsewell merged commit ffe8ad8 into executablebooks:master Sep 3, 2021
@welcome
Copy link

welcome bot commented Sep 3, 2021

Congrats on your first merged pull request in this project! 🎉
congrats

Thank you for contributing, we are very proud of you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants