diff options
Diffstat (limited to 'Text/Pandoc/Writers')
-rw-r--r-- | Text/Pandoc/Writers/HTML.hs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs index d0c45bec1..d31ebfb85 100644 --- a/Text/Pandoc/Writers/HTML.hs +++ b/Text/Pandoc/Writers/HTML.hs @@ -39,7 +39,7 @@ import Data.Char ( ord, toLower, isAlpha ) import Data.List ( isPrefixOf, intersperse ) import qualified Data.Set as S import Control.Monad.State -import Text.XHtml.Transitional +import Text.XHtml.Transitional hiding ( stringToHtml ) data WriterState = WriterState { stNotes :: [Html] -- ^ List of notes @@ -62,6 +62,20 @@ renderFragment opts = if writerWrapText opts then renderHtmlFragment else showHtmlFragment +-- | Slightly modified version of Text.XHtml's stringToHtml. +-- Only uses numerical entities for 0xff and greater. +-- Adds . +stringToHtml :: String -> Html +stringToHtml = primHtml . concatMap fixChar + where + fixChar '<' = "<" + fixChar '>' = ">" + fixChar '&' = "&" + fixChar '"' = """ + fixChar '\160' = " " + fixChar c | ord c < 0xff = [c] + fixChar c = "&#" ++ show (ord c) ++ ";" + -- | Convert Pandoc document to Html string. writeHtmlString :: WriterOptions -> Pandoc -> String writeHtmlString opts = |