Repository navigation
Conversation
Options such as `linenums` or `hl_lines` set in the attr_list of a fenced block are parsed into bool/None/list values. Without `codehilite` they were written into the `<code>` tag as attributes and crashed serialization. Omit non-string values from the output, like `use_pygments` already is. Fixes Python-Markdown#1713. Co-authored-by: jeej1k <351634202+jeej1k@users.noreply.github.com>
Member
|
We should not assume that the attributes are not needed in the output when codehilite is disabled. See my comment on #1713 for the appropriate fix for this. |
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
Fixes #1713.
With
fenced_codeandattr_listenabled butcodehilitenot enabled, options such aslinenums,guess_lang,noclassesorhl_lineson a fenced block are parsed intoTrue/False/None/list values and then written into the<code>tag, which raisesTypeError: cannot serialize None.This PR omits non-string values from the emitted attributes, the same way
use_pygmentsis already omitted, since those options only apply tocodehilite. A test (four variants) and a changelog entry are included; the test fails without the fix.I chose "omit" over "write as strings" because these options have no meaning as HTML attributes. If you would prefer the string form, I'm happy to change it.
jeej3000 and jeej1k are both my accounts; jeej1k is credited as co-author as a backup in case one account is lost.
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:
Checklist