git.iko.soy/typeable/pandoc
on master help sign in
XML: change toEntities to emit numerical hex character references.

Previously decimal references were used. But Polyglot Markup prefers hex. See #5718. This affects the output of pandoc with `--ascii`.

commit513058a24eebb97a849e7eb5051e29ce2f6642c6 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 3 Sep 2019, 11:28 (7 years ago) parent0fe635d
2 files changed+5−4
src/Text/Pandoc/XML.hs+2−1 test/command/ascii.md+3−3
src/Text/Pandoc/XML.hs+2−1
@@ -26,6 +26,7 @@ import Data.Text (Text)
2626import qualified Data.Text as T
2727import Text.HTML.TagSoup.Entity (lookupEntity, htmlEntities)
2828import Text.DocLayout
29+import Text.Printf (printf)
2930import qualified Data.Map as M
3031import Data.String
3132
@@ -89,7 +90,7 @@ inTagsIndented tagType = inTags True tagType []
8990toEntities :: Text -> Text
9091toEntities = T.concatMap go
9192 where go c | isAscii c = T.singleton c
92− | otherwise = T.pack ("&#" ++ show (ord c) ++ ";")
93+ | otherwise = T.pack (printf "&#x%X;" (ord c))
9394
9495-- | Escape all non-ascii characters using HTML5 entities, falling
9596-- back to numerical entities.
test/command/ascii.md+3−3
@@ -2,7 +2,7 @@
22pandoc -t html --ascii
33äéıå
44^D
5−<p>&#228;&#233;&#305;&#229;</p>
5+<p>&#xE4;&#xE9;&#x131;&#xE5;</p>
66```
77
88```
@@ -33,7 +33,7 @@ pandoc -t docbook --ascii
3333äéıå
3434^D
3535<para>
36− &#228;&#233;&#305;&#229;
36+ &#xE4;&#xE9;&#x131;&#xE5;
3737</para>
3838```
3939
@@ -41,7 +41,7 @@ pandoc -t docbook --ascii
4141pandoc -t jats --ascii
4242äéıå
4343^D
44−<p>&#228;&#233;&#305;&#229;</p>
44+<p>&#xE4;&#xE9;&#x131;&#xE5;</p>
4545```
4646
4747```