@@ -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