Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,11 @@ def renderInlineAsText(self, tokens: list[SyntaxTreeNode]) -> str: # noqa: N802
result = ""

for token in tokens or []:
if token.type == "text":
if token.type in {"text", "text_special"}:
# An escape or entity is a text_special token with no children.
# Its content is the character the alt text must keep
# (executablebooks/MyST-Parser#1210).
result += token.content
# elif token.type == "image":
# result += self.renderInlineAsText(token.children)
else:
result += self.renderInlineAsText(token.children or [])
return result
Expand Down
38 changes: 38 additions & 0 deletions tests/test_renderers/fixtures/docutil_syntax_elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,44 @@ Image with escapable html:
<image alt="alt" uri="http://www.google%3C%3E.com">
.

Image alt with escapes and entities:
.
![a \* b &amp; C:\Python26](x.png)
.
<document source="notset">
<paragraph>
<image alt="a * b & C:\Python26" uri="x.png">
.

Image alt with escapes and entities in emphasis:
.
![a *\* b &copy;*](x.png)
.
<document source="notset">
<paragraph>
<image alt="a * b ©" uri="x.png">
.

Image alt with an escape in a nested image:
.
![outer ![in\*ner](y.png)](x.png)
.
<document source="notset">
<paragraph>
<image alt="outer in*ner" uri="x.png">
.

Image alt with an escape, reference style:
.
![a \* b][r]

[r]: x.png
.
<document source="notset">
<paragraph>
<image alt="a * b" uri="x.png">
.

Block Quote:
.
> *foo*
Expand Down
Loading