Skip to content

Support other frontmatter formats (TOML, JSON, custom delimiters) #1

Description

@redtux

Our SPDXMarkdown changelog format plugin currently only strips ----delimited YAML frontmatter before delegating to commitizen's built-in Markdown parser.

woile's comment on commitizen#2014 (the upstream issue that motivated this plugin) made this limitation clear:

Frontmatters come in different shapes, you are assuming --- and yaml, but those are not all the cases. We are not going to hardcode a solution that fits only your use case.

We fully agree — and that is exactly why this is a plugin rather than an upstream patch. But right now our implementation only handles one shape (--- YAML), leaving other common frontmatter formats unsupported:

  • TOML frontmatter: delimited by +++
  • JSON frontmatter: delimited by { } (though JSON is less common in practice)
  • Other custom delimiters: projects may use arbitrary markers

How to help

The core logic lives in _strip_frontmatter (standalone, no commitizen dependency). Adding support for a new format means:

  1. Extending _strip_frontmatter (or adding a sibling function) to handle the new delimiter
  2. Creating or extending config knobs so users can select which frontmatter format to strip
  3. Adding tests in tests/test_spdx_markdown.py
  4. Updating docs

The architecture is deliberately designed with only two override points in _SPDXMarkdownImplget_metadata and get_latest_full_release — so the integration surface is tiny.

See the design doc for the full class hierarchy and algorithm.

PRs welcome!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions