git.iko.soy/typeable/pandoc
on master help sign in
Whitespace cleanup.
commit8ddf7f5dc783dd8541d3ea3cd72dde838ede1b82 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 16 Apr 2011, 10:37 (16 years ago) parent220bd12
1 file changed+44−45
src/Text/Pandoc/Writers/HTML.hs+44−45
src/Text/Pandoc/Writers/HTML.hs+44−45
@@ -18,9 +18,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818-}
1919
2020{- |
21− Module : Text.Pandoc.Writers.HTML
21+ Module : Text.Pandoc.Writers.HTML
2222 Copyright : Copyright (C) 2006-2010 John MacFarlane
23− License : GNU GPL, version 2 or above
23+ License : GNU GPL, version 2 or above
2424
2525 Maintainer : John MacFarlane <jgm@berkeley.edu>
2626 Stability : alpha
@@ -101,10 +101,10 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
101101 else return noHtml
102102 auths <- if standalone
103103 then mapM (inlineListToHtml opts) authors'
104− else return []
104+ else return []
105105 date <- if standalone
106106 then inlineListToHtml opts date'
107− else return noHtml
107+ else return noHtml
108108 let startSlide = RawBlock "html" "<div class=\"slide\">\n"
109109 endSlide = RawBlock "html" "</div>\n"
110110 let cutUp (HorizontalRule : Header 1 ys : xs) = cutUp (Header 1 ys : xs)
@@ -112,7 +112,7 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
112112 cutUp (Header 1 ys : xs) = [endSlide, startSlide] ++
113113 (Header 1 ys : cutUp xs)
114114 cutUp (x:xs) = x : cutUp xs
115− cutUp [] = []
115+ cutUp [] = []
116116 let slides = case blocks of
117117 (HorizontalRule : xs) -> [startSlide] ++ cutUp xs ++ [endSlide]
118118 (Header 1 ys : xs) -> [startSlide, Header 1 ys] ++
@@ -133,10 +133,10 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
133133 let math = if stMath st
134134 then case writerHTMLMathMethod opts of
135135 LaTeXMathML (Just url) ->
136− script !
136+ script !
137137 [src url, thetype "text/javascript"] $ noHtml
138138 MathML (Just url) ->
139− script !
139+ script !
140140 [src url, thetype "text/javascript"] $ noHtml
141141 MathJax url ->
142142 script ! [src url, thetype "text/javascript"] $ noHtml
@@ -144,7 +144,7 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
144144 script !
145145 [src url, thetype "text/javascript"] $ noHtml
146146 _ -> case lookup "mathml-script" (writerVariables opts) of
147− Just s ->
147+ Just s ->
148148 script ! [thetype "text/javascript"] <<
149149 primHtml s
150150 Nothing -> noHtml
@@ -233,7 +233,7 @@ elementToListItem opts (Sec _ num id' headerText subsecs) = do
233233
234234-- | Convert an Element to Html.
235235elementToHtml :: WriterOptions -> Element -> State WriterState Html
236−elementToHtml opts (Blk block) = blockToHtml opts block
236+elementToHtml opts (Blk block) = blockToHtml opts block
237237elementToHtml opts (Sec level num id' title' elements) = do
238238 modify $ \st -> st{stSecNum = num} -- update section number
239239 header' <- blockToHtml opts (Header level title')
@@ -259,7 +259,7 @@ elementToHtml opts (Sec level num id' title' elements) = do
259259-- Assumes notes are sorted.
260260footnoteSection :: WriterOptions -> [Html] -> Html
261261footnoteSection opts notes =
262− if null notes
262+ if null notes
263263 then noHtml
264264 else nl opts +++ (thediv ! [theclass "footnotes"]
265265 $ nl opts +++ hr +++ nl opts +++
@@ -272,7 +272,7 @@ parseMailto ('m':'a':'i':'l':'t':'o':':':addr) =
272272 let (name', rest) = span (/='@') addr
273273 domain = drop 1 rest
274274 in Just (name', domain)
275−parseMailto _ = Nothing
275+parseMailto _ = Nothing
276276
277277-- | Obfuscate a "mailto:" link.
278278obfuscateLink :: WriterOptions -> String -> String -> Html
@@ -280,15 +280,15 @@ obfuscateLink opts txt s | writerEmailObfuscation opts == NoObfuscation =
280280 anchor ! [href s] << txt
281281obfuscateLink opts txt s =
282282 let meth = writerEmailObfuscation opts
283− s' = map toLower s
283+ s' = map toLower s
284284 in case parseMailto s' of
285285 (Just (name', domain)) ->
286286 let domain' = substitute "." " dot " domain
287287 at' = obfuscateChar '@'
288− (linkText, altText) =
288+ (linkText, altText) =
289289 if txt == drop 7 s' -- autolink
290290 then ("'<code>'+e+'</code>'", name' ++ " at " ++ domain')
291− else ("'" ++ txt ++ "'", txt ++ " (" ++ name' ++ " at " ++
291+ else ("'" ++ txt ++ "'", txt ++ " (" ++ name' ++ " at " ++
292292 domain' ++ ")")
293293 in case meth of
294294 ReferenceObfuscation ->
@@ -297,18 +297,18 @@ obfuscateLink opts txt s =
297297 ++ "\">" ++ (obfuscateString txt) ++ "</a>"
298298 JavascriptObfuscation ->
299299 (script ! [thetype "text/javascript"] $
300− primHtml ("\n<!--\nh='" ++
301− obfuscateString domain ++ "';a='" ++ at' ++ "';n='" ++
300+ primHtml ("\n<!--\nh='" ++
301+ obfuscateString domain ++ "';a='" ++ at' ++ "';n='" ++
302302 obfuscateString name' ++ "';e=n+a+h;\n" ++
303− "document.write('<a h'+'ref'+'=\"ma'+'ilto'+':'+e+'\">'+" ++
304− linkText ++ "+'<\\/'+'a'+'>');\n// -->\n")) +++
303+ "document.write('<a h'+'ref'+'=\"ma'+'ilto'+':'+e+'\">'+" ++
304+ linkText ++ "+'<\\/'+'a'+'>');\n// -->\n")) +++
305305 noscript (primHtml $ obfuscateString altText)
306306 _ -> error $ "Unknown obfuscation method: " ++ show meth
307307 _ -> anchor ! [href s] $ stringToHtml opts txt -- malformed email
308308
309309-- | Obfuscate character as entity.
310310obfuscateChar :: Char -> String
311−obfuscateChar char =
311+obfuscateChar char =
312312 let num = ord char
313313 numstr = if even num then show num else "x" ++ showHex num ""
314314 in "&#" ++ numstr ++ ";"
@@ -361,14 +361,14 @@ blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
361361 return h
362362blockToHtml opts (BlockQuote blocks) =
363363 -- in S5, treat list in blockquote specially
364− -- if default is incremental, make it nonincremental;
364+ -- if default is incremental, make it nonincremental;
365365 -- otherwise incremental
366366 if writerSlideVariant opts /= NoSlides
367367 then let inc = not (writerIncremental opts) in
368− case blocks of
368+ case blocks of
369369 [BulletList lst] -> blockToHtml (opts {writerIncremental = inc})
370370 (BulletList lst)
371− [OrderedList attribs lst] ->
371+ [OrderedList attribs lst] ->
372372 blockToHtml (opts {writerIncremental = inc})
373373 (OrderedList attribs lst)
374374 _ -> do contents <- blockListToHtml opts blocks
@@ -377,7 +377,7 @@ blockToHtml opts (BlockQuote blocks) =
377377 else do
378378 contents <- blockListToHtml opts blocks
379379 return $ blockquote (nl opts +++ contents +++ nl opts)
380−blockToHtml opts (Header level lst) = do
380+blockToHtml opts (Header level lst) = do
381381 contents <- inlineListToHtml opts lst
382382 secnum <- liftM stSecNum get
383383 let contents' = if writerNumberSections opts
@@ -470,8 +470,8 @@ tableRowToHtml opts aligns rownum cols' = do
470470 0 -> "header"
471471 x | x `rem` 2 == 1 -> "odd"
472472 _ -> "even"
473− cols'' <- sequence $ zipWith
474− (\alignment item -> tableItemToHtml opts mkcell alignment item)
473+ cols'' <- sequence $ zipWith
474+ (\alignment item -> tableItemToHtml opts mkcell alignment item)
475475 aligns cols'
476476 return $ (tr ! [theclass rowclass] $ nl opts +++ toHtmlFromList cols'')
477477 +++ nl opts
@@ -508,13 +508,13 @@ blockListToHtml opts lst =
508508
509509-- | Convert list of Pandoc inline elements to HTML.
510510inlineListToHtml :: WriterOptions -> [Inline] -> State WriterState Html
511−inlineListToHtml opts lst =
511+inlineListToHtml opts lst =
512512 mapM (inlineToHtml opts) lst >>= return . toHtmlFromList
513513
514514-- | Convert Pandoc inline element to HTML.
515515inlineToHtml :: WriterOptions -> Inline -> State WriterState Html
516516inlineToHtml opts inline =
517− case inline of
517+ case inline of
518518 (Str str) -> return $ stringToHtml opts str
519519 (Space) -> return $ stringToHtml opts " "
520520 (LineBreak) -> return br
@@ -543,9 +543,9 @@ inlineToHtml opts inline =
543543 stringToHtml opts "”")
544544 in do contents <- inlineListToHtml opts lst
545545 return $ leftQuote +++ contents +++ rightQuote
546− (Math t str) -> modify (\st -> st {stMath = True}) >>
546+ (Math t str) -> modify (\st -> st {stMath = True}) >>
547547 (case writerHTMLMathMethod opts of
548− LaTeXMathML _ ->
548+ LaTeXMathML _ ->
549549 -- putting LaTeXMathML in container with class "LaTeX" prevents
550550 -- non-math elements on the page from being treated as math by
551551 -- the javascript
@@ -594,37 +594,37 @@ inlineToHtml opts inline =
594594 LaTeXMathML _ -> do modify (\st -> st {stMath = True})
595595 return $ primHtml str
596596 _ -> return noHtml
597− (RawInline "html" str) -> return $ primHtml str
597+ (RawInline "html" str) -> return $ primHtml str
598598 (RawInline _ _) -> return noHtml
599599 (Link [Code _ str] (s,_)) | "mailto:" `isPrefixOf` s ->
600600 return $ obfuscateLink opts str s
601601 (Link txt (s,_)) | "mailto:" `isPrefixOf` s -> do
602− linkText <- inlineListToHtml opts txt
602+ linkText <- inlineListToHtml opts txt
603603 return $ obfuscateLink opts (show linkText) s
604604 (Link txt (s,tit)) -> do
605605 linkText <- inlineListToHtml opts txt
606− return $ anchor ! ([href s] ++
607− if null tit then [] else [title tit]) $
606+ return $ anchor ! ([href s] ++
607+ if null tit then [] else [title tit]) $
608608 linkText
609609 (Image txt (s,tit)) -> do
610610 let alternate' = stringify txt
611611 let attributes = [src s] ++
612− (if null tit
613− then []
614− else [title tit]) ++
615− if null txt
616− then []
612+ (if null tit
613+ then []
614+ else [title tit]) ++
615+ if null txt
616+ then []
617617 else [alt alternate']
618− return $ image ! attributes
619− -- note: null title included, as in Markdown.pl
620− (Note contents) -> do
618+ return $ image ! attributes
619+ -- note: null title included, as in Markdown.pl
620+ (Note contents) -> do
621621 st <- get
622622 let notes = stNotes st
623623 let number = (length notes) + 1
624624 let ref = show number
625− htmlContents <- blockListToNote opts ref contents
625+ htmlContents <- blockListToNote opts ref contents
626626 -- push contents onto front of notes
627− put $ st {stNotes = (htmlContents:notes)}
627+ put $ st {stNotes = (htmlContents:notes)}
628628 return $ sup <<
629629 anchor ! [href ("#" ++ writerIdentifierPrefix opts ++ "fn" ++ ref),
630630 theclass "footnoteRef",
@@ -635,7 +635,7 @@ blockListToNote :: WriterOptions -> String -> [Block] -> State WriterState Html
635635blockListToNote opts ref blocks =
636636 -- If last block is Para or Plain, include the backlink at the end of
637637 -- that block. Otherwise, insert a new Plain block with the backlink.
638− let backlink = [RawInline "html" $ " <a href=\"#" ++ writerIdentifierPrefix opts ++ "fnref" ++ ref ++
638+ let backlink = [RawInline "html" $ " <a href=\"#" ++ writerIdentifierPrefix opts ++ "fnref" ++ ref ++
639639 "\" class=\"footnoteBackLink\"" ++
640640 " title=\"Jump back to footnote " ++ ref ++ "\">" ++
641641 (if writerAscii opts then "&#8617;" else "↩") ++ "</a>"]
@@ -652,4 +652,3 @@ blockListToNote opts ref blocks =
652652 Plain backlink]
653653 in do contents <- blockListToHtml opts blocks'
654654 return $ nl opts +++ (li ! [prefixedId opts ("fn" ++ ref)]) contents
655−