@@ -347,14 +347,25 @@ lhsCodeBlock = try $ do
347 getPosition >>= guard . (==1) . sourceColumn
347 getPosition >>= guard . (==1) . sourceColumn
348 guardEnabled Ext_literate_haskell
348 guardEnabled Ext_literate_haskell
349 optional codeBlockStart
349 optional codeBlockStart
350− lns <- many1 birdTrackLine
350+ lns <- latexCodeBlock <|> birdCodeBlock
351− -- if (as is normal) there is always a space after >, drop it
352− let lns' = if all (\ln -> null ln || take 1 ln == " ") lns
353− then map (drop 1) lns
355 blanklines
351 blanklines
356 return $ B.codeBlockWith ("", ["sourceCode", "literate", "haskell"], [])
352 return $ B.codeBlockWith ("", ["sourceCode", "literate", "haskell"], [])
357− $ intercalate "\n" lns'
353+ $ intercalate "\n" lns
355+latexCodeBlock :: Parser [Char] st [[Char]]
356+latexCodeBlock = try $ do
357+ try (latexBlockLine "\\begin{code}")
358+ many1Till anyLine (try $ latexBlockLine "\\end{code}")
360+ latexBlockLine s = skipMany spaceChar >> string s >> blankline
362+birdCodeBlock :: Parser [Char] st [[Char]]
363+birdCodeBlock = filterSpace <$> many1 birdTrackLine
364+ where filterSpace lns =
365+ -- if (as is normal) there is always a space after >, drop it
366+ if all (\ln -> null ln || take 1 ln == " ") lns
367+ then map (drop 1) lns
359birdTrackLine :: Parser [Char] st [Char]
370birdTrackLine :: Parser [Char] st [Char]
360birdTrackLine = char '>' >> anyLine
371birdTrackLine = char '>' >> anyLine