Repository navigation
Conversation
text_join only converted the text_special tokens that are direct children of an inline token. An image keeps its alt text as its own child token list, so escapes and entities there were never turned into text and the alt renderer dropped them:  gave alt="a b". Join the children of each child token too, as markdown-it 15.0.0 does. Fixes executablebooks#445
This branch has not been deployed
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 #445
Image
alttext dropped backslash escapes and entities.renderedalt="a b"andrenderedalt="C:ython26". Link text with the same content was fine.The cause is in
text_join. It turnstext_specialtokens intotextand merges adjacent text, but only for the direct children of eachinlinetoken. An image holds its alt text as its own child token list, so thetext_specialtokens in there were left alone, andrenderInlineAsText(which only emitstext, nested images, line breaks and raw HTML) skipped them.markdown-it fixed the same thing in 15.0.0 (markdown-it/markdown-it@974e2d7) by also joining the children of each child token. This ports that. The existing join loop moves into a
_join_text_tokenshelper that runs over the inline children and over each child's own children. Same one-level scope as upstream.Tests
Added a case to
tests/test_port/fixtures/issue-fixes.mdwith the four inputs from the upstream test plus.pytest tests/test_port/test_fixtures.py -k issue_fixes: the new case fails without the change and passes with it.pytest tests/(with thetestingandlinkifyextras): 1033 passed.pluginstox env: 511 passed, same as on master.pre-commit runon the changed files (ruff, ruff format, mypy): passed.Added a changelog entry under Unreleased.