Repository navigation
Conversation
|
As per our Contributing Guide:
You appear to have deleted the PR Template. This will be your only warning. |
|
Sorry about that — the description now follows the PR template, and the disclosure section is filled in with the tool used and what it generated. |
|
@waylan another look please ty |
…own#1501) Remove the three legacy fixture cases whose expected output changed from tests/extensions/attr_list.txt and attr_list.html and cover them in tests/test_syntax/extensions/test_attr_list.py instead. Add a changelog entry and reword two comments so the spelling check passes.
|
@waylan fixed — moved the three changed legacy cases (random attributes, Bad Syntax header, key without value) out of tests/extensions/attr_list.txt/.html into new-style tests in tests/test_syntax/extensions/test_attr_list.py, and added the changelog entry. Also fixed the spelling check, it was flagging the word config in two comments I added. Tests pass locally (1154 OK) and the spelling check passes too. |
|
@waylan thanks for the review and for merging this, appreciate it |
Description
Fixes #1501.
Currently a valueless attribute in an attribute list is stored as
key="key", which makes the same source render differently — with different meaning — depending on the output format:download="download"gives the downloaded file a default name ofdownload; baredownloaddoes not. The reverse problem also existed: an explicit{download="download"}was collapsed to baredownloadunderhtml.This implements the approach sketched by @waylan in #1501 (comment):
markdown/serializers.py: BOOLEAN_ATTRIBUTES), differing per output format — the XHTML list is the one from the XHTML 1.0 spec, the HTML list is from the HTML spec — anddownloadis on neither list.markdown/extensions/attr_list.py), a valueless attribute is represented internally askey=None. When the attribute is assigned to an element, the historickey="key"behaviour is maintained only for known boolean attributes of the active output format; any other valueless attribute keeps the valueNone, preserving what the user provided.markdown/serializers.py) renders aNonevalue as the bare attribute name in both formats, and renderskey="key"in the minimized form underhtmlonly for known boolean attributes — so explicit values are now preserved as provided for non-boolean attributes.UnescapeTreeprocessorskipsNoneattribute values, andfenced_code'shandle_attrs(which shares the parser) keeps its historic treatment of a valueless config word as a flag using the key as its own value.Result:
Backward compatibility: known boolean attributes render exactly as before in both formats. Three cases in the legacy
attr_listfixture had expectations which changed, each being an instance of the bug (a valueless non-boolean attribute such asfoonow renders as barefooinstead offoo="foo"); at the reviewer's request, those cases were moved out of the legacy fixture and into the new-style tests intests/test_syntax/extensions/test_attr_list.py.Tests: 17 new tests in
tests/test_syntax/extensions/test_attr_list.pycovering valueless non-boolean attributes in both formats, cross-format consistency, explicitdownload="download"preservation, known booleans (shared, XHTML-onlycompact, HTML-onlyopen), thekey=Noneparse representation, serializer-level rendering ofNonevalues, and the fenced-code config-word regression. Full suite (python -m unittest discover tests, the runner from tox.ini): 1154 tests OK (baseline 1137 OK, same 111 skips) — zero regressions. Note: this change was developed with AI assistance.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: Muse, Anthropic's coding assistant. It generated the code changes, the new tests, the commit message, and the description above. I ran the full test suite locally to verify the results (1154 tests OK, zero regressions against the 1137-test baseline).
Checklist