feat!: parse YAML frontmatter natively (drop need for yaml-metadata)#74
Merged
Conversation
Previously the reader only understood a naive `key: value` header and could not parse `---`-delimited YAML frontmatter with list-form values (e.g. tags). Users worked around that by also installing pelican-yaml-metadata, but that plugin renders bodies with python-markdown -- whose fenced_code only recognises fences at column 0, so fenced code blocks nested in lists broke (the list restarted and the fence collapsed into an inline code span). The reader now detects a `---` YAML header, parses it with PyYAML, and maps it onto Pelican metadata (tags, category, author(s), date, slug, status, ...), rendering FORMATTED_FIELDS through markdown-it as well. Files without a YAML fence still use the legacy `key: value` parser, so existing content is unaffected. Sites no longer need pelican-yaml-metadata and get correct markdown-it rendering for the whole document, including fenced code inside lists. BREAKING CHANGE: the reader now parses `---` YAML frontmatter itself and depends on PyYAML. Sites that paired it with pelican-yaml-metadata should remove that plugin; metadata derived from YAML headers may differ. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update runtime and dev dependencies to current releases and widen the markdown-it-py / mdit-py-plugins bounds to allow the 4.x / 0.6.x line (markdown-it-py 4.2, mdit-py-plugins 0.6.1, Pygments 2.19, PyYAML 6, pelican 4.11+; black 26, flake8 7, isort 8, pytest 9, invoke 3). Raise the Python floor to >=3.11: 3.9 and 3.10 are EOL/near-EOL, pytest 9 requires >=3.10, and the primary consumer already targets 3.11+. Also migrate the deprecated [tool.poetry.dev-dependencies] table to [tool.poetry.group.dev.dependencies]. Tests and pre-commit (black/flake8/isort/pyupgrade) pass against the upgraded set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop 3.9/3.10 (now below the >=3.11 requirement and EOL/near-EOL) and add 3.14, which is stable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Add a top-level `permissions: contents: read` to the build workflow so test/lint/build run with a least-privilege token; the publish/release jobs keep their own elevated scopes. - Update all actions to their latest majors and pin them to full commit SHAs (with a version comment), including the privileged publish-context actions (pypa/gh-action-pypi-publish, sigstore). Dependabot will keep the pins current. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds native
---YAML frontmatter parsing to the reader, so Pelican sites no longer needpelican-yaml-metadataalongside it.Why
When both
pelican-markdown-it-readerandpelican-yaml-metadataare installed, whichever registers last wins the.mdextension.yaml-metadata(needed for---YAML headers with list-formtags) registered last and rendered bodies with python-markdown, whosefenced_codeonly recognizes fences at column 0 — so fenced code blocks nested inside lists broke (list numbering restarted;```bashcollapsed into an inline code span).Because this reader's frontmatter parser was a naive
split(":")loop (couldn't handle YAML lists),yaml-metadatawas the only workaround. Fixing the parser here removes the conflict at its source.Changes
feat!native YAML frontmatter parsing (PyYAML): mapstags/category/author(s)/date/slug/status/… onto Pelican metadata, rendersFORMATTED_FIELDSthrough markdown-it. Files without a---header fall back to the legacykey: valueparser, so existing content is unaffected.dev-dependenciestable.permissions; update all actions to latest majors and SHA-pin them (incl. privileged publish-context actions).yaml-metadataremoval.Breaking change
The reader now parses
---YAML frontmatter itself and depends on PyYAML. Sites that paired it withpelican-yaml-metadatashould remove that plugin; metadata derived from YAML headers may differ. Warrants a major (3.0.0) release.Testing
New tests cover YAML metadata (incl. list-form + scalar tags), the fenced-code-in-list regression, link placeholders, and the legacy fallback.
invoke tests+invoke lintpass locally against the upgraded set (markdown-it-py 4.2, pelican 4.12, pytest 9, black 26, flake8 7, isort 8).🤖 Generated with Claude Code