From 3df2f1e3de38d4aa50b3df5e4c6ee7cab8a33312 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Wed, 19 Dec 2012 11:29:03 -0800
Subject: [PATCH] EPUB3:  Don't use the switch statement for mathml.

It is not widely implemented yet.
---
 src/Text/Pandoc/Writers/EPUB.hs | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index f1ae41d2f..e7feace7a 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -168,7 +168,7 @@ writeEPUB version opts doc@(Pandoc meta _) = do
                            ([("id", takeBaseName $ eRelativePath ent),
                              ("href", eRelativePath ent),
                              ("media-type", "application/xhtml+xml")]
-                            ++ [("properties","mathml switch") | epub3 &&
+                            ++ [("properties","mathml") | epub3 &&
                                    containsMathML ent]) $ ()
   let chapterRefNode ent = unode "itemref" !
                              [("idref", takeBaseName $ eRelativePath ent)] $ ()
@@ -383,17 +383,12 @@ transformInlines _ sourceDir picsRef (Image lab (src,tit) : xs) = do
                         return new
   return $ Image lab (newsrc, tit) : xs
 transformInlines (MathML _) _ _ (x@(Math _ _) : xs) = do
+  -- note: ideally we'd use a switch statement to provide a fallback
+  -- but switch does not seem to be widely implemented yet, so we just
+  -- provide the mathml
   let writeHtmlInline opts z = trimr $
          writeHtmlString opts $ Pandoc (Meta [] [] []) [Plain [z]]
-      mathml = writeHtmlInline def{writerHTMLMathMethod = MathML Nothing } x
-      -- we use mathjax to get raw latex, since readers tend to
-      -- fall back to using mathjax...
-      fallback = writeHtmlInline def{writerHTMLMathMethod = MathJax "" } x
-      inSwitch = "<epub:switch><epub:case required-namespace=" ++
-         "\"http://www.w3.org/1998/Math/MathML\">" ++ mathml ++
-         "</epub:case><epub:default>" ++ fallback ++
-         "</epub:default></epub:switch>"
-      result = if "<math" `isPrefixOf` mathml then inSwitch else mathml
+      result = writeHtmlInline def{writerHTMLMathMethod = MathML Nothing } x
   return $ RawInline "html" result : xs
 transformInlines _ _ _ xs = return xs