aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2009-11-17 03:36:04 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2009-11-17 03:36:04 +0000
commit9d20eeb019a6c5208342bfc3f03ae47c9aa83483 (patch)
tree5cef381c2f813eb272c7a3bb7d0787557a3c213e /src/Text/Pandoc/Readers
parentfce48c392acd5c56141ce924f4aaa8fadd10085d (diff)
downloadpandoc-9d20eeb019a6c5208342bfc3f03ae47c9aa83483.tar.gz
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
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs11
1 files changed, 11 insertions, 0 deletions
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