Skip to content

Conversation

@sswam
Copy link

@sswam sswam commented Mar 13, 2023

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 foo to foo: null before attempting to parse it as YAML, e.g.:

#| default_exp foo
#| export

is changed to:

#| default_exp foo: null
#| export: null

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):

  • filed a contributor agreement.
  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog

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.

@cscheid cscheid added this to the v1.4 milestone Mar 13, 2023
@cscheid
Copy link
Collaborator

cscheid commented Mar 13, 2023

Thanks for the PR, we appreciate it!. We're only going to be able to look at it carefully enough in a few weeks when our 1.3 release is finalized. I just wanted to make sure you know we're not ignoring this.

@cscheid cscheid added the early-in-release An issue that should be worked on early in the release (likely due to risk) label Mar 13, 2023
@ghost
Copy link

ghost commented Mar 14, 2023

Thanks for contributing @sswam.

@ghost ghost assigned cscheid May 11, 2023
@seeM
Copy link

seeM commented Jun 12, 2023

@cscheid, I believe this has been addressed by #3152, and you may close this PR.

Nbdev users can end directives with a trailing : (e.g. #| hide becomes #| hide:) which should work well with Quarto in both the ipynb to qmd case and vice versa.

@cscheid
Copy link
Collaborator

cscheid commented Jun 12, 2023

@seeM That's what I had thought as well. Thanks for confirming it!

@sswam I think you might be running an old version of quarto, since we merged a fix for #3152 in March. I'm going to go ahead and close this; feel free to follow up if you have a case that doesn't work for you.

@cscheid cscheid closed this Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

early-in-release An issue that should be worked on early in the release (likely due to risk)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants