Skip to content

Commit

Permalink
Enable parsing of translated paragraphs (WARNING: temporary!)
Browse files Browse the repository at this point in the history
Fixes #154.
  • Loading branch information
mgeier committed Jan 9, 2018
1 parent d776daf commit 0134447
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/nbsphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,27 @@ def get_transforms(self):
ProcessLocalLinks, ReplaceAlertDivs]

def parse(self, inputstring, document):
"""Parse `inputstring`, write results to `document`."""
nb = nbformat.reads(inputstring, as_version=_ipynbversion)
"""Parse *inputstring*, write results to *document*.
*inputstring* is either the JSON representation of a notebook,
or a paragraph of text coming from the Sphinx translation
machinery.
Note: For now, the translation strings use reST formatting,
because the NotebookParser uses reST as intermediate
representation.
However, there are plans to remove this intermediate step
(https://github.com/spatialaudio/nbsphinx/issues/36), and after
that, the translated strings will most likely be parsed as
CommonMark.
"""
try:
nb = nbformat.reads(inputstring, as_version=_ipynbversion)
except Exception:
# NB: The use of the RST parser is temporary!
rst.Parser.parse(self, inputstring, document)
return
env = document.settings.env
srcdir = os.path.dirname(env.doc2path(env.docname))
auxdir = os.path.join(env.doctreedir, 'nbsphinx')
Expand Down

0 comments on commit 0134447

Please sign in to comment.