From 87c66d4623200a48eab6e550f73372aaf3608289 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Fri, 1 Jan 2010 04:11:48 +0000 Subject: Finished converting HTML writer to use unicode instead of entities. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1767 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Writers/HTML.hs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 9a093ad96..c80a3b32f 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -60,9 +60,8 @@ 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  . +-- | Modified version of Text.XHtml's stringToHtml. +-- Use unicode characters wherever possible. stringToHtml :: String -> Html stringToHtml = primHtml . concatMap fixChar where @@ -248,7 +247,7 @@ obfuscateLink opts txt s = linkText ++ "+'<\\/'+'a'+'>');\n// -->\n")) +++ noscript (primHtml $ obfuscateString altText) _ -> error $ "Unknown obfuscation method: " ++ show meth - _ -> anchor ! [href s] $ primHtml txt -- malformed email + _ -> anchor ! [href s] $ stringToHtml txt -- malformed email -- | Obfuscate character as entity. obfuscateChar :: Char -> String @@ -410,11 +409,11 @@ inlineToHtml opts inline = case inline of (Str str) -> return $ stringToHtml str (Space) -> return $ stringToHtml " " - (LineBreak) -> return $ br - (EmDash) -> return $ primHtmlChar "mdash" - (EnDash) -> return $ primHtmlChar "ndash" - (Ellipses) -> return $ primHtmlChar "hellip" - (Apostrophe) -> return $ primHtmlChar "rsquo" + (LineBreak) -> return br + (EmDash) -> return $ stringToHtml "—" + (EnDash) -> return $ stringToHtml "–" + (Ellipses) -> return $ stringToHtml "…" + (Apostrophe) -> return $ stringToHtml "’" (Emph lst) -> inlineListToHtml opts lst >>= return . emphasize (Strong lst) -> inlineListToHtml opts lst >>= return . strong (Code str) -> return $ thecode << str @@ -426,10 +425,10 @@ inlineToHtml opts inline = (Subscript lst) -> inlineListToHtml opts lst >>= return . sub (Quoted quoteType lst) -> let (leftQuote, rightQuote) = case quoteType of - SingleQuote -> (primHtmlChar "lsquo", - primHtmlChar "rsquo") - DoubleQuote -> (primHtmlChar "ldquo", - primHtmlChar "rdquo") + SingleQuote -> (stringToHtml "‘", + stringToHtml "’") + DoubleQuote -> (stringToHtml "“", + stringToHtml "”") in do contents <- inlineListToHtml opts lst return $ leftQuote +++ contents +++ rightQuote (Math t str) -> @@ -502,7 +501,7 @@ blockListToNote opts ref blocks = -- that block. Otherwise, insert a new Plain block with the backlink. let backlink = [HtmlInline $ " "] + " title=\"Jump back to footnote " ++ ref ++ "\">↩"] blocks' = if null blocks then [] else let lastBlock = last blocks -- cgit v1.2.3