From d79242796b5bfa24788d30b239de3b15c0ed326c Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Mon, 2 Sep 2019 20:36:57 -0700
Subject: [PATCH] HTML writer: use numeric character references with `--ascii`.

Previously we used named character references with html5 output.
But these aren't valid XML, and we aim to produce html5 that is
also valid XHTML (polyglot markup).  (This is also needed for
epub3.)

Closes #5718.
---
 src/Text/Pandoc/Writers/HTML.hs | 8 ++------
 test/command/ascii.md           | 2 +-
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index af0780e99..38b0e1974 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -59,8 +59,7 @@ import Text.DocTemplates (Context(..))
 import Text.Pandoc.Walk
 import Text.Pandoc.Writers.Math
 import Text.Pandoc.Writers.Shared
-import Text.Pandoc.XML (escapeStringForXML, fromEntities,
-                        toEntities, toHtml5Entities)
+import Text.Pandoc.XML (escapeStringForXML, fromEntities, toEntities)
 #if MIN_VERSION_blaze_markup(0,6,3)
 #else
 import Text.Blaze.Internal (preEscapedString, preEscapedText)
@@ -207,10 +206,7 @@ writeHtmlString' :: PandocMonad m
 writeHtmlString' st opts d = do
   (body, context) <- evalStateT (pandocToHtml opts d) st
   (if writerPreferAscii opts
-      then
-        if stHtml5 st
-           then toHtml5Entities
-           else toEntities
+      then toEntities
       else id) <$>
     case writerTemplate opts of
        Nothing -> return $ renderHtml' body
diff --git a/test/command/ascii.md b/test/command/ascii.md
index 492bf248f..214e10f13 100644
--- a/test/command/ascii.md
+++ b/test/command/ascii.md
@@ -2,7 +2,7 @@
 pandoc -t html --ascii
 äéıå
 ^D
-<p>&auml;&eacute;&imath;&aring;</p>
+<p>&#228;&#233;&#305;&#229;</p>
 ```
 
 ```