Fix issue 3152 - convert nbdev directives to YAML #4807
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
(This likely needs more work and testing.)
Quarto assumes that
#|directive lines are valid YAML, but nbdev directives aren't.I've come up with a somewhat hacky workaround, which converts any nbdev directive
footofoo: nullbefore attempting to parse it as YAML, e.g.:is changed to:
When writing a code cell, it strips off the null value and just shows the plain nbdev directive again. I'm assuming that Quarto directives don't ever use a value of "null".
With these changes, it seems to be stripping the nbdev directives out of my blog posts when rendering from ipynb, and that's okay with me.
It can't currently render from qmd format if these nbdev directives are used. We would need to adjust something in how it's reading the YAML there too.
Checklist
I have (if applicable):
It's not much code, please let me know if you do want to use it and you require me to file a contributor agreement.