Skip to content

feat: MarkdownHeaderSplitter Add option to control which header depths create split boundaries and ignore # lines within code blocks - #11011

Merged
sjrl merged 5 commits into
mainfrom
markdown-header-splitter-improvements
Apr 1, 2026
Merged

sjrl merged 5 commits into
mainfrom
markdown-header-splitter-improvements

Conversation

@sjrl

@sjrl sjrl commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Related Issues

  • fixes #issue-number

Proposed Changes:

  • MarkdownHeaderSplitter now accepts a header_split_levels parameter (list of integers 1–6, default all levels) to control which header depths create split boundaries. For example, header_split_levels=[1, 2] splits only on # and ## headers, merging content under deeper headers into the preceding chunk.
  • MarkdownHeaderSplitter now ignores # lines that appear inside fenced code blocks (triple-backtick or triple-tilde), preventing Python comments and other hash-prefixed lines in code from being misidentified as Markdown headers.

How did you test it?

Added new unit tests.

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

sjrl added 2 commits April 1, 2026 14:38
… to split on. Also added support to skip over content contained within code blocks to prevent matches against python comments.
@vercel

vercel Bot commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Preview Apr 1, 2026 1:26pm

Request Review

@sjrl sjrl self-assigned this Apr 1, 2026
@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Apr 1, 2026
@coveralls

coveralls commented Apr 1, 2026 •

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 23850965533

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.006%) to 92.91%

Files with Coverage Reduction New Missed Lines %
components/preprocessors/markdown_header_splitter.py 6 96.39%
Totals Coverage Status
Change from base Build 23847218878: 0.006%
Covered Lines: 15895
Relevant Lines: 17108

💛 - Coveralls

@sjrl
sjrl marked this pull request as ready for review April 1, 2026 13:27
@sjrl
sjrl requested a review from a team as a code owner April 1, 2026 13:27
@sjrl
sjrl requested review from anakin87 and removed request for a team April 1, 2026 13:27

@anakin87 anakin87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement!

@sjrl
sjrl merged commit a9f9f85 into main Apr 1, 2026
23 checks passed
@sjrl
sjrl deleted the markdown-header-splitter-improvements branch April 1, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants