packages feed

texmath 0.2.0.3 → 0.2.0.4

raw patch · 28 files changed

+1128/−57 lines, 28 filesdep ~parsecbuild-type:Customsetup-changed

Dependency ranges changed: parsec

Files

Setup.hs view
@@ -1,2 +1,7 @@ import Distribution.Simple-main = defaultMain+import System.Process (system)+import System.Exit++main = defaultMainWithHooks $ simpleUserHooks { runTests  = runTestSuite }++runTestSuite _ _ _ _ = system "cd tests && ./runtests.sh" >>= exitWith
Text/TeXMath/MathMLWriter.hs view
@@ -93,10 +93,7 @@   ]  showBinom :: [Element] -> Element-showBinom lst = mrow [ (withAttribute "stretchy" "true" $ unode "mo" "(")-                     , unode "mtable" $ map (unode "mtr" . unode "mtd") lst-                     , (withAttribute "stretchy" "true" $ unode "mo" ")")-                     ]+showBinom lst = unode "mfenced" $ withAttribute "linethickness" "0" $ unode "mfrac" lst  showBinary :: String -> Exp -> Exp -> Element showBinary c x y =
Text/TeXMath/Parser.hs view
@@ -23,7 +23,7 @@ where  import Control.Monad-import Data.Char (isAlphaNum)+import Data.Char (isAlphaNum, isDigit) import qualified Data.Map as M import Text.ParserCombinators.Parsec import qualified Text.ParserCombinators.Parsec.Token as P@@ -99,11 +99,22 @@   return f  expr :: GenParser Char st Exp-expr = subSup <|> superOrSubscripted <|> expr1+expr = do+  a <- expr1+  limits <- option False (try $ symbol "\\limits" >> return True)+  subSup limits a <|> superOrSubscripted limits a <|> return a  inbraces :: GenParser Char st Exp inbraces = liftM EGrouped (braces $ many $ notFollowedBy (char '}') >> expr) +texToken :: GenParser Char st Exp+texToken = inbraces <|> inbrackets <|>+             do c <- anyChar+                spaces+                return $ if isDigit c+                            then (ENumber [c])+                            else (EIdentifier [c])+ inbrackets :: GenParser Char st Exp inbrackets = liftM EGrouped (brackets $ many $ notFollowedBy (char ']') >> expr) @@ -118,16 +129,16 @@  left :: GenParser Char st Exp left = try $ do-  try (symbol "\\left")-  enc <- basicEnclosure <|> (symbol "." >> return (ESymbol Open "\xFEFF"))+  symbol "\\left"+  enc <- basicEnclosure <|> (try (symbol ".") >> return (ESymbol Open "\xFEFF"))   case enc of     (ESymbol Open _) -> tilRight enc <|> return (EStretchy enc)     _ -> pzero  right :: GenParser Char st Exp right = try $ do-  try (symbol "\\right")-  enc <- basicEnclosure <|> (symbol "." >> return (ESymbol Open "\xFEFF"))+  symbol "\\right"+  enc <- basicEnclosure <|> (try (symbol ".") >> return (ESymbol Close "\xFEFF"))   case enc of     (ESymbol Close x) -> return (EStretchy $ ESymbol Open x)     _ -> pzero@@ -149,12 +160,18 @@        Just  r -> liftM (EScaled r . EStretchy) basicEnclosure        Nothing -> pzero  +endLine :: GenParser Char st Char+endLine = try $ do+  symbol "\\\\"+  optional inbrackets  -- can contain e.g. [1.0in] for a line height, not yet supported+  return '\n'+ arrayLine :: GenParser Char st ArrayLine arrayLine = notFollowedBy (try $ char '\\' >> symbol "end" >> return '\n') >>-  sepBy1 (many (notFollowedBy (try $ char '\\' >> char '\\') >> expr)) (symbol "&")+  sepBy1 (many (notFollowedBy endLine >> expr)) (symbol "&")  array :: GenParser Char st Exp-array = stdarray <|> eqnarray <|> cases <|> matrix+array = stdarray <|> eqnarray <|> align <|> cases <|> matrix  matrix :: GenParser Char st Exp matrix =  matrixWith "pmatrix" "(" ")"@@ -167,24 +184,29 @@ matrixWith keywd opendelim closedelim =   inEnvironment keywd $ do     aligns <- option [] arrayAlignments-    lines' <- sepEndBy1 arrayLine (try $ symbol "\\\\")-    return $ EGrouped [ ESymbol Open opendelim+    lines' <- sepEndBy1 arrayLine endLine+    return $ EGrouped [ EStretchy (ESymbol Open opendelim)                       , EArray aligns lines'-                      , ESymbol Close closedelim]+                      , EStretchy (ESymbol Close closedelim)]  stdarray :: GenParser Char st Exp stdarray = inEnvironment "array" $ do   aligns <- option [] arrayAlignments-  liftM (EArray aligns) $ sepEndBy1 arrayLine (try $ symbol "\\\\")+  liftM (EArray aligns) $ sepEndBy1 arrayLine endLine  eqnarray :: GenParser Char st Exp eqnarray = inEnvironment "eqnarray" $   liftM (EArray [AlignRight, AlignCenter, AlignLeft]) $-    sepEndBy1 arrayLine (try $ symbol "\\\\")+    sepEndBy1 arrayLine endLine +align :: GenParser Char st Exp+align = inEnvironment "align" $+  liftM (EArray [AlignRight, AlignLeft]) $+    sepEndBy1 arrayLine endLine+ cases :: GenParser Char st Exp cases = inEnvironment "cases" $ do-  rs <- sepEndBy1 arrayLine (try $ symbol "\\\\")+  rs <- sepEndBy1 arrayLine endLine   return $ EGrouped [EStretchy (ESymbol Open "{"), EArray [] rs]  arrayAlignments :: GenParser Char st [Alignment]@@ -215,23 +237,27 @@   spaces   return $ EIdentifier [v] -subSup :: GenParser Char st Exp-subSup = try $ do-  a <- expr1+subSup :: Bool -> Exp -> GenParser Char st Exp+subSup limits a = try $ do   char '_'   b <- expr1   char '^'   c <- expr-  return $ ESubsup a b c +  return $ if limits+              then EUnderover a b c+              else ESubsup a b c  -superOrSubscripted :: GenParser Char st Exp-superOrSubscripted = try $ do-  a <- expr1+superOrSubscripted :: Bool -> Exp -> GenParser Char st Exp+superOrSubscripted limits a = try $ do   c <- oneOf "^_"   b <- expr   case c of-       '^' -> return $ ESuper a b-       '_' -> return $ ESub a b+       '^' -> return $ if limits+                          then EOver a b+                          else ESuper a b+       '_' -> return $ if limits+                          then EUnder a b+                          else ESub a b        _   -> pzero   escaped :: GenParser Char st Exp@@ -248,6 +274,7 @@ textOps :: M.Map String (String -> Exp) textOps = M.fromList           [ ("\\textrm", EText "normal")+          , ("\\mathrm", EText "normal")           , ("\\text",   EText "normal")           , ("\\mbox",   EText "normal")           , ("\\mathbf", EText "bold")@@ -257,8 +284,8 @@           , ("\\mathtt", EText "monospace")           , ("\\texttt", EText "monospace")           , ("\\mathsf", EText "sans-serif")-          , ("\\mathbb", EText "double-struck")-          , ("\\mathcal", EText "script")+          , ("\\mathbb", \e -> maybe (EText "double-struck" e) (ESymbol Pun) (M.lookup e mathbb))+          , ("\\mathcal", \e -> maybe (EText "script" e) (ESymbol Pun) (M.lookup e mathcal))           , ("\\mathfrak", EText "fraktur")           ] @@ -266,7 +293,7 @@ diacritical = try $ do   c <- command   case M.lookup c diacriticals of-       Just r  -> liftM r inbraces+       Just r  -> liftM r texToken        Nothing -> pzero   diacriticals :: M.Map String (Exp -> Exp)@@ -298,7 +325,7 @@ unary = try $ do   c <- command   unless (c `elem` unaryOps) pzero -  a <- inbraces+  a <- texToken   return $ EUnary c a  text :: GenParser Char st Exp@@ -313,15 +340,15 @@ root = try $ do   try (symbol "\\sqrt") <|> symbol "\\surd"   a <- inbrackets-  b <- inbraces+  b <- texToken   return $ EBinary "\\sqrt" b a  binary :: GenParser Char st Exp binary = try $ do   c <- command   unless (c `elem` binaryOps) pzero -  a <- inbraces-  b <- inbraces+  a <- texToken+  b <- texToken   return $ EBinary c a b  texSymbol :: GenParser Char st Exp@@ -366,6 +393,14 @@           , ("\\Bigg", "2.9")           , ("\\big", "1.2")           , ("\\Big", "1.6")+          , ("\\biggr", "2.2")+          , ("\\Biggr", "2.9")+          , ("\\bigr", "1.2")+          , ("\\Bigr", "1.6")+          , ("\\biggl", "2.2")+          , ("\\Biggl", "2.9")+          , ("\\bigl", "1.2")+          , ("\\Bigl", "1.6")           ]  enclosures :: [(String, Exp)]@@ -381,8 +416,8 @@              , ("\\rbrace", ESymbol Close "}")              , ("\\llbracket", ESymbol Open "\x27E6")              , ("\\rrbracket", ESymbol Close "\x230B")-             , ("\\langle", ESymbol Open "\x3009")-             , ("\\rangle", ESymbol Close "\x300A")+             , ("\\langle", ESymbol Open "\x27E8")+             , ("\\rangle", ESymbol Close "\x27E9")              , ("\\lfloor", ESymbol Open "\x230A")              , ("\\rfloor", ESymbol Close "\x230B")              , ("\\lceil", ESymbol Open "\x2308")@@ -591,6 +626,8 @@            , ("\\bigodot", ESymbol Op "\x2A00")            , ("\\biguplus", ESymbol Op "\x2A04")            , ("\\int", ESymbol Op "\x222B")+           , ("\\iint", ESymbol Op "\x222C")+           , ("\\iiint", ESymbol Op "\x222D")            , ("\\oint", ESymbol Op "\x222E")            , ("\\prime", ESymbol Ord "\x2032")            , ("\\dots", ESymbol Ord "\x2026")@@ -664,3 +701,130 @@            , ("\\tanh", EMathOperator "tanh")            ]  +-- MathML has a mathvariant attribute which is unimplemented in Firefox+--    (see https://bugzilla.mozilla.org/show_bug.cgi?id=114365)+-- Therefore, we translate mathcal to unicode symbols directly.+-- This list is from http://www.w3.org/TR/MathML2/script.html+mathcal :: M.Map String String+mathcal = M.fromList [+             ("A", "\x1D49C")+           , ("B", "\x0212C")+           , ("C", "\x1D49E")+           , ("D", "\x1D49F")+           , ("E", "\x02130")+           , ("F", "\x02131")+           , ("G", "\x1D4A2")+           , ("H", "\x0210B")+           , ("I", "\x02110")+           , ("J", "\x1D4A5")+           , ("K", "\x1D4A6")+           , ("L", "\x02112")+           , ("M", "\x02133")+           , ("N", "\x1D4A9")+           , ("O", "\x1D4AA")+           , ("P", "\x1D4AB")+           , ("Q", "\x1D4AC")+           , ("R", "\x0211B")+           , ("S", "\x1D4AE")+           , ("T", "\x1D4AF")+           , ("U", "\x1D4B0")+           , ("V", "\x1D4B1")+           , ("W", "\x1D4B2")+           , ("X", "\x1D4B3")+           , ("Y", "\x1D4B4")+           , ("Z", "\x1D4B5")+           , ("a", "\x1D4B6")+           , ("b", "\x1D4B7")+           , ("c", "\x1D4B8")+           , ("d", "\x1D4B9")+           , ("e", "\x0212F")+           , ("f", "\x1D4BB")+           , ("g", "\x0210A")+           , ("h", "\x1D4BD")+           , ("i", "\x1D4BE")+           , ("j", "\x1D4BF")+           , ("k", "\x1D4C0")+           , ("l", "\x1D4C1")+           , ("m", "\x1D4C2")+           , ("n", "\x1D4C3")+           , ("o", "\x02134")+           , ("p", "\x1D4C5")+           , ("q", "\x1D4C6")+           , ("r", "\x1D4C7")+           , ("s", "\x1D4C8")+           , ("t", "\x1D4C9")+           , ("u", "\x1D4CA")+           , ("v", "\x1D4CB")+           , ("w", "\x1D4CC")+           , ("x", "\x1D4CD")+           , ("y", "\x1D4CE")+           , ("z", "\x1D4CF")+           ]++-- Similar to mathcal above, we translate manually.+-- This list is from http://www.w3.org/TR/MathML2/double-struck.html+mathbb :: M.Map String String+mathbb = M.fromList [+             ("A", "\x1D538")+           , ("B", "\x1D539")+           , ("C", "\x02102")+           , ("D", "\x1D53B")+           , ("E", "\x1D53C")+           , ("F", "\x1D53D")+           , ("G", "\x1D53E")+           , ("H", "\x0210D")+           , ("I", "\x1D540")+           , ("J", "\x1D541")+           , ("K", "\x1D542")+           , ("L", "\x1D543")+           , ("M", "\x1D544")+           , ("N", "\x02115")+           , ("O", "\x1D546")+           , ("P", "\x02119")+           , ("Q", "\x0211A")+           , ("R", "\x0211D")+           , ("S", "\x1D54A")+           , ("T", "\x1D54B")+           , ("U", "\x1D54C")+           , ("V", "\x1D54D")+           , ("W", "\x1D54E")+           , ("X", "\x1D54F")+           , ("Y", "\x1D550")+           , ("Z", "\x02124")+           , ("a", "\x1D552")+           , ("b", "\x1D553")+           , ("c", "\x1D554")+           , ("d", "\x1D555")+           , ("e", "\x1D556")+           , ("f", "\x1D557")+           , ("g", "\x1D558")+           , ("h", "\x1D559")+           , ("i", "\x1D55A")+           , ("j", "\x1D55B")+           , ("k", "\x1D55C")+           , ("l", "\x1D55D")+           , ("m", "\x1D55E")+           , ("n", "\x1D55F")+           , ("o", "\x1D560")+           , ("p", "\x1D561")+           , ("q", "\x1D562")+           , ("r", "\x1D563")+           , ("s", "\x1D564")+           , ("t", "\x1D565")+           , ("u", "\x1D566")+           , ("v", "\x1D567")+           , ("w", "\x1D568")+           , ("x", "\x1D569")+           , ("y", "\x1D56A")+           , ("z", "\x1D56B")+           , ("0", "\x1D7D8")+           , ("1", "\x1D7D9")+           , ("2", "\x1D7DA")+           , ("3", "\x1D7DB")+           , ("4", "\x1D7DC")+           , ("5", "\x1D7DD")+           , ("6", "\x1D7DE")+           , ("7", "\x1D7DF")+           , ("8", "\x1D7E0")+           , ("9", "\x1D7E1")+           ]
tests/19.xhtml view
@@ -7,7 +7,7 @@     <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">       <mrow>         <mrow>-          <mo stretchy="false">[</mo>+          <mo stretchy="true">[</mo>           <mtable>             <mtr>               <mtd>@@ -99,10 +99,10 @@               </mtd>             </mtr>           </mtable>-          <mo stretchy="false">]</mo>+          <mo stretchy="true">]</mo>         </mrow>         <mrow>-          <mo stretchy="false">(</mo>+          <mo stretchy="true">(</mo>           <mtable>             <mtr>               <mtd>@@ -121,10 +121,10 @@               </mtd>             </mtr>           </mtable>-          <mo stretchy="false">)</mo>+          <mo stretchy="true">)</mo>         </mrow>         <mrow>-          <mo stretchy="false">{</mo>+          <mo stretchy="true">{</mo>           <mtable>             <mtr>               <mtd>@@ -143,10 +143,10 @@               </mtd>             </mtr>           </mtable>-          <mo stretchy="false">}</mo>+          <mo stretchy="true">}</mo>         </mrow>         <mrow>-          <mo stretchy="false">&#8739;</mo>+          <mo stretchy="true">&#8739;</mo>           <mtable>             <mtr>               <mtd>@@ -165,10 +165,10 @@               </mtd>             </mtr>           </mtable>-          <mo stretchy="false">&#8739;</mo>+          <mo stretchy="true">&#8739;</mo>         </mrow>         <mrow>-          <mo stretchy="false">&#8741;</mo>+          <mo stretchy="true">&#8741;</mo>           <mtable>             <mtr>               <mtd>@@ -187,7 +187,7 @@               </mtd>             </mtr>           </mtable>-          <mo stretchy="false">&#8741;</mo>+          <mo stretchy="true">&#8741;</mo>         </mrow>       </mrow>     </math>
+ tests/axiom_of_power_set.tex view
@@ -0,0 +1,1 @@+   \forall A \, \exists P \, \forall B \, [B \in P \iff \forall C \, (C \in B \Rightarrow C \in A)]
+ tests/axiom_of_power_set.xhtml view
@@ -0,0 +1,39 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <mo>&#8704;</mo>+        <mi>A</mi>+        <mspace width="0.167em" />+        <mo>&#8707;</mo>+        <mi>P</mi>+        <mspace width="0.167em" />+        <mo>&#8704;</mo>+        <mi>B</mi>+        <mspace width="0.167em" />+        <mo stretchy="false">[</mo>+        <mi>B</mi>+        <mo>&#8712;</mo>+        <mi>P</mi>+        <mo>&#8660;</mo>+        <mo>&#8704;</mo>+        <mi>C</mi>+        <mspace width="0.167em" />+        <mo stretchy="false">(</mo>+        <mi>C</mi>+        <mo>&#8712;</mo>+        <mi>B</mi>+        <mo>&#8658;</mo>+        <mi>C</mi>+        <mo>&#8712;</mo>+        <mi>A</mi>+        <mo stretchy="false">)</mo>+        <mo stretchy="false">]</mo>+      </mrow>+    </math>+  </body>+</html>
+ tests/binomial_coefficient.tex view
@@ -0,0 +1,1 @@+   \mathbf{C}(n,k) = \mathbf{C}_k^n = {}_n\mathbf{C}_k = \binom{n}{k} = \frac{n!}{k!\,(n -k)!}
+ tests/binomial_coefficient.xhtml view
@@ -0,0 +1,58 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <mtext mathvariant="bold">C</mtext>+        <mo stretchy="false">(</mo>+        <mi>n</mi>+        <mo>,</mo>+        <mi>k</mi>+        <mo stretchy="false">)</mo>+        <mo>=</mo>+        <msubsup>+          <mtext mathvariant="bold">C</mtext>+          <mi>k</mi>+          <mi>n</mi>+        </msubsup>+        <mo>=</mo>+        <msub>+          <mrow />+          <mi>n</mi>+        </msub>+        <msub>+          <mtext mathvariant="bold">C</mtext>+          <mi>k</mi>+        </msub>+        <mo>=</mo>+        <mfenced>+          <mfrac linethickness="0">+            <mi>n</mi>+            <mi>k</mi>+          </mfrac>+        </mfenced>+        <mo>=</mo>+        <mfrac>+          <mrow>+            <mi>n</mi>+            <mo>!</mo>+          </mrow>+          <mrow>+            <mi>k</mi>+            <mo>!</mo>+            <mspace width="0.167em" />+            <mo stretchy="false">(</mo>+            <mi>n</mi>+            <mo>-</mo>+            <mi>k</mi>+            <mo stretchy="false">)</mo>+            <mo>!</mo>+          </mrow>+        </mfrac>+      </mrow>+    </math>+  </body>+</html>
+ tests/complex_number.tex view
@@ -0,0 +1,5 @@+ c = \overbrace+     { \underbrace{a}_\text{real}+       ++       \underbrace{b\mathrm{i}}_\text{imaginary}+     }^\text{complex number}
+ tests/complex_number.xhtml view
@@ -0,0 +1,40 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <mi>c</mi>+        <mo>=</mo>+        <mover>+          <mover>+            <mrow>+              <munder>+                <munder>+                  <mi>a</mi>+                  <mo accent="true">&#65080;</mo>+                </munder>+                <mtext mathvariant="normal">real</mtext>+              </munder>+              <mo>+</mo>+              <munder>+                <munder>+                  <mrow>+                    <mi>b</mi>+                    <mtext mathvariant="normal">i</mtext>+                  </mrow>+                  <mo accent="true">&#65080;</mo>+                </munder>+                <mtext mathvariant="normal">imaginary</mtext>+              </munder>+            </mrow>+            <mo accent="true">&#65079;</mo>+          </mover>+          <mtext mathvariant="normal">complex number</mtext>+        </mover>+      </mrow>+    </math>+  </body>+</html>
+ tests/deMorgans_law.tex view
@@ -0,0 +1,2 @@+  \neg(p\wedge q)\iff(\neg p)\vee(\neg q)+  \overline{\bigcup_{i=1}^{n} A_{i}}=\bigcap_{i=1}^{n} \overline{A_{i}}
+ tests/deMorgans_law.xhtml view
@@ -0,0 +1,63 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <mo>&#172;</mo>+        <mo stretchy="false">(</mo>+        <mi>p</mi>+        <mo>&#8743;</mo>+        <mi>q</mi>+        <mo stretchy="false">)</mo>+        <mo>&#8660;</mo>+        <mo stretchy="false">(</mo>+        <mo>&#172;</mo>+        <mi>p</mi>+        <mo stretchy="false">)</mo>+        <mo>&#8744;</mo>+        <mo stretchy="false">(</mo>+        <mo>&#172;</mo>+        <mi>q</mi>+        <mo stretchy="false">)</mo>+        <mover>+          <mrow>+            <munderover>+              <mo>&#8899;</mo>+              <mrow>+                <mi>i</mi>+                <mo>=</mo>+                <mn>1</mn>+              </mrow>+              <mi>n</mi>+            </munderover>+            <msub>+              <mi>A</mi>+              <mi>i</mi>+            </msub>+          </mrow>+          <mo accent="true">&#175;</mo>+        </mover>+        <mo>=</mo>+        <munderover>+          <mo>&#8898;</mo>+          <mrow>+            <mi>i</mi>+            <mo>=</mo>+            <mn>1</mn>+          </mrow>+          <mi>n</mi>+        </munderover>+        <mover>+          <msub>+            <mi>A</mi>+            <mi>i</mi>+          </msub>+          <mo accent="true">&#175;</mo>+        </mover>+      </mrow>+    </math>+  </body>+</html>
+ tests/differentiable_manifold.tex view
@@ -0,0 +1,3 @@+   \gamma_1\equiv \gamma_2 \iff \left\{ \begin{array}{l} \gamma_1(0)=\gamma_2(0)=p, \text{ and }\\ [1.0ex]+   \left.\frac{\mathrm{d}}{\mathrm{d}t}\phi\circ\gamma_1(t)\right|_{t=0} = \left.\frac{\mathrm{d}}{\mathrm{d}t}\phi\circ\gamma_2(t)\right|_{t=0}+   \end{array} \right.
+ tests/differentiable_manifold.xhtml view
@@ -0,0 +1,111 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <msub>+          <mo>&#947;</mo>+          <mn>1</mn>+        </msub>+        <mo>&#8801;</mo>+        <msub>+          <mo>&#947;</mo>+          <mn>2</mn>+        </msub>+        <mo>&#8660;</mo>+        <mo stretchy="true">{</mo>+        <mtable>+          <mtr>+            <mtd columnalign="left">+              <msub>+                <mo>&#947;</mo>+                <mn>1</mn>+              </msub>+              <mo stretchy="false">(</mo>+              <mn>0</mn>+              <mo stretchy="false">)</mo>+              <mo>=</mo>+              <msub>+                <mo>&#947;</mo>+                <mn>2</mn>+              </msub>+              <mo stretchy="false">(</mo>+              <mn>0</mn>+              <mo stretchy="false">)</mo>+              <mo>=</mo>+              <mi>p</mi>+              <mo>,</mo>+              <mrow>+                <mtext mathvariant="normal">and </mtext>+                <mspace width="0.333em" />+              </mrow>+            </mtd>+          </mtr>+          <mtr>+            <mtd columnalign="left">+              <msub>+                <mrow>+                  <mo stretchy="true">&#65279;</mo>+                  <mfrac>+                    <mtext mathvariant="normal">d</mtext>+                    <mrow>+                      <mtext mathvariant="normal">d</mtext>+                      <mi>t</mi>+                    </mrow>+                  </mfrac>+                  <mo>&#966;</mo>+                  <mo>&#8728;</mo>+                  <msub>+                    <mo>&#947;</mo>+                    <mn>1</mn>+                  </msub>+                  <mo stretchy="false">(</mo>+                  <mi>t</mi>+                  <mo stretchy="false">)</mo>+                  <mo stretchy="true">&#8739;</mo>+                </mrow>+                <mrow>+                  <mi>t</mi>+                  <mo>=</mo>+                  <mn>0</mn>+                </mrow>+              </msub>+              <mo>=</mo>+              <msub>+                <mrow>+                  <mo stretchy="true">&#65279;</mo>+                  <mfrac>+                    <mtext mathvariant="normal">d</mtext>+                    <mrow>+                      <mtext mathvariant="normal">d</mtext>+                      <mi>t</mi>+                    </mrow>+                  </mfrac>+                  <mo>&#966;</mo>+                  <mo>&#8728;</mo>+                  <msub>+                    <mo>&#947;</mo>+                    <mn>2</mn>+                  </msub>+                  <mo stretchy="false">(</mo>+                  <mi>t</mi>+                  <mo stretchy="false">)</mo>+                  <mo stretchy="true">&#8739;</mo>+                </mrow>+                <mrow>+                  <mi>t</mi>+                  <mo>=</mo>+                  <mn>0</mn>+                </mrow>+              </msub>+            </mtd>+          </mtr>+        </mtable>+        <mo stretchy="true">&#65279;</mo>+      </mrow>+    </math>+  </body>+</html>
+ tests/divergence.tex view
@@ -0,0 +1,4 @@+   \nabla \cdot \vec{v} =+   \frac{\partial v_x}{\partial x} ++   \frac{\partial v_y}{\partial y} ++   \frac{\partial v_z}{\partial z}
+ tests/divergence.xhtml view
@@ -0,0 +1,60 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <mo>&#8711;</mo>+        <mo>&#8901;</mo>+        <mover>+          <mi>v</mi>+          <mo accent="true">&#8407;</mo>+        </mover>+        <mo>=</mo>+        <mfrac>+          <mrow>+            <mo>&#8706;</mo>+            <msub>+              <mi>v</mi>+              <mi>x</mi>+            </msub>+          </mrow>+          <mrow>+            <mo>&#8706;</mo>+            <mi>x</mi>+          </mrow>+        </mfrac>+        <mo>+</mo>+        <mfrac>+          <mrow>+            <mo>&#8706;</mo>+            <msub>+              <mi>v</mi>+              <mi>y</mi>+            </msub>+          </mrow>+          <mrow>+            <mo>&#8706;</mo>+            <mi>y</mi>+          </mrow>+        </mfrac>+        <mo>+</mo>+        <mfrac>+          <mrow>+            <mo>&#8706;</mo>+            <msub>+              <mi>v</mi>+              <mi>z</mi>+            </msub>+          </mrow>+          <mrow>+            <mo>&#8706;</mo>+            <mi>z</mi>+          </mrow>+        </mfrac>+      </mrow>+    </math>+  </body>+</html>
+ tests/moore_determinant.tex view
@@ -0,0 +1,7 @@+   M =+   \begin{bmatrix}+     \alpha_1 & \alpha_1^q & \cdots & \alpha_1^{q^{n - 1}} \\+     \alpha_2 & \alpha_2^q & \cdots & \alpha_2^{q^{n - 1}} \\+     \vdots   & \vdots     & \ddots & \vdots             \\+     \alpha_m & \alpha_m^q & \cdots & \alpha_m^{q^{n - 1}}+   \end{bmatrix}
+ tests/moore_determinant.xhtml view
@@ -0,0 +1,130 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <mi>M</mi>+        <mo>=</mo>+        <mrow>+          <mo stretchy="true">[</mo>+          <mtable>+            <mtr>+              <mtd>+                <msub>+                  <mo>&#945;</mo>+                  <mn>1</mn>+                </msub>+              </mtd>+              <mtd>+                <msubsup>+                  <mo>&#945;</mo>+                  <mn>1</mn>+                  <mi>q</mi>+                </msubsup>+              </mtd>+              <mtd>+                <mo>&#8943;</mo>+              </mtd>+              <mtd>+                <msubsup>+                  <mo>&#945;</mo>+                  <mn>1</mn>+                  <msup>+                    <mi>q</mi>+                    <mrow>+                      <mi>n</mi>+                      <mo>-</mo>+                      <mn>1</mn>+                    </mrow>+                  </msup>+                </msubsup>+              </mtd>+            </mtr>+            <mtr>+              <mtd>+                <msub>+                  <mo>&#945;</mo>+                  <mn>2</mn>+                </msub>+              </mtd>+              <mtd>+                <msubsup>+                  <mo>&#945;</mo>+                  <mn>2</mn>+                  <mi>q</mi>+                </msubsup>+              </mtd>+              <mtd>+                <mo>&#8943;</mo>+              </mtd>+              <mtd>+                <msubsup>+                  <mo>&#945;</mo>+                  <mn>2</mn>+                  <msup>+                    <mi>q</mi>+                    <mrow>+                      <mi>n</mi>+                      <mo>-</mo>+                      <mn>1</mn>+                    </mrow>+                  </msup>+                </msubsup>+              </mtd>+            </mtr>+            <mtr>+              <mtd>+                <mo>&#8942;</mo>+              </mtd>+              <mtd>+                <mo>&#8942;</mo>+              </mtd>+              <mtd>+                <mo>&#8945;</mo>+              </mtd>+              <mtd>+                <mo>&#8942;</mo>+              </mtd>+            </mtr>+            <mtr>+              <mtd>+                <msub>+                  <mo>&#945;</mo>+                  <mi>m</mi>+                </msub>+              </mtd>+              <mtd>+                <msubsup>+                  <mo>&#945;</mo>+                  <mi>m</mi>+                  <mi>q</mi>+                </msubsup>+              </mtd>+              <mtd>+                <mo>&#8943;</mo>+              </mtd>+              <mtd>+                <msubsup>+                  <mo>&#945;</mo>+                  <mi>m</mi>+                  <msup>+                    <mi>q</mi>+                    <mrow>+                      <mi>n</mi>+                      <mo>-</mo>+                      <mn>1</mn>+                    </mrow>+                  </msup>+                </msubsup>+              </mtd>+            </mtr>+          </mtable>+          <mo stretchy="true">]</mo>+        </mrow>+      </mrow>+    </math>+  </body>+</html>
+ tests/quadratic_formula.tex view
@@ -0,0 +1,1 @@+   x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
+ tests/quadratic_formula.xhtml view
@@ -0,0 +1,37 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <mi>x</mi>+        <mo>=</mo>+        <mfrac>+          <mrow>+            <mo>-</mo>+            <mi>b</mi>+            <mo>&#177;</mo>+            <msqrt>+              <mrow>+                <msup>+                  <mi>b</mi>+                  <mn>2</mn>+                </msup>+                <mo>-</mo>+                <mn>4</mn>+                <mi>a</mi>+                <mi>c</mi>+              </mrow>+            </msqrt>+          </mrow>+          <mrow>+            <mn>2</mn>+            <mi>a</mi>+          </mrow>+        </mfrac>+      </mrow>+    </math>+  </body>+</html>
tests/runtests.sh view
@@ -1,12 +1,20 @@ #!/bin/sh+# Note: this should be run from within the tests directory+# Make sure you've set the 'test' flag using Cabal:+# cabal install -ftest+# Otherwise the test program won't be built.+# Exit status is number of failed tests. TESTPROG=../dist/build/testTeXMathML/testTeXMathML+failures=0 for t in *.tex; do     $TESTPROG <$t >tmp     diff ${t%.tex}.xhtml tmp >tmpdiff     if [ "$?" -ne "0" ]; then         echo "Test ${t%.tex} FAILED (< expected, > actual):"         cat tmpdiff+        let "failures=$failures+1"     else         echo "Test ${t%.tex} PASSED"     fi done+exit $failures
+ tests/schwinger_dyson.tex view
@@ -0,0 +1,1 @@+   \left\langle\psi\left|\mathcal{T}\left\{\frac{\delta}{\delta\phi}F[\phi]\right\}\right|\psi\right\rangle = -\mathrm{i}\left\langle\psi\left|\mathcal{T}\left\{F[\phi]\frac{\delta}{\delta\phi}S[\phi]\right\}\right|\psi\right\rangle
+ tests/schwinger_dyson.xhtml view
@@ -0,0 +1,71 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <mrow>+          <mo stretchy="true">&#10216;</mo>+          <mo>&#968;</mo>+          <mrow>+            <mo stretchy="true">&#8739;</mo>+            <mo>&#119983;</mo>+            <mrow>+              <mo stretchy="true">{</mo>+              <mfrac>+                <mo>&#948;</mo>+                <mrow>+                  <mo>&#948;</mo>+                  <mo>&#966;</mo>+                </mrow>+              </mfrac>+              <mi>F</mi>+              <mo stretchy="false">[</mo>+              <mo>&#966;</mo>+              <mo stretchy="false">]</mo>+              <mo stretchy="true">}</mo>+            </mrow>+            <mo stretchy="true">&#8739;</mo>+          </mrow>+          <mo>&#968;</mo>+          <mo stretchy="true">&#10217;</mo>+        </mrow>+        <mo>=</mo>+        <mo>-</mo>+        <mtext mathvariant="normal">i</mtext>+        <mrow>+          <mo stretchy="true">&#10216;</mo>+          <mo>&#968;</mo>+          <mrow>+            <mo stretchy="true">&#8739;</mo>+            <mo>&#119983;</mo>+            <mrow>+              <mo stretchy="true">{</mo>+              <mi>F</mi>+              <mo stretchy="false">[</mo>+              <mo>&#966;</mo>+              <mo stretchy="false">]</mo>+              <mfrac>+                <mo>&#948;</mo>+                <mrow>+                  <mo>&#948;</mo>+                  <mo>&#966;</mo>+                </mrow>+              </mfrac>+              <mi>S</mi>+              <mo stretchy="false">[</mo>+              <mo>&#966;</mo>+              <mo stretchy="false">]</mo>+              <mo stretchy="true">}</mo>+            </mrow>+            <mo stretchy="true">&#8739;</mo>+          </mrow>+          <mo>&#968;</mo>+          <mo stretchy="true">&#10217;</mo>+        </mrow>+      </mrow>+    </math>+  </body>+</html>
+ tests/sophomores_dream.tex view
@@ -0,0 +1,1 @@+   \int_0^1 x^x\,\mathrm{d}x = \sum_{n = 1}^\infty{(-1)^{n + 1}\,n^{-n}}
+ tests/sophomores_dream.xhtml view
@@ -0,0 +1,55 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <msubsup>+          <mo>&#8747;</mo>+          <mn>0</mn>+          <mn>1</mn>+        </msubsup>+        <msup>+          <mi>x</mi>+          <mi>x</mi>+        </msup>+        <mspace width="0.167em" />+        <mtext mathvariant="normal">d</mtext>+        <mi>x</mi>+        <mo>=</mo>+        <munderover>+          <mo>&#8721;</mo>+          <mrow>+            <mi>n</mi>+            <mo>=</mo>+            <mn>1</mn>+          </mrow>+          <mo>&#8734;</mo>+        </munderover>+        <mrow>+          <mo stretchy="false">(</mo>+          <mo>-</mo>+          <mn>1</mn>+          <msup>+            <mo stretchy="false">)</mo>+            <mrow>+              <mi>n</mi>+              <mo>+</mo>+              <mn>1</mn>+            </mrow>+          </msup>+          <mspace width="0.167em" />+          <msup>+            <mi>n</mi>+            <mrow>+              <mo>-</mo>+              <mi>n</mi>+            </mrow>+          </msup>+        </mrow>+      </mrow>+    </math>+  </body>+</html>
+ tests/sphere_volume.tex view
@@ -0,0 +1,8 @@+S = \{0 \leq \phi \leq 2\pi, \ 0 \leq \theta \leq \pi, \ 0 \leq \rho \leq R\}+\begin{align*}+\mathrm{Volume} &=\iiint\limits_S\! \rho^2 \sin\theta \,\mathrm{d}\rho \,\mathrm{d}\theta \,\mathrm{d}\phi \\+&=\int_0^{2 \pi }\! \mathrm{d}\phi \,\int_0^{ \pi }\! \sin\theta \,\mathrm{d}\theta \,\int_0^R\! \rho^2 \mathrm{d}\rho \\+&=\phi \Bigr|_0^{2\pi}\ (-\cos\theta) \Bigr|_0^{ \pi }\ \tfrac13 \rho^3 \Bigr|_0^R \\+&=2\pi \times 2 \times \tfrac13 R^3 \\+&=\tfrac43 \pi R^3+\end{align*}
+ tests/sphere_volume.xhtml view
@@ -0,0 +1,188 @@+<?xml version='1.0' ?>+<html xmlns="http://www.w3.org/1999/xhtml">+  <head>+    <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />+  </head>+  <body>+    <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">+      <mrow>+        <mi>S</mi>+        <mo>=</mo>+        <mo stretchy="false">{</mo>+        <mn>0</mn>+        <mo>&#8804;</mo>+        <mo>&#966;</mo>+        <mo>&#8804;</mo>+        <mn>2</mn>+        <mo>&#960;</mo>+        <mo>,</mo>+        <mo> </mo>+        <mn>0</mn>+        <mo>&#8804;</mo>+        <mo>&#952;</mo>+        <mo>&#8804;</mo>+        <mo>&#960;</mo>+        <mo>,</mo>+        <mo> </mo>+        <mn>0</mn>+        <mo>&#8804;</mo>+        <mo>&#961;</mo>+        <mo>&#8804;</mo>+        <mi>R</mi>+        <mo stretchy="false">}</mo>+        <mtable>+          <mtr>+            <mtd columnalign="right">+              <mtext mathvariant="normal">Volume</mtext>+            </mtd>+            <mtd columnalign="left">+              <mo>=</mo>+              <munder>+                <mo>&#8749;</mo>+                <mi>S</mi>+              </munder>+              <mspace width="-0.167em" />+              <msup>+                <mo>&#961;</mo>+                <mn>2</mn>+              </msup>+              <mi>sin</mi>+              <mo>&#952;</mo>+              <mspace width="0.167em" />+              <mtext mathvariant="normal">d</mtext>+              <mo>&#961;</mo>+              <mspace width="0.167em" />+              <mtext mathvariant="normal">d</mtext>+              <mo>&#952;</mo>+              <mspace width="0.167em" />+              <mtext mathvariant="normal">d</mtext>+              <mo>&#966;</mo>+            </mtd>+          </mtr>+          <mtr>+            <mtd columnalign="right" />+            <mtd columnalign="left">+              <mo>=</mo>+              <msubsup>+                <mo>&#8747;</mo>+                <mn>0</mn>+                <mrow>+                  <mn>2</mn>+                  <mo>&#960;</mo>+                </mrow>+              </msubsup>+              <mspace width="-0.167em" />+              <mtext mathvariant="normal">d</mtext>+              <mo>&#966;</mo>+              <mspace width="0.167em" />+              <msubsup>+                <mo>&#8747;</mo>+                <mn>0</mn>+                <mo>&#960;</mo>+              </msubsup>+              <mspace width="-0.167em" />+              <mi>sin</mi>+              <mo>&#952;</mo>+              <mspace width="0.167em" />+              <mtext mathvariant="normal">d</mtext>+              <mo>&#952;</mo>+              <mspace width="0.167em" />+              <msubsup>+                <mo>&#8747;</mo>+                <mn>0</mn>+                <mi>R</mi>+              </msubsup>+              <mspace width="-0.167em" />+              <msup>+                <mo>&#961;</mo>+                <mn>2</mn>+              </msup>+              <mtext mathvariant="normal">d</mtext>+              <mo>&#961;</mo>+            </mtd>+          </mtr>+          <mtr>+            <mtd columnalign="right" />+            <mtd columnalign="left">+              <mo>=</mo>+              <mo>&#966;</mo>+              <msubsup>+                <mo minsize="1.6" maxsize="1.6" stretchy="true">&#8739;</mo>+                <mn>0</mn>+                <mrow>+                  <mn>2</mn>+                  <mo>&#960;</mo>+                </mrow>+              </msubsup>+              <mo> </mo>+              <mo stretchy="false">(</mo>+              <mo>-</mo>+              <mi>cos</mi>+              <mo>&#952;</mo>+              <mo stretchy="false">)</mo>+              <msubsup>+                <mo minsize="1.6" maxsize="1.6" stretchy="true">&#8739;</mo>+                <mn>0</mn>+                <mo>&#960;</mo>+              </msubsup>+              <mo> </mo>+              <mstyle displaystyle="false">+                <mfrac>+                  <mn>1</mn>+                  <mn>3</mn>+                </mfrac>+              </mstyle>+              <msup>+                <mo>&#961;</mo>+                <mn>3</mn>+              </msup>+              <msubsup>+                <mo minsize="1.6" maxsize="1.6" stretchy="true">&#8739;</mo>+                <mn>0</mn>+                <mi>R</mi>+              </msubsup>+            </mtd>+          </mtr>+          <mtr>+            <mtd columnalign="right" />+            <mtd columnalign="left">+              <mo>=</mo>+              <mn>2</mn>+              <mo>&#960;</mo>+              <mo>&#215;</mo>+              <mn>2</mn>+              <mo>&#215;</mo>+              <mstyle displaystyle="false">+                <mfrac>+                  <mn>1</mn>+                  <mn>3</mn>+                </mfrac>+              </mstyle>+              <msup>+                <mi>R</mi>+                <mn>3</mn>+              </msup>+            </mtd>+          </mtr>+          <mtr>+            <mtd columnalign="right" />+            <mtd columnalign="left">+              <mo>=</mo>+              <mstyle displaystyle="false">+                <mfrac>+                  <mn>4</mn>+                  <mn>3</mn>+                </mfrac>+              </mstyle>+              <mo>&#960;</mo>+              <msup>+                <mi>R</mi>+                <mn>3</mn>+              </msup>+            </mtd>+          </mtr>+        </mtable>+      </mrow>+    </math>+  </body>+</html>
texmath.cabal view
@@ -1,7 +1,7 @@ Name:                texmath-Version:             0.2.0.3+Version:             0.2.0.4 Cabal-version:       >= 1.2-Build-type:          Simple+Build-type:          Custom Synopsis:            Conversion of LaTeX math formulas to MathML. Description:         The texmathml library provides functions to convert LaTeX                      math formulas to presentation MathML. It supports@@ -33,26 +33,37 @@                      tests/16.tex, tests/16.xhtml,                      tests/17.tex, tests/17.xhtml,                      tests/18.tex, tests/18.xhtml,-                     tests/19.tex, tests/19.xhtml+                     tests/19.tex, tests/19.xhtml,+                     tests/axiom_of_power_set.tex, tests/axiom_of_power_set.xhtml,+                     tests/binomial_coefficient.tex, tests/binomial_coefficient.xhtml,+                     tests/complex_number.tex, tests/complex_number.xhtml,+                     tests/deMorgans_law.tex, tests/deMorgans_law.xhtml,+                     tests/differentiable_manifold.tex, tests/differentiable_manifold.xhtml,+                     tests/divergence.tex, tests/divergence.xhtml,+                     tests/moore_determinant.tex, tests/moore_determinant.xhtml,+                     tests/quadratic_formula.tex, tests/quadratic_formula.xhtml,+                     tests/schwinger_dyson.tex, tests/schwinger_dyson.xhtml,+                     tests/sophomores_dream.tex, tests/sophomores_dream.xhtml,+                     tests/sphere_volume.tex, tests/sphere_volume.xhtml  Flag cgi   description:       Compile cgi executable.-  default:           True+  default:           False  Flag test   description:       Compile test executable.-  default:           True+  default:           False  Library-    Build-depends:       xml, parsec >= 2 && < 3, containers, base >= 3 && < 5+    Build-depends:       xml, parsec >= 2, containers, base >= 3 && < 5     Exposed-modules:     Text.TeXMath, Text.TeXMath.Parser, Text.TeXMath.MathMLWriter -    Ghc-Options:         -Wall+    Ghc-Options:         -Wall -fno-warn-unused-do-bind     Ghc-Prof-Options:    -auto-all  Executable testTeXMathML     Main-is:             testTeXMathML.hs-    Ghc-Options:         -Wall+    Ghc-Options:         -Wall -fno-warn-unused-do-bind     Ghc-Prof-Options:    -auto-all     if flag(test)       Buildable:         True@@ -61,10 +72,10 @@  Executable texmath-cgi     Main-is:             cgi/texmath-cgi.hs-    Build-depends:       cgi, json-    Ghc-Options:         -Wall+    Ghc-Options:         -Wall -fno-warn-unused-do-bind     Ghc-Prof-Options:    -auto-all     if flag(cgi)       Buildable:         True+      Build-depends:     cgi, json     else       Buildable:         False