Repository navigation
fix(repo): preserve physical Markdown claim line numbers #705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mangeshraut712
wants to merge
6
commits into
intel:main
Choose a base branch
from
mangeshraut712:fix/686-markdown-physical-lines
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+92
−5
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b401c1d
test: preserve interval contracts across numerical backends
mangeshraut712 790da66
fix(repo): count physical Markdown source lines
mangeshraut712 022e331
Merge branch 'main' into fix/686-markdown-physical-lines
vchamarthi 3b1cb2b
fix(repo): preserve Markdown recognition while counting source lines
mangeshraut712 95fef45
Merge remote-tracking branch 'origin/main' into fix/686-markdown-phys…
mangeshraut712 f5a8db6
Merge remote-tracking branch 'upstream/main' into fix/686-markdown-ph…
mangeshraut712 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
dokimi/changelog.d/20261113_100500_mangeshraut712_markdown-lines.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ### Fixed | ||
|
|
||
| - Keep Markdown link, inline-code and fenced-code claim line numbers aligned with source files containing Unicode line separators. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Copyright (C) 2026 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Markdown claim locations use source-file lines, not Unicode separators.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from dokimi.repos.l0.markdown import split | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("separator", ["\u2028", "\u2029", "\x85", "\v", "\f", "\x1c", "\x1d", "\x1e"]) | ||
| def test_unicode_separators_do_not_shift_markdown_claims(separator): | ||
| text = f"Intro{separator}continued\n[link](missing.md) and `src/missing.py`\n```bash\nmake missing\n```\n" | ||
| pieces = split(text) | ||
| assert [(n, target) for n, target, _ in pieces.links] == [(2, "missing.md")] | ||
| assert [(n, span) for n, span, _ in pieces.spans] == [(2, "src/missing.py")] | ||
| assert [(f.line, f.lang, f.lines) for f in pieces.fences] == [(3, "bash", [(4, "make missing")])] | ||
|
|
||
|
|
||
| def test_unicode_separator_preserves_fence_matching_with_physical_locations(): | ||
| pieces = split("prose\u2028```bash\n[link](missing.md)\n") | ||
| assert [(f.line, f.lang, f.lines) for f in pieces.fences] == [(1, "bash", [(2, "[link](missing.md)")])] | ||
| assert pieces.links == [] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("newline", ["\n", "\r\n", "\r"]) | ||
| def test_scan_keeps_physical_line_numbers_after_unicode_separator(tmp_path, newline): | ||
| from dokimi.repos import parse_manifest | ||
| from dokimi.repos.l0 import scan_repo | ||
| from dokimi.repos.source import WorkTree | ||
| from tests.test_repo_l0 import MANIFEST, _repo | ||
|
|
||
| guidance = newline.join(["Intro\u2028continued", "[link](missing.md)", "Paths: `src/missing.py`", ""]) | ||
| _repo(tmp_path, {"AGENTS.md": guidance, "src/keep.py": "", "CONTRIBUTING.md": ""}) | ||
| result = scan_repo(WorkTree(tmp_path), parse_manifest(MANIFEST)) | ||
| claims = {(c["kind"], c["claim"]): c["line"] for c in result["claims"]} | ||
| assert claims[("link", "missing.md")] == 2 | ||
| assert claims[("path", "src/missing.py")] == 3 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("newline", ["\n", "\r\n", "\r"]) | ||
| def test_fences_keep_physical_newlines_and_trailing_blank_line(newline): | ||
| pieces = split(newline.join(["intro", "```bash", "make all", "", ""])) | ||
| assert [(f.line, f.lang, f.lines) for f in pieces.fences] == [(2, "bash", [(3, "make all"), (4, "")])] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("separator", ["\u2028", "\u2029", "\x85", "\v", "\f", "\x1c", "\x1d", "\x1e"]) | ||
| def test_unicode_separator_preserves_closing_fences_and_reference_definitions(separator): | ||
| pieces = split(f"```bash\nmake all\n```{separator}Then run this\nSee [docs](missing.md).\n" | ||
| f"[x]: other.md{separator}more text\n") | ||
| assert [(f.line, f.lang, f.lines) for f in pieces.fences] == [(1, "bash", [(2, "make all")])] | ||
| assert [(n, target) for n, target, _ in pieces.links] == [(4, "missing.md"), (5, "other.md")] | ||
|
|
||
|
|
||
| def test_unicode_separator_preserves_span_and_info_string_matching(): | ||
| pieces = split("`src/keep.py\u2028and src/missing.py`\n```\u2028bash\nmake all\n```\n") | ||
| assert pieces.spans == [] | ||
| assert [(f.line, f.lang, f.lines) for f in pieces.fences] == [(2, "", [(2, "bash"), (3, "make all")])] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("separator", ["\u2028", "\u2029", "\x85", "\v", "\f", "\x1c", "\x1d", "\x1e"]) | ||
| @pytest.mark.parametrize("newline", ["\n", "\r\n", "\r"]) | ||
| def test_unicode_separator_preserves_blank_fenced_segments(separator, newline): | ||
| pieces = split(newline.join(["```bash", f"make all{separator}", "```", ""])) | ||
| assert [(f.line, f.lang, f.lines) for f in pieces.fences] == [(1, "bash", [(2, "make all"), (2, "")])] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: the exact
lopins (0.0 compensated, 1e-4 left to right) are gone, andhiis now a one-ULP window. The body mentions the one-ULP allowance, not the droppedlopins. Is the new boundary check (test.p(hi) >= ALPHA > test.p(nextafter(hi))) enough to pin the ends? I could not run these 7 tests here (scipy stub fails on both trees).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
test_the_callers_p_places_zero_when_the_backend_disagrees,lois pinned to0.0when the backend disagrees. For real delta intervals where floating-point rounding varies across runtime math libraries,test.p(hi) >= ALPHA > test.p(nextafter(hi))pinshito the exact single step ofpacrossALPHA, whilelomaintains the sign constraint without relying on non-portable machine-precision constants. The PR description has been updated to clarify what the tests stub and verify.