git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: use character entities references when possible for HTML5.
commitf379edc4ad372f96d4a5cc7cd38292f095dfdf35 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 1 Nov 2018, 16:08 (8 years ago) parent5350ce2
3 files changed+10−4
MANUAL.txt+1−1 src/Text/Pandoc/Writers/HTML.hs+8−2 test/command/ascii.md+1−1
MANUAL.txt+1−1
@@ -859,7 +859,7 @@ Options affecting specific writers {.options}
859859`--ascii`
860860
861861: Use only ASCII characters in output. Currently supported for
862− XML and HTML formats (which use numerical entities instead of
862+ XML and HTML formats (which use entities instead of
863863 UTF-8 when this option is selected), groff ms
864864 (which use hexadecimal escapes), and to a limited degree
865865 LaTeX (which uses standard commands for accented
src/Text/Pandoc/Writers/HTML.hs+8−2
@@ -75,7 +75,8 @@ import Text.Pandoc.Templates
7575import Text.Pandoc.Walk
7676import Text.Pandoc.Writers.Math
7777import Text.Pandoc.Writers.Shared
78−import Text.Pandoc.XML (escapeStringForXML, fromEntities, toEntities)
78+import Text.Pandoc.XML (escapeStringForXML, fromEntities,
79+ toEntities, toHtml5Entities)
7980#if MIN_VERSION_blaze_markup(0,6,3)
8081#else
8182import Text.Blaze.Internal (preEscapedString, preEscapedText)
@@ -206,7 +207,12 @@ writeHtmlString' :: PandocMonad m
206207 => WriterState -> WriterOptions -> Pandoc -> m Text
207208writeHtmlString' st opts d = do
208209 (body, context) <- evalStateT (pandocToHtml opts d) st
209− (if writerPreferAscii opts then toEntities else id) <$>
210+ (if writerPreferAscii opts
211+ then
212+ if stHtml5 st
213+ then toHtml5Entities
214+ else toEntities
215+ else id) <$>
210216 case writerTemplate opts of
211217 Nothing -> return $ renderHtml' body
212218 Just tpl -> do
test/command/ascii.md+1−1
@@ -2,7 +2,7 @@
22pandoc -t html --ascii
33äéıå
44^D
5−<p>&#228;&#233;&#305;&#229;</p>
5+<p>&auml;&eacute;&inodot;&aring;</p>
66```
77
88```