Repository navigation
FIX: Keep escapes and entities in image alt text - #1211
Merged
chrisjsewell merged 5 commits intoNov 9, 2026
Merged
Conversation
Image alt text dropped text_special tokens, so a backslash escape or an HTML entity disappeared from the alt attribute. AI-assisted (Cursor). Not yet reviewed by a human.
This was referenced Oct 17, 2026
Image rendering is pinned in `docutil_syntax_elements.md`, so the alt cases live there as doctree fixtures rather than as html5 writer strings. Adds an escape and entity inside emphasis, an escape in a nested image, and a reference-style image. All four fail without the fix.
Member
|
Merged in af515c1, thanks @Cherith1222! The fix was right as written: it handles escapes and entities at any nesting depth, including an image nested in an image, which markdown-it JS 15's |
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.
Fixes #1210.
Image alt text dropped
text_specialtokens, so a backslash escape or an HTML entity disappeared from thealtattribute. Those tokens are now kept.Tests, on Windows with Python 3.13.3, via Resource Sentinel (1 CPU, 1.5 GiB, 1 I/O):
myst_parser/mdit_to_docutils/base.pychecked out atmaster,test_image_alt_keeps_escapes_and_entitiesfailed. The expected alt wasa * band the rendered alt wasa b.ruff0.15.20checkpassed onmyst_parser/mdit_to_docutils/base.pyandtests/test_image_alt.py. That is the version in the project dependency group.ruff format --checkalso passed on those files.Not run: the full suite, and anything other than Windows.
This patch was drafted with AI assistance (Cursor).