github executablebooks/MyST-NB v0.2.0
Refactor Parsing Process

latest releases: v1.1.2, v1.1.1, v1.1.0...
4 years ago

With the shiny new mistletoe-ebp API (see https://mistletoe-ebp.readthedocs.io/en/latest/using/intro.html#programmatic-use), the parsing process has been refactored to be more inline with how it will occur for the text based representation:

  1. The full notebook is converted to an 'intermediate' mistletoe/markdown AST (before inline text is processed), in order to collect all link/footnote definitions
  2. This AST is then walked to 'expand' SpanContainer (see https://mistletoe-ebp.readthedocs.io/en/latest/using/intro.html#the-parse-process)
  3. The SphinxNBRenderer is applyed once on the full AST (rather than for each cell as was done previously).

This involved creating a specific CodeCell mistletoe token, then adding an extra render method to SphinxRenderer that knows how to deal with it, basically using the code from https://github.com/ExecutableBookProject/MyST-NB/blob/d089de3c1140f72daf7c579be7637164ee548028/myst_nb/parser.py#L98

Note: this logic has been removed: https://github.com/ExecutableBookProject/MyST-NB/blob/d089de3c1140f72daf7c579be7637164ee548028/myst_nb/parser.py#L89

Since it is not compatible with the new process, as already discussed in #30

Don't miss a new MyST-NB release

NewReleases is sending notifications on new releases.