Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quarto-format-adapters

Three small stdin/stdout adapters for formatting Markdown and Quarto documents without losing executable-cell syntax.

The package installs three commands:

  • quarto-runic formats all Julia backtick fences with a single Runic process.
  • quarto-styler formats all R fences with one reusable R worker pool.
  • quarto-autocorrect applies AutoCorrect to prose and to # comments inside Python and Julia fences, including {python} and {julia} Quarto cells.

Both commands preserve the original fence opener. The shared parser also keeps CRLF line endings when quarto-runic temporarily normalizes Quarto fences.

Install

cargo install quarto-format-adapters

Runic, R with the styler package, and AutoCorrect remain external tools and must be installed separately. Their command paths can be supplied explicitly.

quarto-runic

quarto-runic --runic /path/to/runic

The command reads a complete document from standard input. It changes {julia} temporarily to julia, invokes Runic once in Markdown mode, and then restores the original opener and attributes. QUARTO_RUNIC_RUNIC can provide the executable path instead of --runic.

quarto-styler

quarto-styler --rscript /path/to/Rscript

The command extracts all top-level r, {r}, and {r ...} fences and formats each body independently with styler::style_text() in a reusable R worker pool. It then restores the bodies without changing fence openers, attributes, or the document's line-ending style. The pool defaults to twelve workers; QUARTO_STYLER_WORKERS can override that number.

Formatted fence bodies are cached under the local application-data directory, so unchanged blocks do not start R on later formatting passes. Set QUARTO_STYLER_CACHE_DIR to relocate the cache. When changing styler versions or style configuration, set a new QUARTO_STYLER_CACHE_TAG to invalidate old entries.

QUARTO_STYLER_RSCRIPT can provide the executable path instead of --rscript.

quarto-autocorrect

quarto-autocorrect --autocorrect /path/to/autocorrect

AutoCorrect normally skips the contents of executable Quarto fences. This adapter retains AutoCorrect's normal Markdown pass and performs one additional text-mode pass over Python and Julia # comments. Quarto #| cell options and hash characters inside quoted strings are excluded.

QUARTO_AUTOCORRECT_COMMAND can provide the executable path instead of --autocorrect.

Editor formatter chain

These commands are designed to compose with other stdin formatters. A typical Quarto chain is:

Panache -> quarto-styler -> quarto-runic -> quarto-autocorrect

When Panache precedes quarto-styler, disable Panache's per-fence R formatter so that it does not start one R process for every fence.

Each command exits nonzero and reports the underlying formatter error on standard error when its external process fails.

Development

cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-targets
cargo publish --dry-run

About

Quarto-aware stdin adapters for Runic and AutoCorrect

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages