Open psychemedia opened 2 years ago
For processing rich md, such as tagged md cells readable by Jupytext format, we could have a custom .md
handler to read the doc into a notebook format using jupytext, then preprocess.
sphinx:
config:
nb_custom_formats:
.Rmd:
- jupytext.reads
- fmt: Rmd
I haven't found an obvious preprocessor pipeline for treating documents before Sphinx gets to work on them, but we could create a package to act as a custom handler that will do the preprocessing steps.
For example, Jupyter Book docs suggest:
I think we can pass extra parameters in the same way as
as_version
.The following fragment may also be handy for coding up a notebook preprocessor (the sphinx loader should use
nbformat.from_dict(json.loads(nb_body))
as the response, perhaps?)Docs for creating a custom
nbconvert
preprocessor here.The example given is to create the preprocessor class:
There also looks to be a
preprocess_cell
method that can be overwritten; presumably, each cell is iterated through and you can then process each cell in turn.Then configure the pipeline: