-- 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, 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 <a>here</a> 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 <tt>executable</tt> flag to install a standalone executable,
--   <tt>texmath</tt>, that converts formulas from one format to another.
--   (Use the <tt>--help</tt> flag for a description of all functionality).
--   
--   Use the <tt>server</tt> flag to install a web server,
--   <tt>texmath-server</tt>, that exposes a JSON API allowing conversion
--   of individual formulas and batches of formulas.
@package texmath
@version 0.12.10.3


-- | HTML entity definitions as provided by W3C.
--   
--   The mapping matches the version from 10th April 2014.
--   
--   The original source can be downloaded from
--   <a>http://www.w3.org/TR/2014/REC-xml-entity-names-20140410/</a>.
--   
--   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
--   <a>http://www.w3.org/2003/entities/2007doc/#epsilon</a>.
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 <tt>\newcommand</tt> or <tt>\renewcommand</tt> macro
--   definition and returns a <a>Macro</a>.
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 <a>TeX</a> 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 (<tt>&lt;mn&gt;</tt> in MathML).
ENumber :: Text -> Exp

-- | A group of expressions that function as a unit (e.g. <tt>{...}</tt>)
--   in TeX, <tt>&lt;mrow&gt;...&lt;/mrow&gt;</tt> 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 (<tt>&lt;mi&gt;...&lt;/mi&gt;</tt> in
--   MathML. Note that MathML tends to use <tt>&lt;mi&gt;</tt> tags for
--   "sin" and other mathematical operators; these are represented as
--   <a>EMathOperator</a> in TeXMath.
EIdentifier :: Text -> Exp

-- | A spelled-out operator like <tt>lim</tt> or <tt>sin</tt>.
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
--   <tt>EOver</tt>.
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 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 <a>DisplayType</a>
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 <a>in the
--   specification</a>
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
--   &lt;<a>http://milde.users.sourceforge.net/LUCR/Math/data/unimathsymbols.txt</a>
--   here&gt;
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

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

-- | Contains <tt>amsmath</tt> and <tt>amssymbol</tt>
defaultEnv :: [Text]

-- | An <tt>EDelimited</tt> element contains a string of ordinary
--   expressions (represented here as <tt>Right</tt> values) or fences
--   (represented here as <tt>Left</tt>, and in LaTeX using <tt>mid</tt>).
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.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.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.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.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.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 <tt>empty</tt>.
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 <a>here</a>
module Text.TeXMath.Readers.MathML.MMLDict

-- | Tries to find the <a>Operator</a> 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

-- | <a>Adobe Symbol</a>
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 <a>toUnicodeChar</a>: returns the corresponding
--   unstyled character and <a>TextType</a> of a unicode character.
fromUnicodeChar :: Char -> Maybe (TextType, Char)
toUnicodeChar :: (TextType, Char) -> Maybe Char

-- | Inverse of <a>toUnicode</a>.
fromUnicode :: TextType -> Text -> Text

-- | Replace characters with their corresponding mathvariant unicode
--   character. MathML has a mathvariant attribute which is unimplemented
--   in Firefox (see <a>here</a>) 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
--   <a>here</a>
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 <a>Exp</a>s.
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 <a>Exp</a>.
readTeX :: Text -> Either Text [Exp]


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

-- | Parse a MathML expression to a list of <a>Exp</a>.
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 <a>Pandoc</a> inlines.
writePandoc :: DisplayType -> [Exp] -> Maybe [Inline]

module Text.TeXMath.Writers.TeX

-- | Transforms an expression tree to equivalent LaTeX with the default
--   packages (amsmath and amssymb)
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.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 <tt>writeLaTeX . readLaTeX /= id</tt>.
--   
--   A typical use is to combine together a reader and writer.
--   
--   <pre>
--   import Control.Applicative ((&lt;$&gt;))
--   import Data.Text (Text)
--   import Text.TeXMath (writeMathML, readTeX)
--   
--   texMathToMathML :: DisplayType -&gt; Text -&gt; Either Text Element
--   texMathToMathML dt s = writeMathML dt &lt;$&gt; readTeX s
--   </pre>
--   
--   It is also possible to manipulate the AST using <a>Generics</a>. 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.
--   
--   <pre>
--   {-# LANGUAGE OverloadedStrings -#}
--   
--   import Control.Applicative ((&lt;$&gt;))
--   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 -&gt; Exp
--   changeIdent (EIdentifier "x") = EIdentifier "y"
--   changeIdent e = e
--   
--   texToMMLWithChangeIdent :: DisplayType -&gt; Text -&gt; Either Text Element
--   texToMMLWithChangeIdent dt s =
--     writeMathML dt . everywhere (mkT changeIdent) &lt;$&gt; readTeX s
--   </pre>
module Text.TeXMath

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

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

-- | Transforms an expression tree to equivalent LaTeX with the default
--   packages (amsmath and amssymb)
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

-- | 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 <a>Pandoc</a> inlines.
writePandoc :: DisplayType -> [Exp] -> Maybe [Inline]
data DisplayType

-- | A displayed formula.
DisplayBlock :: DisplayType

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