-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fixed bug where MarkdownHeaderSplitter's split result missed the first direct parent's header in the metadata and added lark to pyproject.toml #11042
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
Merged
sjrl
merged 17 commits into
deepset-ai:main
from
MechaCritter:bugfix/markdown_header_splitter
Apr 9, 2026
+92
−8
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6d35380
fixed bug where MarkdownHeaderSplitter's split result missed the firs…
MechaCritter ced2666
added release note
MechaCritter 0fdea30
Merge branch 'main' into bugfix/markdown_header_splitter
MechaCritter d78d837
reverted changes of adding "lark"
MechaCritter 9f43069
collapsed release note to contain only "fixes"
MechaCritter dae77ef
added test "test_keep_headers_with_secondary_split_preserves_parent_h…
MechaCritter 8f362ae
Merge remote-tracking branch 'refs/remotes/origin/bugfix/markdown_hea…
MechaCritter be4dd40
Update releasenotes/notes/fix-missing-parent-header-error-MarkdownHea…
MechaCritter b50296a
Update releasenotes/notes/fix-missing-parent-header-error-MarkdownHea…
MechaCritter 450b69f
Update releasenotes/notes/fix-missing-parent-header-error-MarkdownHea…
MechaCritter a2c7820
Update releasenotes/notes/fix-missing-parent-header-error-MarkdownHea…
MechaCritter 0fe3481
Update test/components/preprocessors/test_markdown_header_splitter.py
MechaCritter a6eb3f0
Update test/components/preprocessors/test_markdown_header_splitter.py
MechaCritter 58fcad1
Update test/components/preprocessors/test_markdown_header_splitter.py
MechaCritter c364f5c
Update test/components/preprocessors/test_markdown_header_splitter.py
sjrl 6de41d9
Merge branch 'main' into bugfix/markdown_header_splitter
MechaCritter 5c85f3d
Merge branch 'main' into bugfix/markdown_header_splitter
sjrl 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
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
61 changes: 61 additions & 0 deletions
61
...enotes/notes/fix-missing-parent-header-error-MarkdownHeaderSplitter-b5db96e19011b6b9.yaml
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,61 @@ | ||
| --- | ||
| fixes: | ||
| - | | ||
| When using the **MarkdownHeaderSplitter**, in the split chunks, the child header previously lost | ||
| its direct parent header in the metadata. Previously if one executed the code below: | ||
| .. code:: python | ||
| from haystack.components.preprocessors import MarkdownHeaderSplitter | ||
| from haystack import Document | ||
| text = """ | ||
| # header 1 | ||
| intro text | ||
| ## header 1.1 | ||
| text 1 | ||
| ## header 1.2 | ||
| text 2 | ||
| ### header 1.2.1 | ||
| text 3 | ||
| ### header 1.2.2 | ||
| text 4 | ||
| """ | ||
| document = Document(content=text) | ||
| splitter = MarkdownHeaderSplitter( | ||
| keep_headers=True, | ||
| secondary_split="word" | ||
| ) | ||
| result = splitter.run(documents=[document])["documents"] | ||
| for doc in result: | ||
| print(f"Header: {doc.meta['header']}, parent headers: {doc.meta['parent_headers']}") | ||
| We would have expected this output: | ||
| .. code:: text | ||
| Header: header 1, parent headers: [] | ||
| Header: header 1.1, parent headers: ['header 1'] | ||
| Header: header 1.2, parent headers: ['header 1'] | ||
| Header: header 1.2.1, parent headers: ['header 1', 'header 1.2'] | ||
| Header: header 1.2.2, parent headers: ['header 1', 'header 1.2'] | ||
| But instead we actually got: | ||
| .. code:: text | ||
| Header: header 1, parent headers: [] | ||
| Header: header 1.1, parent headers: [] | ||
| Header: header 1.2, parent headers: ['header 1'] | ||
| Header: header 1.2.1, parent headers: ['header 1'] | ||
| Header: header 1.2.2, parent headers: ['header 1', 'header 1.2'] | ||
| The error happened when a parent header had its own content chunk before the first | ||
| child header. | ||
| This has been fixed so even when a parent header has its own content chunk before the first child header all content is preserved. |
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
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.
Uh oh!
There was an error while loading. Please reload this page.