Skip to content

FIX: Keep escapes and entities in image alt text - #1211

Open
Cherith1222 wants to merge 1 commit into
executablebooks:masterfrom
Cherith1222:fix/1210-image-alt-escapes
Open

Cherith1222 wants to merge 1 commit into
executablebooks:masterfrom
Cherith1222:fix/1210-image-alt-escapes

Conversation

@Cherith1222

Copy link
Copy Markdown

Fixes #1210.

Image alt text dropped text_special tokens, so a backslash escape or an HTML entity disappeared from the alt attribute. Those tokens are now kept.

Tests, on Windows with Python 3.13.3, via Resource Sentinel (1 CPU, 1.5 GiB, 1 I/O):

  • With myst_parser/mdit_to_docutils/base.py checked out at master, test_image_alt_keeps_escapes_and_entities failed. The expected alt was a * b and the rendered alt was a b.
  • On this commit the same test passed (1 passed).
  • ruff 0.15.20 check passed on myst_parser/mdit_to_docutils/base.py and tests/test_image_alt.py. That is the version in the project dependency group. ruff format --check also passed on those files.

Not run: the full suite, and anything other than Windows.

This patch was drafted with AI assistance (Cursor).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant