Skip to content

✨ feat(mq-lang): add depth parameter to section::sections - #2208

Merged
harehare merged 3 commits into
mainfrom
feat/section-sections-depth
Aug 15, 2026
Merged

✨ feat(mq-lang): add depth parameter to section::sections#2208
harehare merged 3 commits into
mainfrom
feat/section-sections-depth

Conversation

@harehare

Copy link
Copy Markdown
Owner

Summary

sections() previously only supported flat boundaries (every heading of any level ends the previous section), so nested subsection content was unreachable in bulk without calling section() once per known heading name. Add a depth parameter reusing the same same-or-higher-level boundary algorithm section() already had, and simplify section() to delegate to sections(md_nodes, depth) | title_contains(pattern).

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation
  • ⚡ Performance
  • ✅ Test
  • 📦 Build / dependencies
  • 👷 CI

Checklist

  • I ran cargo fmt and cargo clippy and addressed any warnings
  • I ran just test-all and all tests pass
  • I added or updated tests covering this change
  • I updated relevant documentation (/docs, crate README.md) if needed
  • I added a changelog entry if this is a user-facing change

Additional Context

sections() previously only supported flat boundaries (every heading of
any level ends the previous section), so nested subsection content was
unreachable in bulk without calling section() once per known heading
name. Add a depth parameter reusing the same same-or-higher-level
boundary algorithm section() already had, and simplify section() to
delegate to sections(md_nodes, depth) | title_contains(pattern).

split() is intentionally left untouched: reusing the new nested logic
there would drop content from the documented split-document-by-heading
cookbook example.
Replace the ad-hoc single-case depth tests with @parametrize cases
covering both depth=false and depth=true, matching the file's existing
table-driven style. Also adds a flat-mode negative check (subheading
text must NOT leak into a flat section's body) that the previous
depth=true-only tests didn't cover.
@codspeed-hq

codspeed-hq Bot commented Aug 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing feat/section-sections-depth (ad977cd) with main (b825b51)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (b536ca8) during the generation of this report, so b825b51 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Avoid recomputing len(start_indices) on every while-loop iteration.
@harehare
harehare merged commit c39c628 into main Aug 15, 2026
12 checks passed
@harehare
harehare deleted the feat/section-sections-depth branch August 15, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant