Repository navigation
Conversation
`FencedBlockPreprocessor.run` merges every key/value pair from a fenced
block's attribute list into the `codehilite` settings, so a block could
set `pygments_formatter` and replace the formatter chosen in the
`codehilite` configuration. Pygments' `text` formatter writes the code
out as is, so `{ .text pygments_formatter='text' }` rendered the block's
content as markup instead of escaping it like any other code block.
Other formatters do not produce HTML at all.
The key is now dropped before the merge, in the Pygments branch only.
The fenced code docs only list `HtmlFormatter` and lexer options as
settable per block, and `CodeHilite` already forces the `full` option
off for a similar reason. The non-Pygments branch and the other
per-block options are unchanged.
Member
|
I'm not sure why we care about this. This seems like a situation of garbage in, garbage out. |
Contributor
Author
|
Fair point. The reason I thought it was worth it is that, as far as I can tell, |
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.
Description
FencedBlockPreprocessor.runpasses every key/value pair from a fenced block's attribute list on toCodeHilite, includingpygments_formatter, so one block can replace the formatter set in thecodehiliteconfiguration. With Pygments installed and justfenced_codeandcodehiliteenabled:Pygments'
textformatter writes the code out as is, so the content of that block is not escaped the way it is in every other code block. Other formatters don't give HTML at all (pygments_formatter='raw'renders ab"..."bytes repr). The fenced code docs listHtmlFormatterand lexer options as what a block can set, andpygments_formatteris neither.The key is now dropped from the attribute list's settings before they are merged with the
codehiliteconfiguration, which is similar toCodeHilitealways forcingfulloff. This only affects the Pygments branch. Without Pygments, the key is still written as a<code>attribute (withattr_list) as before, and other per-block options such aslinenums,css_classanduse_pygmentswork as before.The new test sits with the other per-block option tests. It fails on master with Pygments 2.7.1 and passes with this change. The full suite passes with Pygments 2.7.1 and without Pygments, and flake8 is clean.
AI Assistance Disclosure
No AI tools were used in preparing this PR.
AI tools were used and I have disclosed which ones, and have fully reviewed and verified their output.
AI tools were use to assist with the following:
Tool used: Claude Code (Claude Opus 5.5).
Checklist