executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx
https://myst-nb.readthedocs.io
BSD 3-Clause "New" or "Revised" License
207 stars 84 forks source link

Defer cell metadata based manipulations to a transform #84

Open chrisjsewell opened 4 years ago

chrisjsewell commented 4 years ago

Currently, there are a number of places in the parser/renderer where we manipulate the docutils AST based on cell metadata

It would probably be better, for future development/extensibility, to handle these in a seperate transform, rather than 'hard-baking' them into the parser. The full cell metadata should also be added to the CellNode, rather than just tags:

https://github.com/ExecutableBookProject/MyST-NB/blob/ab4ba1d0964a7fe0a6cd516143ccc0a472b63570/myst_nb/parser.py#L203-L205

choldgraf commented 4 years ago

That seems reasonable to me. That way all of the cell metadata is always present until the very end, and then at the last second a transform passes through all CellNodes and does what it needs to do based on what is inside?