git.iko.soy/typeable/pandoc
on master help sign in
Allow LaTeX-style code sections as well as bird-style in lhs markdown.
67508f9fiddlosopher
Text/Pandoc/Readers/Markdown.hs+14−1
@@ -398,6 +398,19 @@ codeBlockIndented = do
398lhsCodeBlock :: GenParser Char ParserState Block
398lhsCodeBlock :: GenParser Char ParserState Block
399lhsCodeBlock = do
399lhsCodeBlock = do
400 failUnlessLHS
400 failUnlessLHS
401+ contents <- lhsCodeBlockBird <|> lhsCodeBlockLaTeX
402+ return $ CodeBlock ("",["haskell"],[]) contents
403+
404+lhsCodeBlockLaTeX :: GenParser Char ParserState String
405+lhsCodeBlockLaTeX = try $ do
406+ string "\\begin{code}"
407+ manyTill spaceChar newline
408+ contents <- many1Till anyChar (try $ string "\\end{code}")
409+ blanklines
410+ return $ stripTrailingNewlines contents
411+
412+lhsCodeBlockBird :: GenParser Char ParserState String
413+lhsCodeBlockBird = try $ do
401 pos <- getPosition
414 pos <- getPosition
402 when (sourceColumn pos /= 1) $ fail "Not in first column"
415 when (sourceColumn pos /= 1) $ fail "Not in first column"
403 lns <- many1 birdTrackLine
416 lns <- many1 birdTrackLine
@@ -406,7 +419,7 @@ lhsCodeBlock = do
406 then map (drop 1) lns
419 then map (drop 1) lns
407 else lns
420 else lns
408 blanklines
421 blanklines
409− return $ CodeBlock ("",["haskell"],[]) $ intercalate "\n" lns'
422+ return $ intercalate "\n" lns'
410
423
411birdTrackLine :: GenParser Char st [Char]
424birdTrackLine :: GenParser Char st [Char]
412birdTrackLine = do
425birdTrackLine = do