Repository navigation
Clean up the splitter internals - #43
Merged
Merged
Conversation
Name the header tuple, track the name of the open block for the unclosed-block warning, replace _trim with a range helper so spans and content come from one place, and shorten the docstrings. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jNL9rsodv5SMpDXVNMEia
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jNL9rsodv5SMpDXVNMEia
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.
What changed
All changes are in
markdown_chunkify/splitter.py._find_headersreturnslist[_Header], aNamedTuplewithline_start,content_start,levelandtext.split_textuses attribute access instead of positional unpacking.block_nameis set when a fence or HTML block opens. This replaces the chain that rebuilt the name at the end. The warning uses lazy %-formatting and renders the same message as before._trimmed_range(text, start, end)replaces_trim. It gives the preamble range (so thetext.index(...)lookup is gone), the header content and the header span end._LEADING_BLANK_LINES_PATTERNdrops its^, because^without MULTILINE only matches at position 0, not at thepospassed tomatch().max_levelunderAttributes:. Thesplit_textReturns section is now two sentences, and the hanging indent in thetextarg is fixed. Thesplit_textexample is still the one doctest.Why
The splitter was harder to read than it needed to be: positional tuple indexes, a warning name rebuilt from the closing tag, and two separate trimming paths for content and spans. Nothing user-facing changes, so there is no CHANGELOG entry.
Verification
ruff checkandruff format --checkpass.pytest: 94 passed with no test edits. Coverage is 99% overall and 98% forsplitter.py. The 2 missed lines are the same front-matter lines that main misses.uv buildworks. The wheel imports in a fresh venv and passes the# Cafécheck.pydantic==2.0.2, 94 passed.max_level1-6, which makes 30096 calls and 51735 sections.model_dump()output and the captured WARNING messages matched in every call. 18960 of those calls logged a warning, covering every block kind.splitter.pydrops from 351 to 288 lines.