@@ -67,14 +67,6 @@ renderFragment opts = if writerWrapText opts
67stringToHtml :: String -> Html
67stringToHtml :: String -> Html
68stringToHtml = primHtml . escapeStringForXML
68stringToHtml = primHtml . escapeStringForXML
70−-- Note: href and src, unmodified, incorrectly escape high
71−-- characters in URIs using entities. So we use these replacements:
72−href' :: String -> HtmlAttr
73−href' = href . stringToURI
75−src' :: String -> HtmlAttr
76−src' = src . stringToURI
78-- | Convert Pandoc document to Html string.
70-- | Convert Pandoc document to Html string.
79writeHtmlString :: WriterOptions -> Pandoc -> String
71writeHtmlString :: WriterOptions -> Pandoc -> String
80writeHtmlString opts d =
72writeHtmlString opts d =
@@ -120,13 +112,13 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
120 then case writerHTMLMathMethod opts of
112 then case writerHTMLMathMethod opts of
121 LaTeXMathML (Just url) ->
113 LaTeXMathML (Just url) ->
122 script !
114 script !
123− [src' url, thetype "text/javascript"] $ noHtml
115+ [src url, thetype "text/javascript"] $ noHtml
124 MathML (Just url) ->
116 MathML (Just url) ->
125 script !
117 script !
126− [src' url, thetype "text/javascript"] $ noHtml
118+ [src url, thetype "text/javascript"] $ noHtml
127 JsMath (Just url) ->
119 JsMath (Just url) ->
129− [src' url, thetype "text/javascript"] $ noHtml
121+ [src url, thetype "text/javascript"] $ noHtml
130 _ -> case lookup "mathml-script" (writerVariables opts) of
122 _ -> case lookup "mathml-script" (writerVariables opts) of
131 Just s ->
123 Just s ->
132 script ! [thetype "text/javascript"] <<
124 script ! [thetype "text/javascript"] <<
@@ -196,7 +188,7 @@ elementToListItem opts (Sec _ num id' headerText subsecs) = do
196 let subList = if null subHeads
188 let subList = if null subHeads
197 then noHtml
189 then noHtml
198 else unordList subHeads
190 else unordList subHeads
199− return $ Just $ (anchor ! [href' ("#" ++ writerIdentifierPrefix opts ++ id')] $ txt) +++ subList
191+ return $ Just $ (anchor ! [href ("#" ++ writerIdentifierPrefix opts ++ id')] $ txt) +++ subList
201-- | Convert an Element to Html.
193-- | Convert an Element to Html.
202elementToHtml :: WriterOptions -> Element -> State WriterState Html
194elementToHtml :: WriterOptions -> Element -> State WriterState Html
@@ -230,7 +222,7 @@ parseMailto _ = Nothing
230-- | Obfuscate a "mailto:" link.
222-- | Obfuscate a "mailto:" link.
231obfuscateLink :: WriterOptions -> String -> String -> Html
223obfuscateLink :: WriterOptions -> String -> String -> Html
232obfuscateLink opts txt s | writerEmailObfuscation opts == NoObfuscation =
224obfuscateLink opts txt s | writerEmailObfuscation opts == NoObfuscation =
233− anchor ! [href' s] << txt
225+ anchor ! [href s] << txt
234obfuscateLink opts txt s =
226obfuscateLink opts txt s =
235 let meth = writerEmailObfuscation opts
227 let meth = writerEmailObfuscation opts
236 s' = map toLower s
228 s' = map toLower s
@@ -257,7 +249,7 @@ obfuscateLink opts txt s =
257 linkText ++ "+'<\\/'+'a'+'>');\n// -->\n")) +++
249 linkText ++ "+'<\\/'+'a'+'>');\n// -->\n")) +++
258 noscript (primHtml $ obfuscateString altText)
250 noscript (primHtml $ obfuscateString altText)
259 _ -> error $ "Unknown obfuscation method: " ++ show meth
251 _ -> error $ "Unknown obfuscation method: " ++ show meth
260− _ -> anchor ! [href' s] $ stringToHtml txt -- malformed email
252+ _ -> anchor ! [href s] $ stringToHtml txt -- malformed email
262-- | Obfuscate character as entity.
254-- | Obfuscate character as entity.
263obfuscateChar :: Char -> String
255obfuscateChar :: Char -> String
@@ -320,7 +312,7 @@ blockToHtml opts (Header level lst) = do
320 stringToHtml " " +++ contents
312 stringToHtml " " +++ contents
321 else contents
313 else contents
322 let contents'' = if writerTableOfContents opts
314 let contents'' = if writerTableOfContents opts
323− then anchor ! [href' $ "#" ++ writerIdentifierPrefix opts ++ "TOC"] $ contents'
315+ then anchor ! [href $ "#" ++ writerIdentifierPrefix opts ++ "TOC"] $ contents'
324 else contents'
316 else contents'
325 return $ case level of
317 return $ case level of
326 1 -> h1 contents''
318 1 -> h1 contents''
@@ -460,7 +452,7 @@ inlineToHtml opts inline =
460 then thespan ! [theclass "math"] $ primHtml str
452 then thespan ! [theclass "math"] $ primHtml str
461 else thediv ! [theclass "math"] $ primHtml str
453 else thediv ! [theclass "math"] $ primHtml str
462 MimeTeX url ->
454 MimeTeX url ->
463− return $ image ! [src' (url ++ "?" ++ str),
455+ return $ image ! [src (url ++ "?" ++ str),
464 alt str, title str]
456 alt str, title str]
465 GladTeX ->
457 GladTeX ->
466 return $ primHtml $ "<EQ>" ++ str ++ "</EQ>"
458 return $ primHtml $ "<EQ>" ++ str ++ "</EQ>"
@@ -492,13 +484,13 @@ inlineToHtml opts inline =
492 return $ obfuscateLink opts (show linkText) s
484 return $ obfuscateLink opts (show linkText) s
493 (Link txt (s,tit)) -> do
485 (Link txt (s,tit)) -> do
494 linkText <- inlineListToHtml opts txt
486 linkText <- inlineListToHtml opts txt
495− return $ anchor ! ([href' s] ++
487+ return $ anchor ! ([href s] ++
496 if null tit then [] else [title tit]) $
488 if null tit then [] else [title tit]) $
498 (Image txt (s,tit)) -> do
490 (Image txt (s,tit)) -> do
499 alternate <- inlineListToHtml opts txt
491 alternate <- inlineListToHtml opts txt
500 let alternate' = renderFragment opts alternate
492 let alternate' = renderFragment opts alternate
501− let attributes = [src' s] ++
493+ let attributes = [src s] ++
502 (if null tit
494 (if null tit
504 else [title tit]) ++
496 else [title tit]) ++
@@ -516,7 +508,7 @@ inlineToHtml opts inline =
516 -- push contents onto front of notes
508 -- push contents onto front of notes
517 put $ st {stNotes = (htmlContents:notes)}
509 put $ st {stNotes = (htmlContents:notes)}
518 return $ sup <<
510 return $ sup <<
519− anchor ! [href' ("#" ++ writerIdentifierPrefix opts ++ "fn" ++ ref),
511+ anchor ! [href ("#" ++ writerIdentifierPrefix opts ++ "fn" ++ ref),
520 theclass "footnoteRef",
512 theclass "footnoteRef",
521 prefixedId opts ("fnref" ++ ref)] << ref
513 prefixedId opts ("fnref" ++ ref)] << ref
522 (Cite _ il) -> inlineListToHtml opts il
514 (Cite _ il) -> inlineListToHtml opts il
@@ -525,7 +517,7 @@ blockListToNote :: WriterOptions -> String -> [Block] -> State WriterState Html
525blockListToNote opts ref blocks =
517blockListToNote opts ref blocks =
526 -- If last block is Para or Plain, include the backlink at the end of
518 -- If last block is Para or Plain, include the backlink at the end of
527 -- that block. Otherwise, insert a new Plain block with the backlink.
519 -- that block. Otherwise, insert a new Plain block with the backlink.
528− let backlink = [HtmlInline $ " <a href=\"#" ++ stringToURI (writerIdentifierPrefix opts ++ "fnref" ++ ref) ++
520+ let backlink = [HtmlInline $ " <a href=\"#" ++ writerIdentifierPrefix opts ++ "fnref" ++ ref ++
529 "\" class=\"footnoteBackLink\"" ++
521 "\" class=\"footnoteBackLink\"" ++
530 " title=\"Jump back to footnote " ++ ref ++ "\">↩</a>"]
522 " title=\"Jump back to footnote " ++ ref ++ "\">↩</a>"]
531 blocks' = if null blocks
523 blocks' = if null blocks