Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Quarto-style comment blocks #3557

Closed
tomshafer opened this issue Feb 9, 2023 · 4 comments · May be fixed by #3561
Closed

Support Quarto-style comment blocks #3557

tomshafer opened this issue Feb 9, 2023 · 4 comments · May be fixed by #3561
Labels
F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?

Comments

@tomshafer
Copy link

Describe the style change

Presently black inserts a space between the "#" and "|" in Quarto metadata comments like #| label: cell1.

Examples in the current Black style

Space is inserted between the hash and the pipe:

# | label: cell-no1
# | echo: false

Desired style

No space between the hash and the pipe, which breaks document metadata parsing:

#| label: cell-no1
#| echo: false

Additional context

Quarto is the new(ish) replacement for RMarkdown and uses these kinds of comments for metadata in, e.g., Jupyter cells and so black breaks document rendering. It would be nice to keep #| together in the same way as a couple of other comment pairs are preserved.

@tomshafer tomshafer added the T: style What do we want Blackened code to look like? label Feb 9, 2023
@ichard26 ichard26 added F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented labels Feb 10, 2023
@ichard26
Copy link
Collaborator

ichard26 commented Feb 10, 2023

Seems reasonable. All it would take is to add | to this string of exempted characters:

COMMENT_EXCEPTIONS = " !:#'"

I suppose this has to go into the preview style, but that'd make it not that friendly to use / practically unusable since --preview changes a lot of other things. Hmm.

@JelleZijlstra
Copy link
Collaborator

I'm actually hesitant to add more exceptions to that list. There's a never-ending list of tools that treat some particular comment specially. Perhaps we should bite the bullet and make this configurable, or tell the tools that they need to change.

@tomshafer
Copy link
Author

Thanks for the consideration. I've opened a PR in case it's OK to merge; would be a nice quality of life improvement! Cheers.

@JelleZijlstra
Copy link
Collaborator

Closing in favor of #3668.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants