You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🐛 FIX: report accurate source lines for directives and text
Fix three classes of wrong source-line attribution:
- Directive option warnings (unknown key, invalid value, bad YAML,
comments) now point at the offending option's own source line,
for both `---` and `:option:` block styles, instead of the
directive's opening line.
Unknown option keys are now warned once per key, at its own line.
The `---` options block is now split line-based: any text trailing
a closing delimiter still becomes body content (as previously),
but is kept as its own line, so it and all subsequent body lines
map exactly to their source lines.
A new `options_to_tokens` API in `myst_parser.parsers.options`
exposes the tokenizer's per-key positions, and its `State` now
records the lines of `#` comments
(`options_to_items` is now a thin wrapper around it).
Directives run from synthesized, non-source content (HTML images
and admonitions) attribute option warnings to the element's line.
- Directives with body content on the opening line (no-argument
directives such as `{note}`) reported every body warning one line
too low; `body_offset` is now `-1` for the merged first line.
- `document.current_line` was set once per directive and never
reset, so docutils' `Node.setup_child` stamped the most recent
directive's line (or 0) onto every subsequently-created line-less
node, e.g. every `Text` node - the root cause of tools such as
sphinxcontrib-spelling and gettext reporting 'line 0' or the last
directive's line. The renderer now keeps `current_line` in sync
as nodes are created.
Also:
- `block_text` passed to directives is now the full directive text
(opening fence, options, body, closing fence), matching what an
equivalent rST directive receives, so third-party directives that
inspect it see rST-consistent content.
- `include` with `:literal:` now sets the literal block's line to
`start-line + 1` (docutils parity) instead of a hardcoded 1.
Closes#546
# note starting in docutils 0.22 this option is now an integer instead of a string, see: https://github.com/live-clones/docutils/commit/f39ac1413e56a330c8fea6e0d080fed0ff2b8483
0 commit comments