fix: slice search sections on the same line breaks markdown-it counts - #76
Open
Abhishek-B-R wants to merge 1 commit into
Open
Abhishek-B-R wants to merge 1 commit into
Abhishek-B-R wants to merge 1 commit into
Conversation
project_sections cut the body with str.splitlines(), but the heading boundaries come from markdown-it token maps, which only count \n, \r\n and \r as line breaks. splitlines() also breaks on form feeds, U+2028, U+2029, U+0085 and a few control characters, so one of those in a page shifted every later slice: section bodies picked up their own heading line and the text before it moved into the wrong section. Split on the same three breaks markdown-it uses.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
project_sectionssplits the body with a regex on\r\n,\rand\ninstead ofstr.splitlines().tests/test_wiki_sections.py.Why
heading boundaries come from markdown-it's
token.map, which only counts\n,\r\nand\r.splitlines()also breaks on form feeds, U+2028, U+2029, U+0085 and a few control chars, so one of those in a page shifts every section after it. the section body then starts with its own## headingline and search reports the wrong heading for a match.Verification
Docs and wiki
.almanac/wiki updated if an implementation decision, workflow, invariant, or gotcha changed.the new test fails on main and passes here.
Notes for reviewers
CRLF and lone
\rbodies split the same as before.ruff format --checkflags a trailing blank line insections.pythat is already on main; left it alone to keep the diff small.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.