Skip to content

✨ feat(builtin): add frontmatter() for YAML/TOML frontmatter parsing#1813

Merged
harehare merged 4 commits into
mainfrom
feat/builtin-frontmatter
Jun 2, 2026
Merged

✨ feat(builtin): add frontmatter() for YAML/TOML frontmatter parsing#1813
harehare merged 4 commits into
mainfrom
feat/builtin-frontmatter

Conversation

@harehare

Copy link
Copy Markdown
Owner

Adds a new frontmatter() builtin that detects and parses both YAML and TOML frontmatter from markdown nodes using the existing yaml/toml import modules.

Updates example docs to use the simpler frontmatter() call.

@codspeed-hq

codspeed-hq Bot commented May 31, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 29.55%

⚡ 1 improved benchmark
✅ 28 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
eval_macro_expansion_simple 138.5 µs 106.9 µs +29.55%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/builtin-frontmatter (41189c4) with main (8435856)1

Open in CodSpeed

Footnotes

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

Adds a new `frontmatter()` builtin that detects and parses both YAML
and TOML frontmatter from markdown nodes using the existing yaml/toml
import modules.

Updates example docs to use the simpler frontmatter() call.
@harehare harehare force-pushed the feat/builtin-frontmatter branch from 8448d15 to d08f46e Compare June 1, 2026 13:22
harehare and others added 3 commits June 1, 2026 23:14
Add test_frontmatter() covering YAML/TOML parsing, non-frontmatter
nodes, and nested values. Fix TOML branch to use `v | .value` instead
of `toml::toml_parse(v)`, which was passing the raw node string
(including +++ delimiters) and failing to parse.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gify

- Add to_frontmatter() as the canonical replacement for to_front_matter()
- Deprecate to_front_matter() with a comment
- Sort dict keys in yaml_stringify/_yaml_stringify_value to produce
  deterministic output, fixing a flaky test caused by Ident BTreeMap
  ordering depending on string interning order at runtime
- Update to_front_matter test expected value to match sorted key order
- Add test_to_frontmatter() to module_tests.mq
Align YAML branch with TOML branch by using `v | .value | yaml::yaml_parse`
instead of `yaml::yaml_parse(v)`.
@harehare harehare merged commit 40144ca into main Jun 2, 2026
10 checks passed
@harehare harehare deleted the feat/builtin-frontmatter branch June 2, 2026 13:37
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