From 3cf60c73061f247b531da4b3c18664c6134bee53 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 31 Dec 2011 11:40:47 -0800 Subject: Support for math in RST reader and writer. Inline math uses the :math:`...` construct. Display math uses .. math:: ... or if multilin .. math:: ... These seem to be supported now by rst2latex.py. --- src/Text/Pandoc/Readers/RST.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 02154b5a3..456b23ce8 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -363,18 +363,18 @@ customCodeBlock = try $ do -- | The 'math' directive (from Sphinx) for display math. mathBlock :: GenParser Char st Block -mathBlock = mathBlockMultiline <|> mathBlockOneLine +mathBlock = try $ do + string ".. math::" + mathBlockMultiline <|> mathBlockOneLine mathBlockOneLine :: GenParser Char st Block mathBlockOneLine = try $ do - string ".. math:" result <- manyTill anyChar newline blanklines return $ Para [Math DisplayMath $ removeLeadingTrailingSpace result] mathBlockMultiline :: GenParser Char st Block mathBlockMultiline = try $ do - string ".. math::" blanklines result <- indentedBlock -- a single block can contain multiple equations, which need to go @@ -384,7 +384,8 @@ mathBlockMultiline = try $ do let startsWithColon (':':_) = True startsWithColon _ = False let lns' = dropWhile startsWithColon lns - let eqs = map unwords $ filter (not . null) $ splitBy null lns' + let eqs = map (removeLeadingTrailingSpace . unlines) + $ filter (not . null) $ splitBy null lns' return $ Para $ map (Math DisplayMath) eqs lhsCodeBlock :: GenParser Char ParserState Block -- cgit v1.2.3