From c7f6f779089e0336a7070cd2a9b614a8e98e9515 Mon Sep 17 00:00:00 2001
From: John MacFarlane <fiddlosopher@gmail.com>
Date: Fri, 30 Dec 2011 23:51:49 -0800
Subject: [PATCH] Support Sphinx-style math in RST writer.

http://sphinx.pocoo.org/latest/ext/math.html
---
 src/Text/Pandoc/Writers/RST.hs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index 125ed4f13..282935bbd 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -286,8 +286,9 @@ 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 ":math:`$$" <> text str <> "$$`"
+              then ":math:`" <> text str <> "`\\ "
+              else blankline $$ ".. math::" $$ blankline $$
+                   nest 3 (text str) $$ blankline
 inlineToRST (RawInline _ _) = return empty
 inlineToRST (LineBreak) = return cr -- there's no line break in RST
 inlineToRST Space = return space