Parse a MathML expression to a list of Exp.
Moduletexmath-0.12.8.9Haskell2010
Text.TeXMath
Functions for converting between different representations of mathematical formulas.
Also note that in general writeLaTeX . readLaTeX /= id.
A typical use is to combine together a reader and writer.
import Control.Applicative ((<$>))
import Data.Text (Text)
import Text.TeXMath (writeMathML, readTeX)
texMathToMathML :: DisplayType -> Text -> Either Text Element
texMathToMathML dt s = writeMathML dt <$> readTeX sIt is also possible to manipulate the AST using Data.Generics. For
example, if you wanted to replace all occurences of the identifier
x in your expression, you do could do so with the following
script.
{-# LANGUAGE OverloadedStrings -#}
import Control.Applicative ((<$>))
import Data.Text (Text)
import Data.Generics (everywhere, mkT)
import Text.TeXMath (writeMathML, readTeX)
import Text.TeXMath.Types
import Text.XML.Light (Element)
changeIdent :: Exp -> Exp
changeIdent (EIdentifier "x") = EIdentifier "y"
changeIdent e = e
texToMMLWithChangeIdent :: DisplayType -> Text -> Either Text Element
texToMMLWithChangeIdent dt s =
writeMathML dt . everywhere (mkT changeIdent) <$> readTeX s
- 2 types
- 11 values
- Packagetexmath-0.12.8.9
- Exports13
- LanguageHaskell2010
- LicenceGPL-2.0-only
- SourceTeXMath.hs
Parse a formula, returning a list of Exp.
Transforms an expression tree to equivalent LaTeX with the default packages (amsmath and amssymb)
Transforms an expression tree to equivalent LaTeX with the specified packages
Adds the correct LaTeX environment around a TeXMath fragment
Transforms an expression tree to equivalent Eqn
Transforms an expression tree to equivalent Typst
Transforms an expression tree to an OMML XML Tree
Transforms an expression tree to a MathML XML tree
Attempts to convert a formula to a list of Pandoc inlines.
Constructors
DisplayBlockA displayed formula.
DisplayInlineA formula rendered inline in text.
Instances3Eq, Ord, Show
Eq DisplayTypeDefined in texmath-0.12.8.9 · Text.TeXMath.TypesOrd DisplayTypeDefined in texmath-0.12.8.9 · Text.TeXMath.TypesShow DisplayTypeDefined in texmath-0.12.8.9 · Text.TeXMath.Types