@@ -27,16 +27,30 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2727
2828Conversion of TeX math to a list of 'Pandoc' inline elements.
2929-}
30−module Text.Pandoc.Readers.TeXMath ( readTeXMath ) where
30+module Text.Pandoc.Readers.TeXMath ( readTeXMath, readTeXMath' ) where
3131
3232import Text.Pandoc.Definition
3333import Text.TeXMath
3434
3535-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
36−-- Defaults to raw formula between @$@ characters if entire formula
36+-- Defaults to raw formula between @$@ or @$$@ characters if entire formula
3737-- can't be converted.
38+readTeXMath' :: MathType
39+ -> String -- ^ String to parse (assumes @'\n'@ line endings)
40+ -> [Inline]
41+readTeXMath' mt inp = case texMathToPandoc dt inp of
42+ Left _ -> [Str (delim ++ inp ++ delim)]
43+ Right res -> res
44+ where (dt, delim) = case mt of
45+ DisplayMath -> (DisplayBlock, "$$")
46+ InlineMath -> (DisplayInline, "$")
47+
48+{-# DEPRECATED readTeXMath "Use readTeXMath' from Text.Pandoc.JSON instead" #-}
49+-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
50+-- Defaults to raw formula between @$@ characters if entire formula
51+-- can't be converted. (This is provided for backwards compatibility;
52+-- it is better to use @readTeXMath'@, which properly distinguishes
53+-- between display and inline math.)
3854readTeXMath :: String -- ^ String to parse (assumes @'\n'@ line endings)
3955 -> [Inline]
40−readTeXMath inp = case texMathToPandoc DisplayInline inp of
41− Left _ -> [Str ("$" ++ inp ++ "$")]
42− Right res -> res
56+readTeXMath = readTeXMath' InlineMath