git.iko.soy/typeable/pandoc
on master help sign in
Added lhs support to RST writer.
c84c3b0fiddlosopher
Text/Pandoc/Writers/RST.hs+8−4
@@ -36,6 +36,7 @@ import Text.Pandoc.Blocks
36import Data.List ( isPrefixOf, isSuffixOf, drop, intersperse )
36import Data.List ( isPrefixOf, isSuffixOf, drop, intersperse )
37import Text.PrettyPrint.HughesPJ hiding ( Str )
37import Text.PrettyPrint.HughesPJ hiding ( Str )
38import Control.Monad.State
38import Control.Monad.State
39+import Control.Applicative ( (<$>) )
39
40
40data WriterState =
41data WriterState =
41 WriterState { stNotes :: [[Block]]
42 WriterState { stNotes :: [[Block]]
@@ -176,10 +177,13 @@ blockToRST (Header level inlines) = do
176 let headerChar = if level > 5 then ' ' else "=-~^'" !! (level - 1)
177 let headerChar = if level > 5 then ' ' else "=-~^'" !! (level - 1)
177 let border = text $ replicate headerLength headerChar
178 let border = text $ replicate headerLength headerChar
178 return $ contents $+$ border <> text "\n"
179 return $ contents $+$ border <> text "\n"
179−blockToRST (CodeBlock _ str) = do
180+blockToRST (CodeBlock (_,classes,_) str) = do
181+ opts <- stOptions <$> get
180− tabstop <- get >>= (return . writerTabStop . stOptions)
182+ let tabstop = writerTabStop opts
183+ if "haskell" `elem` classes && writerLiterateHaskell opts
184+ then return $ (vcat $ map (text "> " <>) $ map text (lines str)) <> text "\n"
181− return $ (text "::\n") $+$
185+ else return $ (text "::\n") $+$
182− (nest tabstop $ vcat $ map text (lines str)) <> text "\n"
186+ (nest tabstop $ vcat $ map text (lines str)) <> text "\n"
183blockToRST (BlockQuote blocks) = do
187blockToRST (BlockQuote blocks) = do
184 tabstop <- get >>= (return . writerTabStop . stOptions)
188 tabstop <- get >>= (return . writerTabStop . stOptions)
185 contents <- blockListToRST blocks
189 contents <- blockListToRST blocks