-
Notifications
You must be signed in to change notification settings - Fork 71
[markdown] Preserve metadata passed to fenced code blocks #2186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[markdown] Preserve metadata passed to fenced code blocks #2186
Conversation
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a valuable feature by preserving metadata from fenced code blocks, attaching it as a data-metadata
attribute to the pre
element. The implementation is well-executed, and the accompanying tests provide good coverage for the new functionality. I have one suggestion to refactor a small portion of the code to reduce duplication, which will enhance maintainability. Overall, this is a solid contribution.
PR HealthBreaking changes ✔️
This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with |
Pull Request Test Coverage Report for Build 18136699326Details
💛 - Coveralls |
To enable accessing any extra metadata passed to the fenced code block after the language, store it on the wrapping
pre
element with a data attribute.For example:
Roughly becomes the following HTML:
Many site generation tools (such as Starlight) support this section for customizing the rendered code block.
Currently we've forked this syntax to use on dart.dev, but I imagine this is a common enough pattern that'd others would benefit. If preferred, it could opt-in through the syntax's constructor, but that's not a common pattern yet in the package and CommonMark doesn't mandate any specific treatment of the string.