git.iko.soy/typeable/pandoc
on master help sign in
Added lhs support to RST writer.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1508 788f1e2b-df1e-0410-8736-df70ead52e1b

commitc84c3b0c36cb34085cbc17a5ddbc1ae52ab62087 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateTue 2 Dec 2008, 22:43 (18 years ago) parentcc17688
1 file changed+8−4
Text/Pandoc/Writers/RST.hs+8−4
Text/Pandoc/Writers/RST.hs+8−4
@@ -36,6 +36,7 @@ import Text.Pandoc.Blocks
3636import Data.List ( isPrefixOf, isSuffixOf, drop, intersperse )
3737import Text.PrettyPrint.HughesPJ hiding ( Str )
3838import Control.Monad.State
39+import Control.Applicative ( (<$>) )
3940
4041data WriterState =
4142 WriterState { stNotes :: [[Block]]
@@ -176,10 +177,13 @@ blockToRST (Header level inlines) = do
176177 let headerChar = if level > 5 then ' ' else "=-~^'" !! (level - 1)
177178 let border = text $ replicate headerLength headerChar
178179 return $ contents $+$ border <> text "\n"
179−blockToRST (CodeBlock _ str) = do
180− tabstop <- get >>= (return . writerTabStop . stOptions)
181− return $ (text "::\n") $+$
182− (nest tabstop $ vcat $ map text (lines str)) <> text "\n"
180+blockToRST (CodeBlock (_,classes,_) str) = do
181+ opts <- stOptions <$> get
182+ let tabstop = writerTabStop opts
183+ if "haskell" `elem` classes && writerLiterateHaskell opts
184+ then return $ (vcat $ map (text "> " <>) $ map text (lines str)) <> text "\n"
185+ else return $ (text "::\n") $+$
186+ (nest tabstop $ vcat $ map text (lines str)) <> text "\n"
183187blockToRST (BlockQuote blocks) = do
184188 tabstop <- get >>= (return . writerTabStop . stOptions)
185189 contents <- blockListToRST blocks