Repository navigation
Return only the header line from to_markdown for empty sections - #44
Merged
Merged
Conversation
Section.to_markdown() appended two newlines after the header even when the section had no content. Return just the header line in that case. Add a test, and note in the README that freezing is shallow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jNL9rsodv5SMpDXVNMEia
Record the empty-section to_markdown fix under 0.3.0 Fixed. 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
Section.to_markdown()returns only the header line when the section has no content. For"# A\n## B", the first section now returns"# A"instead of"# A\n\n". Sections with content and level-0 sections behave as before.test_to_markdown_without_contentintests/test_splitter.py.metadata.parentsshould be treated as read-only.Why
A section without content got the header followed by two stray newlines. it was present in the old
MarkdownContent.to_markdowntoo.Verification
AssertionError: assert '# A\n\n' == '# A') and passes with the fix.uv sync --locked,uv run ruff check --no-fix .anduv run ruff format --check .pass.uv run pytest -q --cov=markdown_chunkify --cov-report=term-missing: 95 passed,models.pyat 100% coverage.uv run python -m doctest markdown_chunkify/splitter.pypasses.pydantic==2.0.2: 95 passed.