Markdown writer: escape literal & that would trigger entity.

Closes #11490.
This commit is contained in:
John MacFarlane
2026-02-27 11:43:47 +01:00
parent 72b62843c1
commit fd8d755f8a
2 changed files with 16 additions and 0 deletions
@@ -89,6 +89,9 @@ escapeText opts = T.pack . go' . T.unpack
| isEnabled Ext_mark opts = '\\':'=':go ('=':cs)
go ('~':'~':cs)
| isEnabled Ext_strikeout opts = '\\':'~':go ('~':cs)
go ('&':cs)
| Right _ <- parse characterReference "" ('&':cs)
= '\\':'&': go cs
go (c:cs) =
case c of
'[' -> '\\':c:go cs
+13
View File
@@ -0,0 +1,13 @@
```
% pandoc -t markdown
&lt;&amp;lt;
^D
\<\&lt;
```
```
% pandoc -t markdown
&amp;#xa0;
^D
\&#xa0;
```