Repository navigation
Fix TypeError for a valueless data-toc-label - #1715
Closed
lidongze1002 wants to merge 1 commit into
Closed
lidongze1002 wants to merge 1 commit into
lidongze1002 wants to merge 1 commit into
Conversation
The attr_list extension writes a bare attribute with a value of None, and toc
read data-toc-label without allowing for that, so a heading written as
"# Heading {: data-toc-label }" raised TypeError: expected string or
bytes-like object, got 'NoneType' from unescape. A valueless label is no label
at all: the heading text is used and the attribute is dropped, which is how a
valueless id has been handled since Python-Markdown#1705.
Closes Python-Markdown#1712.
Member
|
I am closing this as a duplicate of #1714. |
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
A heading with a bare
data-toc-labelattribute crashes thetocextension:attr_liststores a bare attribute asNone, andTocTreeprocessor.run()hands that value straight tounescape(). #1705 fixed exactly this for a valuelessid; this does the same fordata-toc-label: a valueless label is treated like a missing one, the heading text becomes the label, and the attribute is dropped so it no longer reaches the output HTML either.This is a regression: 3.11.2 rendered
<h1 id="hello">Hello</h1>, 3.11.3 and master raise.Test evidence
testValuelessLabelAttributeintests/test_syntax/extensions/test_toc.py, beside the toc + attr_list: bare {id} attribute crashes toc with TypeError (unescape(None)) #1705 test.TypeError; with it, it passes.python -m unittest discover tests→Ran 1222 tests ... OK (skipped=111).flake8clean on the changed files.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 used to assist with the following:
The tool was OpenCode running DeepSeek V4.1 Flash as the coding agent.
Checklist