Skip to content

Preserve escapes and entities in image alt text - #600

Open
Ychris12138 wants to merge 1 commit into
hukkin:masterfrom
Ychris12138:fix/image-alt-special-text
Open

Ychris12138 wants to merge 1 commit into
hukkin:masterfrom
Ychris12138:fix/image-alt-special-text

Conversation

@Ychris12138

Copy link
Copy Markdown

Fixes #599.

Image alt text currently drops text_special children, so formatting ![C:\Python26](/u) loses the backslash and P, and entities/escaped punctuation disappear. Render those tokens using their original markup. Keeping the escape/entity spelling also prevents literal closing brackets, backticks, and angle brackets from becoming Markdown syntax.

Adds 14 regressions covering escapes, named/numeric entities, literal delimiters, wrapping, and idempotence. All fail before the fix and pass afterward. This remains useful with older markdown-it-py releases supported by mdformat, independently of the upstream parser fix in executablebooks/markdown-it-py#446.

Validation on Python 3.12: full pytest suite 4296 passed, 5 skipped; Black, isort, mypy for changed Python files, git diff --check, and mdformat --check README.md passed. No network or model API is needed for these tests.

AI-assisted implementation; all reported verification was executed locally.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 03:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Backslash escapes and entities are deleted from image alt text

2 participants