Shared per-cell line-width metadata for source formatting #14898
Replies: 4 comments 1 reply
|
For R, Regarding the naming, that's going to be tricky because that's a real "mess":
|
|
Right, also one might want more options than just line width. Maybe behind a table instead. I don't necessarily think naming has to be so problematic since there would anyway need to be an adapter that translates this from a quarto option to ruff/air/biome/etc. |
|
Partly related to this: |
|
I am going to go ahead and switch to use the following schema in Panache: code-style:
line-width: 72
indent-width: 2Panache will accept this as both a top-level (YAML metadata) option, and also as a code chunk option. So that users can now write: #| code-style:
#| line-width: 40
#| indent-width: 2
a <- some_long_function(with, lots, of, arguments)Hopefully this is something that you (the Quarto people) will eventually adopt too. And I'll try to coordinate with some other formatters that also do formatting for code chunks. One possible issue is that people may want separate options for different languages, but perhaps a second table could do? code-style:
line-width: 80
r:
line-width: 72 # override top-level option
indent-width: 2 |
Uh oh!
There was an error while loading. Please reload this page.
I’m the author of Panache, a formatter, linter, and language server for Markdown and Quarto. Panache delegates code-block formatting to language-specific formatters, and I’m considering adding support for a per-block formatting width.
The use case comes from my teaching slides: some code appears in narrow columns, while other examples span the full slide. A single project-wide line width doesn’t work well for both.
I’d like authors to express a target source-code line width independently of the language or formatter. One possible syntax would be:
Panache would read this metadata and pass the width to the configured formatter—for example,
--line-width 40to Arity. The setting would apply only to that block, with unmarked blocks retaining their configured defaults. Quarto itself wouldn’t need to invoke a formatter.Before introducing a Panache-specific option, I’d appreciate guidance on a shared convention:
The intended meaning is a target width for formatting source code, measured in columns. The name
format-widthis tentative; I’m happy to follow an existing convention or coordinate on a suitable one.All reactions