Expand description
Parser for Quarto / RMarkdown executable code chunk metadata.
Two label sources, both supported:
- Inline info string:
```{r, label="setup", echo=FALSE} - 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 anykey=valueare 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§
- Chunk
Label - One label found while parsing a chunk header or body.
- Inline
Chunk Header - Parsed inline chunk header — the part inside
{...}.
Enums§
- Chunk
Label Source - Origin of a parsed label, mirrored from panache’s
ChunkLabelSourceso rules can distinguish inline-positional spaces (which are the strongest signal of a typo) from quoted-string spaces.
Functions§
- is_
executable_ chunk - Return
trueif 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; returnsNonefor plain display blocks like```r.