aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2011-12-31 11:40:47 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2011-12-31 11:40:47 -0800
commit3cf60c73061f247b531da4b3c18664c6134bee53 (patch)
tree55cded45b8b5503ff8fadfe91f0e6807a06ac9de /src/Text/Pandoc/Writers
parentc264dc4f5b86688552f663f1487d135b035f0b62 (diff)
downloadpandoc-3cf60c73061f247b531da4b3c18664c6134bee53.tar.gz
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.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/RST.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index 282935bbd..db2ad0dfb 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -286,9 +286,11 @@ inlineToRST (Str str) = return $ text $ escapeString str
inlineToRST (Math t str) = do
modify $ \st -> st{ stHasMath = True }
return $ if t == InlineMath
- then ":math:`" <> text str <> "`\\ "
- else blankline $$ ".. math::" $$ blankline $$
- nest 3 (text str) $$ blankline
+ then ":math:`" <> text str <> "`" <> beforeNonBlank "\\ "
+ else if '\n' `elem` str
+ then blankline $$ ".. math::" $$
+ blankline $$ nest 3 (text str) $$ blankline
+ else blankline $$ (".. math:: " <> text str) $$ blankline
inlineToRST (RawInline _ _) = return empty
inlineToRST (LineBreak) = return cr -- there's no line break in RST
inlineToRST Space = return space