diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-12-02 22:43:33 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-12-02 22:43:33 +0000 |
commit | ebe9ac50b0560614e542ed8b11cc2c974f346c47 (patch) | |
tree | 7946553bcf59df1877742637cf27f9f9d60e721d /Text/Pandoc/Readers | |
parent | c84c3b0c36cb34085cbc17a5ddbc1ae52ab62087 (diff) | |
download | pandoc-ebe9ac50b0560614e542ed8b11cc2c974f346c47.tar.gz |
Added lhs support to RST reader.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1509 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Text/Pandoc/Readers')
-rw-r--r-- | Text/Pandoc/Readers/RST.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Text/Pandoc/Readers/RST.hs b/Text/Pandoc/Readers/RST.hs index 50075ae65..255054c10 100644 --- a/Text/Pandoc/Readers/RST.hs +++ b/Text/Pandoc/Readers/RST.hs @@ -33,6 +33,7 @@ module Text.Pandoc.Readers.RST ( import Text.Pandoc.Definition import Text.Pandoc.Shared import Text.ParserCombinators.Parsec +import Control.Monad ( when ) import Data.List ( findIndex, delete, intercalate ) -- | Parse reStructuredText string and return Pandoc document. @@ -126,6 +127,7 @@ block = choice [ codeBlock , hrule , list , lineBlock + , lhsCodeBlock , para , plain , nullBlock ] <?> "block" @@ -328,6 +330,24 @@ codeBlock = try $ do result <- indentedBlock return $ CodeBlock ("",[],[]) $ stripTrailingNewlines result +lhsCodeBlock :: GenParser Char ParserState Block +lhsCodeBlock = try $ do + failUnlessLHS + pos <- getPosition + when (sourceColumn pos /= 1) $ fail "Not in first column" + lns <- many1 birdTrackLine + -- if (as is normal) there is always a space after >, drop it + let lns' = if all (\ln -> null ln || take 1 ln == " ") lns + then map (drop 1) lns + else lns + blanklines + return $ CodeBlock ("", ["sourceCode", "haskell"], []) $ intercalate "\n" lns' + +birdTrackLine :: GenParser Char st [Char] +birdTrackLine = do + char '>' + manyTill anyChar newline + -- -- raw html -- |