Found while probing #1164 (which does not change this behaviour — it is identical before and after).
All warnings/errors raised inside an {include}d markdown file are attributed one line too low. E.g. with sub.md:
line one
{unknownrole}`x`
included via ```{include} sub.md — the role warning reports sub.md:4, but the role is on line 3.
Cause
MockIncludeDirective.run calls:
self.renderer.nested_render_text(file_content, startline + 1, ...)
(myst_parser/mocking.py) but nested_render_text's lineno is added to the 0-based token maps before _render_tokens applies its own 0-based → 1-based + 1 conversion, so the correct argument for a file starting at (1-based) line startline + 1 is startline, not startline + 1. Every other caller (MockState.nested_parse) passes a value that composes correctly.
The fix is likely a one-character change, but wants a warning-line regression test for: a plain include, :start-line:, and nested includes, before touching it — the include-with-:heading-offset: and front-matter-stripping paths (front_matter token pop shifts nothing since maps are preserved) should be probed too.
Found while probing #1164 (which does not change this behaviour — it is identical before and after).
All warnings/errors raised inside an
{include}d markdown file are attributed one line too low. E.g. withsub.md:line one {unknownrole}`x`included via
```{include} sub.md— the role warning reportssub.md:4, but the role is on line 3.Cause
MockIncludeDirective.runcalls:(
myst_parser/mocking.py) butnested_render_text'slinenois added to the 0-based token maps before_render_tokensapplies its own 0-based → 1-based+ 1conversion, so the correct argument for a file starting at (1-based) linestartline + 1isstartline, notstartline + 1. Every other caller (MockState.nested_parse) passes a value that composes correctly.The fix is likely a one-character change, but wants a warning-line regression test for: a plain include,
:start-line:, and nested includes, before touching it — theinclude-with-:heading-offset:and front-matter-stripping paths (front_mattertoken pop shifts nothing since maps are preserved) should be probed too.