Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion myst_parser/mocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def run(self) -> list[nodes.Element]:
f'Directive "{self.name}"; option "{split_on_type}": text not found "{split_on}".',
)
if split_on_type == "start-after":
startline += split_index + len(split_on)
startline += file_content[: split_index + len(split_on)].count("\n")
file_content = file_content[split_index + len(split_on) :]
else:
file_content = file_content[:split_index]
Expand Down
19 changes: 19 additions & 0 deletions tests/test_renderers/fixtures/mock_include_errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,22 @@ Error in include file:
.
tmpdir/bad.md:2: (WARNING/2) Unknown interpreted text role "a". [myst.role_unknown]
.

Error in include file with start-after:
.
```{include} bad_after.md
:start-after: START-HERE
```
.
tmpdir/bad_after.md:5: (WARNING/2) Unknown interpreted text role "a". [myst.role_unknown]
.

Error in include file with start-line and start-after:
.
```{include} bad_after.md
:start-line: 1
:start-after: START-HERE
```
.
tmpdir/bad_after.md:5: (WARNING/2) Unknown interpreted text role "a". [myst.role_unknown]
.
3 changes: 3 additions & 0 deletions tests/test_renderers/test_include_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def test_errors(file_params, tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)

tmp_path.joinpath("bad.md").write_text("{a}`b`")
tmp_path.joinpath("bad_after.md").write_text(
"line one\nline two\nSTART-HERE\nline four\n{a}`b`"
)

report_stream = StringIO()
publish_doctree(
Expand Down