HTML writer: use character entities references when possible for HTML5.
This commit is contained in:
parent
5350ce26b4
commit
f379edc4ad
3 changed files with 10 additions and 4 deletions
|
@ -859,7 +859,7 @@ Options affecting specific writers {.options}
|
||||||
`--ascii`
|
`--ascii`
|
||||||
|
|
||||||
: Use only ASCII characters in output. Currently supported for
|
: Use only ASCII characters in output. Currently supported for
|
||||||
XML and HTML formats (which use numerical entities instead of
|
XML and HTML formats (which use entities instead of
|
||||||
UTF-8 when this option is selected), groff ms
|
UTF-8 when this option is selected), groff ms
|
||||||
(which use hexadecimal escapes), and to a limited degree
|
(which use hexadecimal escapes), and to a limited degree
|
||||||
LaTeX (which uses standard commands for accented
|
LaTeX (which uses standard commands for accented
|
||||||
|
|
|
@ -75,7 +75,8 @@ import Text.Pandoc.Templates
|
||||||
import Text.Pandoc.Walk
|
import Text.Pandoc.Walk
|
||||||
import Text.Pandoc.Writers.Math
|
import Text.Pandoc.Writers.Math
|
||||||
import Text.Pandoc.Writers.Shared
|
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)
|
#if MIN_VERSION_blaze_markup(0,6,3)
|
||||||
#else
|
#else
|
||||||
import Text.Blaze.Internal (preEscapedString, preEscapedText)
|
import Text.Blaze.Internal (preEscapedString, preEscapedText)
|
||||||
|
@ -206,7 +207,12 @@ writeHtmlString' :: PandocMonad m
|
||||||
=> WriterState -> WriterOptions -> Pandoc -> m Text
|
=> WriterState -> WriterOptions -> Pandoc -> m Text
|
||||||
writeHtmlString' st opts d = do
|
writeHtmlString' st opts d = do
|
||||||
(body, context) <- evalStateT (pandocToHtml opts d) st
|
(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
|
case writerTemplate opts of
|
||||||
Nothing -> return $ renderHtml' body
|
Nothing -> return $ renderHtml' body
|
||||||
Just tpl -> do
|
Just tpl -> do
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pandoc -t html --ascii
|
pandoc -t html --ascii
|
||||||
äéıå
|
äéıå
|
||||||
^D
|
^D
|
||||||
<p>äéıå</p>
|
<p>äéıå</p>
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue