aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-01-05 14:44:26 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-01-05 14:44:26 -0800
commit23aae79b016711c15d27058b5c902e26f2169261 (patch)
tree58f5aaedd1836664e0487366d7de6ee2c973aa8b
parenteb83f0e5e40a1a0846085fccb2f72ce2b7cc60f0 (diff)
downloadpandoc-23aae79b016711c15d27058b5c902e26f2169261.tar.gz
Updated for texmath 0.5.
-rw-r--r--pandoc.cabal2
-rw-r--r--src/Text/Pandoc/Readers/TeXMath.hs26
2 files changed, 14 insertions, 14 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index 765fde59f..d41e608ee 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -171,7 +171,7 @@ Library
process >= 1, directory >= 1,
bytestring >= 0.9, zip-archive >= 0.1.1.4,
utf8-string >= 0.3, old-time >= 1,
- HTTP >= 4000.0.5, texmath >= 0.4, xml >= 1.3.5 && < 1.4,
+ HTTP >= 4000.0.5, texmath >= 0.5, xml >= 1.3.5 && < 1.4,
random, extensible-exceptions,
citeproc-hs >= 0.3 && < 0.4,
pandoc-types == 1.7.*,
diff --git a/src/Text/Pandoc/Readers/TeXMath.hs b/src/Text/Pandoc/Readers/TeXMath.hs
index ca839dd08..8c9fe2c7e 100644
--- a/src/Text/Pandoc/Readers/TeXMath.hs
+++ b/src/Text/Pandoc/Readers/TeXMath.hs
@@ -27,12 +27,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of TeX math to a list of 'Pandoc' inline elements.
-}
-module Text.Pandoc.Readers.TeXMath (
- readTeXMath
- ) where
+module Text.Pandoc.Readers.TeXMath ( readTeXMath ) where
-import Text.ParserCombinators.Parsec
import Text.Pandoc.Definition
+import Text.TeXMath.Types
import Text.TeXMath.Parser
-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
@@ -40,16 +38,17 @@ import Text.TeXMath.Parser
-- can't be converted.
readTeXMath :: String -- ^ String to parse (assumes @'\n'@ line endings)
-> [Inline]
-readTeXMath inp = case readTeXMath' inp of
- Nothing -> [Str ("$" ++ inp ++ "$")]
- Just res -> res
+readTeXMath inp = case texMathToPandoc inp of
+ Left _ -> [Str ("$" ++ inp ++ "$")]
+ Right res -> res
--- | Like 'readTeXMath', but without the default.
-readTeXMath' :: String -- ^ String to parse (assumes @'\n'@ line endings)
- -> Maybe [Inline]
-readTeXMath' inp = case parse formula "formula" inp of
- Left _ -> Just [Str inp]
- Right exps -> expsToInlines exps
+texMathToPandoc :: String -> Either String [Inline]
+texMathToPandoc inp = inp `seq`
+ case parseFormula inp of
+ Left err -> Left err
+ Right exps -> case expsToInlines exps of
+ Nothing -> Left "Formula too complex for [Inline]"
+ Just r -> Right r
expsToInlines :: [Exp] -> Maybe [Inline]
expsToInlines xs = do
@@ -111,3 +110,4 @@ expToInlines (EOver (EGrouped [EIdentifier [c]]) (ESymbol Accent [accent])) =
_ -> Nothing
expToInlines _ = Nothing
+