aboutsummaryrefslogtreecommitdiff
path: root/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-12-02 22:42:55 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-12-02 22:42:55 +0000
commit67508f986f310e83f2180fe08182fc4b8d0a5556 (patch)
treee5f4b5a0ce77f1c196e9460342c868a53a5e2505 /Text/Pandoc/Readers
parent6359c789a76a455ae54d9b13537caf31d043161f (diff)
downloadpandoc-67508f986f310e83f2180fe08182fc4b8d0a5556.tar.gz
Allow LaTeX-style code sections as well as bird-style in lhs markdown.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1504 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Text/Pandoc/Readers')
-rw-r--r--Text/Pandoc/Readers/Markdown.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Text/Pandoc/Readers/Markdown.hs b/Text/Pandoc/Readers/Markdown.hs
index a6fe145c7..436ca3bd8 100644
--- a/Text/Pandoc/Readers/Markdown.hs
+++ b/Text/Pandoc/Readers/Markdown.hs
@@ -398,6 +398,19 @@ codeBlockIndented = do
lhsCodeBlock :: GenParser Char ParserState Block
lhsCodeBlock = do
failUnlessLHS
+ contents <- lhsCodeBlockBird <|> lhsCodeBlockLaTeX
+ return $ CodeBlock ("",["haskell"],[]) contents
+
+lhsCodeBlockLaTeX :: GenParser Char ParserState String
+lhsCodeBlockLaTeX = try $ do
+ string "\\begin{code}"
+ manyTill spaceChar newline
+ contents <- many1Till anyChar (try $ string "\\end{code}")
+ blanklines
+ return $ stripTrailingNewlines contents
+
+lhsCodeBlockBird :: GenParser Char ParserState String
+lhsCodeBlockBird = try $ do
pos <- getPosition
when (sourceColumn pos /= 1) $ fail "Not in first column"
lns <- many1 birdTrackLine
@@ -406,7 +419,7 @@ lhsCodeBlock = do
then map (drop 1) lns
else lns
blanklines
- return $ CodeBlock ("",["haskell"],[]) $ intercalate "\n" lns'
+ return $ intercalate "\n" lns'
birdTrackLine :: GenParser Char st [Char]
birdTrackLine = do