Skip to content

✨ NEW: Support configurable front matter markers - #155

Open
Gonghan-Princess wants to merge 1 commit into
executablebooks:masterfrom
Gonghan-Princess:codex/feat-front-matter-markers
Open

Gonghan-Princess wants to merge 1 commit into
executablebooks:masterfrom
Gonghan-Princess:codex/feat-front-matter-markers

Conversation

@Gonghan-Princess

Copy link
Copy Markdown

Front matter delimiters are currently fixed to ---, preventing applications from using +++ for TOML-style metadata or ;;; for JSON-style metadata. Add a keyword-only marker option to front_matter_plugin, configured separately for each MarkdownIt parser.

For example, MarkdownIt().use(front_matter_plugin, marker="+") extracts content between +++ fences. The plugin continues to return raw metadata text; it does not decode TOML or JSON or add dependencies. The default - marker and existing YAML fixtures retain their behavior. Custom markers use the existing minimum-three and matching-closing-length rules; YAML's ... terminator is recognized only with the default marker.

Reject empty, multi-character, whitespace, and NUL markers when configuring the plugin. Update the API documentation with an example and add an Unreleased changelog entry.

Fixes #134.

Validation on Windows / Python 3.12.10:

  • Initial regression run: 23 feature cases failed on the original API; nine existing front matter tests passed. An additional test reproduced the NUL normalization edge before adding its validation.
  • Project tox -e py312: 535 passed (24 added cases).
  • Project tox -e mypy, tox -e pre-commit, and tox -e docs-update: passed, including strict Sphinx -nW --keep-going.
  • Executed the Python example extracted from the actual function docstring successfully.
  • Tests cover token content/markup/maps, hidden rendering, TOML/JSON delimiters, empty metadata, short/invalid/unclosed/mismatched fences, YAML terminator text inside custom metadata, and independent parser configurations.
  • Other Python versions and platforms remain for CI.

AI assistance: OpenAI Codex prepared the implementation, tests, documentation, and PR text. A separate Codex agent reviewed the patch; its NUL-marker finding was addressed and tested. No human review is claimed.

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.

Configurable marker characters for Markdown front matter

1 participant