MyST-NB icon indicating copy to clipboard operation
MyST-NB copied to clipboard

Defer cell metadata based manipulations to a transform

Open chrisjsewell opened this issue 5 years ago • 1 comments

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

  • https://github.com/ExecutableBookProject/MyST-NB/blob/ab4ba1d0964a7fe0a6cd516143ccc0a472b63570/myst_nb/parser.py#L56-L63
  • https://github.com/ExecutableBookProject/MyST-NB/blob/ab4ba1d0964a7fe0a6cd516143ccc0a472b63570/myst_nb/parser.py#L207
  • https://github.com/ExecutableBookProject/MyST-NB/blob/ab4ba1d0964a7fe0a6cd516143ccc0a472b63570/myst_nb/parser.py#L218

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

chrisjsewell avatar Mar 17 '20 21:03 chrisjsewell

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?

choldgraf avatar Mar 17 '20 21:03 choldgraf