From 9d20eeb019a6c5208342bfc3f03ae47c9aa83483 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Tue, 17 Nov 2009 03:36:04 +0000 Subject: Support for "..code-block" directive in RST reader. Not core RST, but used in Sphinx for code blocks annotated with syntax information. Thanks to Luke Plant for the patch. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1619 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/RST.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 89c30ff5d..9e38b1872 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -122,6 +122,7 @@ block = choice [ codeBlock , fieldList , blockQuote , imageBlock + , customCodeBlock , unknownDirective , header , hrule @@ -331,6 +332,16 @@ codeBlock = try $ do result <- indentedBlock return $ CodeBlock ("",[],[]) $ stripTrailingNewlines result +-- | The 'code-block' directive (from Sphinx) that allows a language to be +-- specified. +customCodeBlock :: GenParser Char st Block +customCodeBlock = try $ do + string ".. code-block:: " + language <- manyTill anyChar newline + blanklines + result <- indentedBlock + return $ CodeBlock ("", ["sourceCode", language], []) $ stripTrailingNewlines result + lhsCodeBlock :: GenParser Char ParserState Block lhsCodeBlock = try $ do failUnlessLHS -- cgit v1.2.3