-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Conversion between math formats.
--   
--   The texmath library provides functions to read and write TeX math,
--   presentation MathML, and OMML (Office Math Markup Language, used in
--   Microsoft Office). Support is also included for converting math
--   formats to Gnu eqn, typst, StarMath, and pandoc's native format
--   (allowing conversion, via pandoc, to a variety of different markup
--   formats). The TeX reader supports basic LaTeX and AMS extensions, and
--   it can parse and apply LaTeX macros. (See here for a live demo
--   of bidirectional conversion between LaTeX and MathML.)
--   
--   The package also includes several utility modules which may be useful
--   for anyone looking to manipulate either TeX math or MathML. For
--   example, a copy of the MathML operator dictionary is included.
--   
--   Use the executable flag to install a standalone executable,
--   texmath, that converts formulas from one format to another.
--   (Use the --help flag for a description of all functionality).
--   
--   Use the server flag to install a web server,
--   texmath-server, that exposes a JSON API allowing conversion
--   of individual formulas and batches of formulas.
@package texmath
@version 0.13.2.1

-- | HTML entity definitions as provided by W3C.
--   
--   The mapping matches the version from 10th April 2014.
--   
--   The original source can be downloaded from
--   http://www.w3.org/TR/2014/REC-xml-entity-names-20140410/.
--   
--   Note: I have made one alteration, switching epsilon and varepsilon,
--   because the meanings of these names in HTML is different from the
--   meanings in MathML+LaTeX. See
--   http://www.w3.org/2003/entities/2007doc/#epsilon.
module Text.TeXMath.Readers.MathML.EntityMap

-- | Translates MathML entity reference to the corresponding Unicode
--   string.
getUnicode :: Text -> Maybe Text

-- | Functions for parsing LaTeX macro definitions and applying macros to
--   LateX expressions.
module Text.TeXMath.Readers.TeX.Macros
data Macro

-- | Parses a string for a list of macro definitions, optionally separated
--   and ended by spaces and TeX comments. Returns the list of macros
--   (which may be empty) and the unparsed portion of the input string.
parseMacroDefinitions :: Text -> ([Macro], Text)

-- | Parses a \newcommand or \renewcommand macro
--   definition and returns a Macro.
pMacroDefinition :: forall (m :: Type -> Type) s st. (Monad m, Stream s m Char) => ParsecT s st m Macro

-- | Applies a list of macros to a string recursively until a fixed point
--   is reached. If there are several macros in the list with the same
--   name, earlier ones will shadow later ones.
applyMacros :: [Macro] -> Text -> Text
instance GHC.Internal.Show.Show Text.TeXMath.Readers.TeX.Macros.Macro

module Text.TeXMath.TeX

-- | An intermediate representation of TeX math, to be used in rendering.
data TeX
ControlSeq :: Text -> TeX
Token :: Char -> TeX
Literal :: Text -> TeX
Grouped :: [TeX] -> TeX
Space :: TeX

-- | Render a TeX to a string, appending to the front of the given
--   string.
renderTeX :: TeX -> Text -> Text
isControlSeq :: Text -> Bool
escapeLaTeX :: Char -> TeX
instance GHC.Classes.Eq Text.TeXMath.TeX.TeX
instance GHC.Internal.Show.Show Text.TeXMath.TeX.TeX

-- | Types for representing a structured formula.
module Text.TeXMath.Types
data Exp

-- | A number (<mn> in MathML).
ENumber :: Text -> Exp

-- | A group of expressions that function as a unit (e.g. {...})
--   in TeX, <mrow>...</mrow> in MathML.
EGrouped :: [Exp] -> Exp

-- | A group of expressions inside paired open and close delimiters (which
--   may in some cases be null).
EDelimited :: Text -> Text -> [InEDelimited] -> Exp

-- | An identifier, e.g. a variable (<mi>...</mi> in
--   MathML. Note that MathML tends to use <mi> tags for
--   "sin" and other mathematical operators; these are represented as
--   EMathOperator in TeXMath.
EIdentifier :: Text -> Exp

-- | A spelled-out operator like lim or sin.
EMathOperator :: Text -> Exp

-- | A symbol.
ESymbol :: TeXSymbolType -> Text -> Exp

-- | A space, with the width specified in em.
ESpace :: Rational -> Exp

-- | An expression with a subscript. First argument is base, second
--   subscript.
ESub :: Exp -> Exp -> Exp

-- | An expresion with a superscript. First argument is base, second
--   subscript.
ESuper :: Exp -> Exp -> Exp

-- | An expression with both a sub and a superscript. First argument is
--   base, second subscript, third superscript.
ESubsup :: Exp -> Exp -> Exp -> Exp

-- | An expression with something over it. The first argument is True if
--   the formula is "convertible:" that is, if the material over the
--   formula should appear as a regular superscript in inline math. The
--   second argument is the base, the third the expression that goes over
--   it.
EOver :: Bool -> Exp -> Exp -> Exp

-- | An expression with something under it. The arguments work as in
--   EOver.
EUnder :: Bool -> Exp -> Exp -> Exp

-- | An expression with something over and something under it.
EUnderover :: Bool -> Exp -> Exp -> Exp -> Exp

-- | A "phantom" operator that takes space but doesn't display.
EPhantom :: Exp -> Exp

-- | A boxed expression.
EBoxed :: Exp -> Exp

-- | A cancelled expression.
ECancel :: StrokeType -> Exp -> Exp

-- | A fraction. First argument is numerator, second denominator.
EFraction :: FractionType -> Exp -> Exp -> Exp

-- | An nth root. First argument is index, second is base.
ERoot :: Exp -> Exp -> Exp

-- | A square root.
ESqrt :: Exp -> Exp

-- | An expression that is scaled to some factor of its normal size.
EScaled :: Rational -> Exp -> Exp

-- | An array or matrix. The first argument specifies the alignments of the
--   columns; the second gives the contents of the lines. All of these
--   lists should be the same length.
EArray :: [Alignment] -> [ArrayLine] -> Exp

-- | Some normal text, possibly styled.
EText :: TextType -> Text -> Exp

-- | A group of styled expressions.
EStyled :: TextType -> [Exp] -> Exp
data TeXSymbolType
Ord :: TeXSymbolType
Op :: TeXSymbolType
Bin :: TeXSymbolType
Rel :: TeXSymbolType
Open :: TeXSymbolType
Close :: TeXSymbolType
Pun :: TeXSymbolType
Accent :: TeXSymbolType
Fence :: TeXSymbolType
TOver :: TeXSymbolType
TUnder :: TeXSymbolType
Alpha :: TeXSymbolType
BotAccent :: TeXSymbolType
Rad :: TeXSymbolType
type ArrayLine = [[Exp]]
data FractionType

-- | Displayed or textual, acc to DisplayType
NormalFrac :: FractionType

-- | Force display mode
DisplayFrac :: FractionType

-- | Force inline mode (textual)
InlineFrac :: FractionType

-- | No line between top and bottom
NoLineFrac :: FractionType
data TextType
TextNormal :: TextType
TextBold :: TextType
TextItalic :: TextType
TextMonospace :: TextType
TextSansSerif :: TextType
TextDoubleStruck :: TextType
TextScript :: TextType
TextFraktur :: TextType
TextBoldItalic :: TextType
TextSansSerifBold :: TextType
TextSansSerifBoldItalic :: TextType
TextBoldScript :: TextType
TextBoldFraktur :: TextType
TextSansSerifItalic :: TextType
data Alignment
AlignLeft :: Alignment
AlignCenter :: Alignment
AlignRight :: Alignment
data DisplayType

-- | A displayed formula.
DisplayBlock :: DisplayType

-- | A formula rendered inline in text.
DisplayInline :: DisplayType

-- | A record of the MathML dictionary as defined in the
--   specification
data Operator
Operator :: Text -> Text -> FormType -> Int -> Int -> Int -> [Property] -> Operator

-- | Operator
[oper] :: Operator -> Text

-- | Plain English Description
[description] :: Operator -> Text

-- | Whether Prefix, Postfix or Infix
[form] :: Operator -> FormType

-- | Default priority for implicit nesting
[priority] :: Operator -> Int

-- | Default Left Spacing
[lspace] :: Operator -> Int

-- | Default Right Spacing
[rspace] :: Operator -> Int

-- | List of MathML properties
[properties] :: Operator -> [Property]
data FormType
FPrefix :: FormType
FPostfix :: FormType
FInfix :: FormType

-- | A record of the Unicode to LaTeX lookup table a full descripton can be
--   seen
--   <http://milde.users.sourceforge.net/LUCR/Math/data/unimathsymbols.txt
--   here>
data Record
Record :: Char -> [(Text, Text)] -> TeXSymbolType -> Text -> Record

-- | Unicode Character
[uchar] :: Record -> Char

-- | LaTeX commands (package, command)
[commands] :: Record -> [(Text, Text)]

-- | TeX math category
[category] :: Record -> TeXSymbolType

-- | Plain english description
[comments] :: Record -> Text
type Property = Text
data Position
Under :: Position
Over :: Position
data StrokeType
ForwardSlash :: StrokeType
BackSlash :: StrokeType
XSlash :: StrokeType

-- | List of available packages
type Env = [Text]

-- | Contains amsmath and amssymbol
defaultEnv :: [Text]

-- | An EDelimited element contains a string of ordinary
--   expressions (represented here as Right values) or fences
--   (represented here as Left, and in LaTeX using mid).
type InEDelimited = Either Middle Exp
instance GHC.Internal.Data.Data.Data Text.TeXMath.Types.Alignment
instance GHC.Internal.Data.Data.Data Text.TeXMath.Types.Exp
instance GHC.Internal.Data.Data.Data Text.TeXMath.Types.FractionType
instance GHC.Internal.Data.Data.Data Text.TeXMath.Types.StrokeType
instance GHC.Internal.Data.Data.Data Text.TeXMath.Types.TeXSymbolType
instance GHC.Internal.Data.Data.Data Text.TeXMath.Types.TextType
instance GHC.Classes.Eq Text.TeXMath.Types.Alignment
instance GHC.Classes.Eq Text.TeXMath.Types.DisplayType
instance GHC.Classes.Eq Text.TeXMath.Types.Exp
instance GHC.Classes.Eq Text.TeXMath.Types.FormType
instance GHC.Classes.Eq Text.TeXMath.Types.FractionType
instance GHC.Classes.Eq Text.TeXMath.Types.StrokeType
instance GHC.Classes.Eq Text.TeXMath.Types.TeXSymbolType
instance GHC.Classes.Eq Text.TeXMath.Types.TextType
instance GHC.Classes.Ord Text.TeXMath.Types.Alignment
instance GHC.Classes.Ord Text.TeXMath.Types.DisplayType
instance GHC.Classes.Ord Text.TeXMath.Types.Exp
instance GHC.Classes.Ord Text.TeXMath.Types.FormType
instance GHC.Classes.Ord Text.TeXMath.Types.FractionType
instance GHC.Classes.Ord Text.TeXMath.Types.StrokeType
instance GHC.Classes.Ord Text.TeXMath.Types.TeXSymbolType
instance GHC.Classes.Ord Text.TeXMath.Types.TextType
instance GHC.Internal.Read.Read Text.TeXMath.Types.Alignment
instance GHC.Internal.Read.Read Text.TeXMath.Types.Exp
instance GHC.Internal.Read.Read Text.TeXMath.Types.FractionType
instance GHC.Internal.Read.Read Text.TeXMath.Types.StrokeType
instance GHC.Internal.Read.Read Text.TeXMath.Types.TeXSymbolType
instance GHC.Internal.Read.Read Text.TeXMath.Types.TextType
instance GHC.Internal.Show.Show Text.TeXMath.Types.Alignment
instance GHC.Internal.Show.Show Text.TeXMath.Types.DisplayType
instance GHC.Internal.Show.Show Text.TeXMath.Types.Exp
instance GHC.Internal.Show.Show Text.TeXMath.Types.FormType
instance GHC.Internal.Show.Show Text.TeXMath.Types.FractionType
instance GHC.Internal.Show.Show Text.TeXMath.Types.Operator
instance GHC.Internal.Show.Show Text.TeXMath.Types.Record
instance GHC.Internal.Show.Show Text.TeXMath.Types.StrokeType
instance GHC.Internal.Show.Show Text.TeXMath.Types.TeXSymbolType
instance GHC.Internal.Show.Show Text.TeXMath.Types.TextType

module Text.TeXMath.Shared

-- | Maps TextType to the corresponding MathML mathvariant
getMMLType :: TextType -> Text

-- | Maps MathML mathvariant to the corresponing TextType
getTextType :: Text -> TextType

-- | Maps TextType to corresponding LaTeX command
getLaTeXTextCommand :: Env -> TextType -> Text

-- | Maps a LaTeX scaling command to the percentage scaling
getScalerCommand :: Rational -> Maybe Text

-- | Gets percentage scaling from LaTeX scaling command
getScalerValue :: Text -> Maybe Rational

-- | Mapping between LaTeX scaling commands and the scaling factor
scalers :: [(Text, Rational)]

-- | Returns the space width for a unicode space character, or Nothing.
getSpaceWidth :: Char -> Maybe Rational

-- | Returns the sequence of unicode space characters closest to the
--   specified width.
getSpaceChars :: Rational -> Text

-- | Given a diacritical mark, returns the corresponding LaTeX command
getDiacriticalCommand :: Position -> Text -> Maybe Text

-- | Mapping between unicode combining character and LaTeX accent command
diacriticals :: [(Text, Text)]
getOperator :: Exp -> Maybe TeX

-- | Attempts to convert a string into
readLength :: Text -> Maybe Rational

-- | Walks over a tree of expressions, removing empty expressions, and
--   fixing delimited expressions with no delimiters and unnecessarily
--   grouped expressions.
fixTree :: Exp -> Exp

-- | Test to see whether an expression is empty.
isEmpty :: Exp -> Bool

-- | An empty group of expressions
empty :: Exp
handleDownup :: DisplayType -> Exp -> Exp
isUppercaseGreek :: Text -> Bool
toPrimes :: Exp -> Maybe Text
isRLSequence :: [Alignment] -> Bool

-- | Dictionary of operators to MathML attributes as specified by the W3C
--   standard.
--   
--   The original file can be downloaded from here
module Text.TeXMath.Readers.MathML.MMLDict

-- | Tries to find the Operator record based on a given position. If
--   there is no exact match then the positions will be tried in the
--   following order (Infix, Postfix, Prefix) with the first match (if any)
--   being returned.
getMathMLOperator :: Text -> FormType -> Maybe Operator

-- | A table of all operators as defined by the MathML operator dictionary.
operators :: [Operator]

-- | Utilities to convert between MS font codepoints and unicode
--   characters.
module Text.TeXMath.Unicode.Fonts

-- | Given a font and codepoint, returns the corresponding unicode
--   character
getUnicode :: Font -> Char -> Maybe Char

-- | Enumeration of recognised fonts
data Font

-- | Adobe Symbol
Symbol :: Font

-- | Parse font name into Font if possible.
textToFont :: Text -> Maybe Font
instance GHC.Classes.Eq Text.TeXMath.Unicode.Fonts.Font
instance GHC.Internal.Show.Show Text.TeXMath.Unicode.Fonts.Font

-- | Function for replacing strings of characters with their respective
--   mathvariant and vice versa.
module Text.TeXMath.Unicode.ToUnicode

-- | The inverse of toUnicodeChar: returns the corresponding
--   unstyled character and TextType of a unicode character.
fromUnicodeChar :: Char -> Maybe (TextType, Char)
toUnicodeChar :: (TextType, Char) -> Maybe Char

-- | Inverse of toUnicode.
fromUnicode :: TextType -> Text -> Text

-- | Replace characters with their corresponding mathvariant unicode
--   character. MathML has a mathvariant attribute which is unimplemented
--   in Firefox (see here) Therefore, we may want to translate
--   mathscr, etc to unicode symbols directly.
toUnicode :: TextType -> Text -> Text

-- | This module is derived from the list of unicode to LaTeX mappings
--   compiled by Günter Milde.
--   
--   An unmodified original copy of this work can be obtained from
--   here
module Text.TeXMath.Unicode.ToTeX

-- | Converts a string of unicode characters into a strong of equivalent
--   TeXMath commands. An environment is a list of strings specifying which
--   additional packages are available.
getTeXMath :: Text -> Env -> [TeX]

-- | Returns TeX symbol type corresponding to a unicode character.
getSymbolType :: Char -> TeXSymbolType

-- | Mapping from TeX commands to Exp.
symbolMap :: Map Text Exp
records :: [Record]

-- | Types and functions for conversion of OMML into TeXMath Exps.
module Text.TeXMath.Readers.OMML
readOMML :: Text -> Either Text [Exp]
instance GHC.Classes.Eq Text.TeXMath.Readers.OMML.OMathTextScript
instance GHC.Classes.Eq Text.TeXMath.Readers.OMML.OMathTextStyle
instance GHC.Internal.Show.Show Text.TeXMath.Readers.OMML.OMathRunElem
instance GHC.Internal.Show.Show Text.TeXMath.Readers.OMML.OMathRunTextStyle
instance GHC.Internal.Show.Show Text.TeXMath.Readers.OMML.OMathTextScript
instance GHC.Internal.Show.Show Text.TeXMath.Readers.OMML.OMathTextStyle

-- | Functions for parsing a LaTeX formula to a Haskell representation.
module Text.TeXMath.Readers.TeX

-- | Parse a formula, returning a list of Exp.
readTeX :: Text -> Either Text [Exp]

-- | Parses MathML in conformance with the MathML3 specification.
--   
--   Unimplemented features:
--   
--   
--   
- mpadded
--   
- malignmark
--   
- maligngroup
--   
- Elementary Math
--   
--   
--   To Improve:
--   
--   
--   
- Handling of menclose
--   
- Handling of mstyle
--   
module Text.TeXMath.Readers.MathML

-- | Parse a MathML expression to a list of Exp.
readMathML :: Text -> Either Text [Exp]
instance GHC.Classes.Eq Text.TeXMath.Readers.MathML.SupOrSub
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Text.TeXMath.Readers.MathML.IR a)
instance GHC.Internal.Show.Show Text.TeXMath.Readers.MathML.SupOrSub

module Text.TeXMath.Writers.Eqn

-- | Transforms an expression tree to equivalent Eqn
writeEqn :: DisplayType -> [Exp] -> Text

-- | Functions for writing a parsed formula as MathML.
module Text.TeXMath.Writers.MathML

-- | Transforms an expression tree to a MathML XML tree
writeMathML :: DisplayType -> [Exp] -> Element

-- | Functions for writing a parsed formula as OMML.
module Text.TeXMath.Writers.OMML

-- | Transforms an expression tree to an OMML XML Tree
writeOMML :: DisplayType -> [Exp] -> Element

-- | Functions for writing a parsed formula as a list of Pandoc Inlines.
module Text.TeXMath.Writers.Pandoc

-- | Attempts to convert a formula to a list of Pandoc inlines.
writePandoc :: DisplayType -> [Exp] -> Maybe [Inline]

module Text.TeXMath.Writers.TeX

-- | Transforms an expression tree to equivalent LaTeX with the default
--   packages (amsmath, amssymb, and cancel)
writeTeX :: [Exp] -> Text

-- | Transforms an expression tree to equivalent LaTeX with the specified
--   packages
writeTeXWith :: Env -> [Exp] -> Text

-- | Adds the correct LaTeX environment around a TeXMath fragment
addLaTeXEnvironment :: DisplayType -> Text -> Text
instance GHC.Internal.Base.Applicative Text.TeXMath.Writers.TeX.Math
instance GHC.Internal.Base.Functor Text.TeXMath.Writers.TeX.Math
instance GHC.Internal.Base.Monad Text.TeXMath.Writers.TeX.Math
instance Control.Monad.Reader.Class.MonadReader Text.TeXMath.Writers.TeX.MathState Text.TeXMath.Writers.TeX.Math
instance Control.Monad.Writer.Class.MonadWriter [Text.TeXMath.TeX.TeX] Text.TeXMath.Writers.TeX.Math
instance GHC.Internal.Show.Show Text.TeXMath.Writers.TeX.MathState

module Text.TeXMath.Writers.StarMath

-- | Render TeXMath expressions as StarMath syntax. Falls back to TeX
--   output for expressions that are not yet supported.
writeStarMath :: DisplayType -> [Exp] -> Text
instance GHC.Classes.Eq Text.TeXMath.Writers.StarMath.AlignContext

module Text.TeXMath.Writers.Typst

-- | Transforms an expression tree to equivalent Typst
writeTypst :: DisplayType -> [Exp] -> Text

-- | 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 s
--   
--   
--   It is also possible to manipulate the AST using 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
--   
module Text.TeXMath

-- | Parse a MathML expression to a list of Exp.
readMathML :: Text -> Either Text [Exp]
readOMML :: Text -> Either Text [Exp]

-- | Parse a formula, returning a list of Exp.
readTeX :: Text -> Either Text [Exp]

-- | Transforms an expression tree to equivalent LaTeX with the default
--   packages (amsmath, amssymb, and cancel)
writeTeX :: [Exp] -> Text

-- | Transforms an expression tree to equivalent LaTeX with the specified
--   packages
writeTeXWith :: Env -> [Exp] -> Text

-- | Adds the correct LaTeX environment around a TeXMath fragment
addLaTeXEnvironment :: DisplayType -> Text -> Text

-- | Transforms an expression tree to equivalent Eqn
writeEqn :: DisplayType -> [Exp] -> Text

-- | Render TeXMath expressions as StarMath syntax. Falls back to TeX
--   output for expressions that are not yet supported.
writeStarMath :: DisplayType -> [Exp] -> Text

-- | Transforms an expression tree to equivalent Typst
writeTypst :: DisplayType -> [Exp] -> Text

-- | Transforms an expression tree to an OMML XML Tree
writeOMML :: DisplayType -> [Exp] -> Element

-- | Transforms an expression tree to a MathML XML tree
writeMathML :: DisplayType -> [Exp] -> Element

-- | Attempts to convert a formula to a list of Pandoc inlines.
writePandoc :: DisplayType -> [Exp] -> Maybe [Inline]
data DisplayType

-- | A displayed formula.
DisplayBlock :: DisplayType

-- | A formula rendered inline in text.
DisplayInline :: DisplayType
data Exp
