Skip to content

Fix boolean fenced code attributes without codehilite - #1718

Open
ARAYN7011 wants to merge 1 commit into
Python-Markdown:masterfrom
ARAYN7011:fix-fenced-code-bool-attrs-1713
Open

ARAYN7011 wants to merge 1 commit into
Python-Markdown:masterfrom
ARAYN7011:fix-fenced-code-bool-attrs-1713

Conversation

@ARAYN7011

Copy link
Copy Markdown

Description

Fixes #1713. When fenced_code and attr_list are enabled but codehilite is not, boolean options such as linenums=true were passed to _escape_attrib_html as bool objects, raising TypeError: cannot serialize True. Following the plan in the issue thread, values are now serialized as the serializer would: None -> key; True -> bare key for HTML boolean attributes with html output, otherwise key="key"; False -> omitted.

Test plan: added two tests in tests/test_syntax/extensions/test_fenced_code.py (fail before, pass after); full python -m unittest discover tests passes; flake8 clean on 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 use to assist with the following:

    • Code
    • Code Comments
    • Documentation
    • Changelog Entry
    • Commit Message
    • The Description Above
    • Other: tests (Claude Code)

Checklist

Boolean options (e.g. linenums) set via attr_list were passed to the
escape helper as bool objects, raising TypeError when codehilite is not
enabled. Serialize them the way the serializer does.

Fixes Python-Markdown#1713.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fenced_code + attr_list: boolean options like linenums crash with "cannot serialize" when codehilite is not enabled

1 participant