feat: support page numbers in Markdown page breaks#639
Open
gyx09212214-prog wants to merge 2 commits into
Open
feat: support page numbers in Markdown page breaks#639gyx09212214-prog wants to merge 2 commits into
gyx09212214-prog wants to merge 2 commits into
Conversation
Contributor
|
✅ DCO Check Passed Thanks @gyx09212214-prog, all your commits are properly signed off. 🎉 |
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
…og@users.noreply.github.com> I, gyx09212214-prog <243787584+gyx09212214-prog@users.noreply.github.com>, hereby add my Signed-off-by to this commit: 8d675d4 Signed-off-by: gyx09212214-prog <243787584+gyx09212214-prog@users.noreply.github.com>
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
Adds named page-number placeholders for Markdown
page_break_placeholdervalues.Today
MarkdownParams(page_break_placeholder="<!-- page {page_no} -->")emits{page_no}literally. The internal page-break marker already carries both previous and next page numbers, so this change formats the placeholder when the final Markdown text is assembled.Supported placeholders:
{page_no}: the page after the break, matching the common “page marker before page N” use case{next_page}: same value as{page_no}{prev_page}: the page before the breakExisting literal placeholders such as
"<!-- page break -->","", andNonekeep their current behavior.This helps document/RAG pipelines preserve page-level provenance in Markdown exports, which is useful for citations and traceable retrieval chunks. It also addresses the page-number placeholder part of docling-project/docling#2036.
Tests
python -m pytest test/test_serialization.py -q(48 passed)python -m py_compile docling_core/transforms/serializer/markdown.py test/test_serialization.pygit diff --checkpython -m ruff check docling_core/transforms/serializer/markdown.py test/test_serialization.py