@@ -33,6 +33,7 @@ module Text.Pandoc.Readers.RST (
33import Text.Pandoc.Definition
33import Text.Pandoc.Definition
34import Text.Pandoc.Shared
34import Text.Pandoc.Shared
35import Text.ParserCombinators.Parsec
35import Text.ParserCombinators.Parsec
36+import Control.Monad ( when )
36import Data.List ( findIndex, delete, intercalate )
37import Data.List ( findIndex, delete, intercalate )
38-- | Parse reStructuredText string and return Pandoc document.
39-- | Parse reStructuredText string and return Pandoc document.
@@ -126,6 +127,7 @@ block = choice [ codeBlock
128 , lineBlock
129 , lineBlock
131 , nullBlock ] <?> "block"
133 , nullBlock ] <?> "block"
@@ -328,6 +330,24 @@ codeBlock = try $ do
328 result <- indentedBlock
330 result <- indentedBlock
329 return $ CodeBlock ("",[],[]) $ stripTrailingNewlines result
331 return $ CodeBlock ("",[],[]) $ stripTrailingNewlines result
333+lhsCodeBlock :: GenParser Char ParserState Block
334+lhsCodeBlock = try $ do
337+ when (sourceColumn pos /= 1) $ fail "Not in first column"
338+ lns <- many1 birdTrackLine
339+ -- if (as is normal) there is always a space after >, drop it
340+ let lns' = if all (\ln -> null ln || take 1 ln == " ") lns
341+ then map (drop 1) lns
344+ return $ CodeBlock ("", ["sourceCode", "haskell"], []) $ intercalate "\n" lns'
346+birdTrackLine :: GenParser Char st [Char]
349+ manyTill anyChar newline
332-- raw html
352-- raw html