Skip to main content

Module quarto_chunks

Module quarto_chunks 

Source
Expand description

Parser for Quarto / RMarkdown executable code chunk metadata.

Two label sources, both supported:

  1. Inline info string: ```{r, label="setup", echo=FALSE}
  2. Hashpipe chunk options inside the block body: #| label: setup

The inline form supports three shapes:

  • Bare label as the first positional argument: {r setup} or {r several words} (multiple bare words before any key=value are treated as a whitespace- separated label; this is also how the linter detects spaces in labels).
  • Explicit label=value: {r, label=setup} or {r, label="my label"}.
  • Mixed forms like {r setup, echo=FALSE}.

The grammar reflects how knitr/Quarto themselves parse chunk headers. We do not aim for full knitr fidelity; the goal is to recognise the patterns that drive the two lint rules using this helper (MD078, MD079).

Structs§

ChunkLabel
One label found while parsing a chunk header or body.
InlineChunkHeader
Parsed inline chunk header — the part inside {...}.

Enums§

ChunkLabelSource
Origin of a parsed label, mirrored from panache’s ChunkLabelSource so rules can distinguish inline-positional spaces (which are the strongest signal of a typo) from quoted-string spaces.

Functions§

is_executable_chunk
Return true if the chunk header denotes an executable Quarto chunk.
parse_hashpipe_labels
Scan the body of a fenced code block for hashpipe label options (#| label: setup).
parse_inline_chunk_header
Try to parse the info string of a fenced code block as a Quarto inline chunk header. Accepts both {r} and {r, label=foo} shapes; returns None for plain display blocks like ```r.