Repository navigation
Diagnose a language word followed by {attrs} on a code fence (Q-2-57) - #825
gordonwoodhull wants to merge 2 commits into
Conversation
A fence like ```python {.marimo} failed with an uncoded parse error. The
grammar takes one language word or one braced attribute list on the
opening line, not both. It now reports Q-2-57 with a hint built from the
author's own list in the accepted order, with the language folded in:
`{#id .python .cls key=val}` for a code block, or
`{python #id .cls key=val}` for an executable cell.
The hint is offered only when a braced list follows the word; a braceless
list, two identifiers, or a word with punctuation keep the generic error.
The new language-with-attributes suggester reuses the attribute-order
helpers from Q-2-55/56.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
A suggester can now return a source range along with its hint. The language-with-attributes suggester returns the braced list, the text the parser did not expect, instead of the single character where it failed.
|
Converting this to a draft. The Q-2-57 diagnostic itself works as intended. The question I want to settle first is what the hint should say about the executable-cell form. The hint offers Separately, Q-2-36 started in January as a warning (Q-2-8) and became a hard error in #197. In Q1, That merits further discussion before this lands. |
A fenced code block like
used to fail with an uncoded "Parse error … unexpected character or token here" pointing at the space after
python. The grammar accepts either a single language word or one braced attribute list on the opening line, not both, but nothing said so. Pandoc does accept the combined form, so people write it.It now reports
Q-2-57("I didn't expect this after the code block's language.") with a hint built from the author's own attribute list, in the accepted order of identifier, then classes, then key-value pairs, with the language word folded in:The first form is a plain code block with the language as its first class. The second is an executable cell. Both
python {…}andpython{…}are covered.The hint is only offered when a braced list follows the word.
python .marimo, a list with two identifiers, and language names with punctuation (c++) keep the generic error.The suggester reuses the attribute-order machinery from Q-2-55/56 (shared classification and ordering helpers, plus a new
language-with-attributessuggester). The error is reported over the braced list, the text that wasn't expected, rather than the single character where the parser gave up; a suggester can now return a range along with its hint. The grammar is unchanged. Adds theQ-2-57docs page and catalog entry.