aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-11-01 16:08:27 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-11-01 16:08:27 -0700
commitf379edc4ad372f96d4a5cc7cd38292f095dfdf35 (patch)
treeb22d39fb2b0278186002a325b6390e756577651f /src/Text
parent5350ce26b463ccb8edc7b0c7b1be72558e87992c (diff)
downloadpandoc-f379edc4ad372f96d4a5cc7cd38292f095dfdf35.tar.gz
HTML writer: use character entities references when possible for HTML5.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 46f754226..4d15c827c 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -75,7 +75,8 @@ import Text.Pandoc.Templates
import Text.Pandoc.Walk
import Text.Pandoc.Writers.Math
import Text.Pandoc.Writers.Shared
-import Text.Pandoc.XML (escapeStringForXML, fromEntities, toEntities)
+import Text.Pandoc.XML (escapeStringForXML, fromEntities,
+ toEntities, toHtml5Entities)
#if MIN_VERSION_blaze_markup(0,6,3)
#else
import Text.Blaze.Internal (preEscapedString, preEscapedText)
@@ -206,7 +207,12 @@ writeHtmlString' :: PandocMonad m
=> WriterState -> WriterOptions -> Pandoc -> m Text
writeHtmlString' st opts d = do
(body, context) <- evalStateT (pandocToHtml opts d) st
- (if writerPreferAscii opts then toEntities else id) <$>
+ (if writerPreferAscii opts
+ then
+ if stHtml5 st
+ then toHtml5Entities
+ else toEntities
+ else id) <$>
case writerTemplate opts of
Nothing -> return $ renderHtml' body
Just tpl -> do