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
{{ message }}
Repository navigation
{include} with :start-after: adds a character index to the line number #1216
For {include} with :start-after:, the line numbers of the included content are wrong by a large amount. The
directive adds the marker's character index to startline, which is a line count:
startline is then passed on to nested_render_text(file_content, startline + 1, ...), so every line in the slice
(and every warning raised in it) is shifted by the number of characters that precede the end of the marker.
Reproduce
conf.py: extensions = ["myst_parser"], exclude_patterns = ["inc"]. There are three copies of the same file, inc/plain.md, inc/startline.md and inc/startafter.md, each using its own role name:
With myst-parser 5.1.0, docutils 0.22.4 and Sphinx 9.1.0, sphinx-build -E, the warnings are:
index.md:2: WARNING: Unknown interpreted text role "plain"
index.md:5: WARNING: Unknown interpreted text role "startline"
index.md:31: WARNING: Unknown interpreted text role "startafter"
The paragraph holding the role starts on line 1 (plain), and on line 4 for the two clipped includes. plain and startline are only off by the constant one of #1165. startafter reports line 31: the 28 characters up to the
end of START-HERE were added as lines.
Expected
:start-after: should add the number of lines consumed before the slice, for example file_content[:split_index + len(split_on)].count("\n"), so that it lands on the same line as :start-line: would.
A regression test of the warning line for :start-after: (and for :start-line: together with :start-after:)
would pin it, alongside #1165's fix.
Activity
🔧 MAINTAIN: drop the topmatter half (#1167 now lands via #1197)
🐛 FIX: exact source lines in `{include}`d files (executablebooks#1169)