texmath-0.6.5.2/0000755000000000000000000000000012236473702011530 5ustar0000000000000000texmath-0.6.5.2/LICENSE0000644000000000000000000004316012236473702012541 0ustar0000000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. texmath-0.6.5.2/Setup.hs0000644000000000000000000000034212236473702013163 0ustar0000000000000000import Distribution.Simple import System.Process (system) import System.Exit main = defaultMainWithHooks $ simpleUserHooks { runTests = runTestSuite } runTestSuite _ _ _ _ = system "cd tests && sh runtests.sh" >>= exitWith texmath-0.6.5.2/texmath.cabal0000644000000000000000000001367512236473702014202 0ustar0000000000000000Name: texmath Version: 0.6.5.2 Cabal-Version: >= 1.6 Build-type: Custom Synopsis: Conversion of LaTeX math formulas to MathML or OMML. Description: The texmathml library provides functions to convert LaTeX math formulas to presentation MathML (which can be used in HTML) or OMML (Office Math Markup Language, used in Microsoft Office). It supports basic LaTeX and AMS extensions, and it can parse and apply LaTeX macros. . Use the @test@ flag to install a standalone executable, @texmath@, that reads a LaTeX formula from @stdin@ and writes MathML to @stdout@. . Use the @cgi@ flag to install a cgi script, @texmath-cgi@. Category: Text Stability: Experimental License: GPL License-File: LICENSE Author: John MacFarlane Maintainer: jgm@berkeley.edu Homepage: http://github.com/jgm/texmath Data-Files: cgi/texmath.xhtml, tests/runtests.sh, tests/01.tex, tests/01.xhtml, tests/01.omml, tests/02.tex, tests/02.xhtml, tests/02.omml, tests/03.tex, tests/03.xhtml, tests/03.omml, tests/04.tex, tests/04.xhtml, tests/04.omml, tests/05.tex, tests/05.xhtml, tests/05.omml, tests/06.tex, tests/06.xhtml, tests/06.omml, tests/07.tex, tests/07.xhtml, tests/07.omml, tests/08.tex, tests/08.xhtml, tests/08.omml, tests/09.tex, tests/09.xhtml, tests/09.omml, tests/10.tex, tests/10.xhtml, tests/10.omml, tests/11.tex, tests/11.xhtml, tests/11.omml, tests/12.tex, tests/12.xhtml, tests/12.omml, tests/13.tex, tests/13.xhtml, tests/13.omml, tests/14.tex, tests/14.xhtml, tests/14.omml, tests/15.tex, tests/15.xhtml, tests/15.omml, tests/16.tex, tests/16.xhtml, tests/16.omml, tests/17.tex, tests/17.xhtml, tests/17.omml, tests/18.tex, tests/18.xhtml, tests/18.omml, tests/19.tex, tests/19.xhtml, tests/19.omml, tests/20.tex, tests/20.xhtml, tests/20.omml, tests/21.tex, tests/21.xhtml, tests/21.omml, tests/22.tex, tests/22.xhtml, tests/22.omml, tests/axiom_of_power_set.tex, tests/axiom_of_power_set.xhtml, tests/axiom_of_power_set.omml, tests/binomial_coefficient.tex, tests/binomial_coefficient.xhtml, tests/binomial_coefficient.omml, tests/complex_number.tex, tests/complex_number.xhtml, tests/complex_number.omml, tests/deMorgans_law.tex, tests/deMorgans_law.xhtml, tests/deMorgans_law.omml, tests/differentiable_manifold.tex, tests/differentiable_manifold.xhtml, tests/differentiable_manifold.omml, tests/divergence.tex, tests/divergence.xhtml, tests/divergence.omml, tests/moore_determinant.tex, tests/moore_determinant.xhtml, tests/moore_determinant.omml, tests/quadratic_formula.tex, tests/quadratic_formula.xhtml, tests/quadratic_formula.omml, tests/schwinger_dyson.tex, tests/schwinger_dyson.xhtml, tests/schwinger_dyson.omml, tests/sophomores_dream.tex, tests/sophomores_dream.xhtml, tests/sophomores_dream.omml, tests/sphere_volume.tex, tests/sphere_volume.xhtml, tests/sphere_volume.omml, tests/unicode.tex, tests/unicode.xhtml, tests/unicode.omml, tests/ensuremath.tex, tests/ensuremath.xhtml, tests/ensuremath.omml, tests/macros.tex, tests/macros.xhtml, tests/macros.omml, tests/subsup.tex, tests/subsup.xhtml, tests/subsup.omml, tests/stackrel.tex, tests/stackrel.xhtml, tests/stackrel.omml, tests/notin.tex, tests/notin.xhtml, tests/notin.omml, tests/labels.tex, tests/labels.xhtml, tests/labels.omml Source-repository head type: git location: git://github.com/jgm/texmath.git Flag cgi description: Compile cgi executable. default: False Flag test description: Compile test executable. default: False Library Build-depends: xml, parsec >= 3, containers, pandoc-types if impl(ghc >= 6.10) Build-depends: base >= 4 && < 5, syb else Build-depends: base >= 3 && < 4 Exposed-modules: Text.TeXMath Text.TeXMath.Types Text.TeXMath.Parser Text.TeXMath.MathML Text.TeXMath.OMML Text.TeXMath.Pandoc Text.TeXMath.Macros Text.TeXMath.ToUnicode if impl(ghc >= 6.12) Ghc-Options: -Wall -fno-warn-unused-do-bind else Ghc-Options: -Wall Ghc-Prof-Options: -auto-all -caf-all Executable texmath Main-is: texmath.hs if impl(ghc >= 6.12) Ghc-Options: -Wall -fno-warn-unused-do-bind else Ghc-Options: -Wall Ghc-Prof-Options: -auto-all -caf-all if flag(test) Buildable: True else Buildable: False Executable texmath-cgi Main-is: cgi/texmath-cgi.hs if impl(ghc >= 6.12) Ghc-Options: -Wall -fno-warn-unused-do-bind else Ghc-Options: -Wall Ghc-Prof-Options: -auto-all -caf-all if flag(cgi) Buildable: True Build-depends: cgi, json, utf8-string else Buildable: False texmath-0.6.5.2/texmath.hs0000644000000000000000000000260012236473702013534 0ustar0000000000000000{-# LANGUAGE CPP #-} module Main where import Text.TeXMath import Text.TeXMath.Parser (parseFormula) import Text.XML.Light import Text.TeXMath.Macros import System.IO import System.Environment inHtml :: Either String Element -> Either String Element inHtml (Left x) = Left x inHtml (Right x) = Right $ add_attr (Attr (unqual "xmlns") "http://www.w3.org/1999/xhtml") $ unode "html" [ unode "head" $ add_attr (Attr (unqual "content") "application/xhtml+xml; charset=UTF-8") $ add_attr (Attr (unqual "http-equiv") "Content-Type") $ unode "meta" () , unode "body" x ] getUTF8Contents :: IO String getUTF8Contents = #if MIN_VERSION_base(4,2,0) hSetEncoding stdin utf8 >> hGetContents stdin #else hGetContents stdin #endif main :: IO () main = do args <- getArgs let dt = if "--inline" `elem` args then DisplayInline else DisplayBlock let converter = if "--omml" `elem` args then fmap ppTopElement . texMathToOMML dt else if "--native" `elem` args then fmap show . parseFormula else fmap ppTopElement . inHtml . texMathToMathML dt inp <- getUTF8Contents let (ms, rest) = parseMacroDefinitions inp case (converter $! applyMacros ms rest) of Left err -> hPutStrLn stderr err Right v -> putStr v texmath-0.6.5.2/cgi/0000755000000000000000000000000012236473702012272 5ustar0000000000000000texmath-0.6.5.2/cgi/texmath-cgi.hs0000644000000000000000000000175612236473702015051 0ustar0000000000000000module Main where import Network.CGI import Text.XML.Light import Text.TeXMath import Text.TeXMath.Macros import Data.Maybe (fromMaybe) import Control.Monad import Text.JSON import Codec.Binary.UTF8.String (decodeString, encodeString) cgiMain :: CGI CGIResult cgiMain = do setHeader "Content-type" "text/xhtml; charset=UTF-8" latexFormula <- liftM (decodeString . fromMaybe "") $ getInput "latexFormula" rawMacros <- liftM (decodeString . fromMaybe "") $ getInput "macros" let (ms, _) = parseMacroDefinitions rawMacros output . encodeStrict $ case texMathToMathML DisplayBlock (applyMacros (reverse ms) latexFormula) of Left e -> toJSObject [("success", JSBool False) , ("error", JSString $ toJSString e)] Right v -> toJSObject [("success", JSBool True) , ("mathml", JSString $ toJSString $ encodeString $ ppElement v)] main :: IO () main = runCGI $ handleErrors cgiMain texmath-0.6.5.2/cgi/texmath.xhtml0000644000000000000000000000422512236473702015025 0ustar0000000000000000

LaTeX to MathML converter





using texmath

  

texmath-0.6.5.2/tests/0000755000000000000000000000000012236473702012672 5ustar0000000000000000texmath-0.6.5.2/tests/01.omml0000644000000000000000000000311312236473702013776 0ustar0000000000000000

  
    
  
  
    
      
      x
    
    
      
      =
    
    
      
        
      
      
        
          
          
        
        
          
          b
        
        
          
          ±
        
        
          
            
          
          
          
            
              
                
                  
                  b
                
              
              
                
                  
                  2
                
              
            
            
              
              
            
            
              
              4
            
            
              
              a
            
            
              
              c
            
          
        
      
      
        
          
          2
        
        
          
          a
        
      
    
  

texmath-0.6.5.2/tests/01.tex0000644000000000000000000000004212236473702013630 0ustar0000000000000000x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}

texmath-0.6.5.2/tests/01.xhtml0000644000000000000000000000154212236473702014172 0ustar0000000000000000

  
    
  
  
    
      
        x
        =
        
          
            
            b
            ±
            
              
                
                  b
                  2
                
                
                4
                a
                c
              
            
          
          
            2
            a
          
        
      
    
  

texmath-0.6.5.2/tests/02.omml0000644000000000000000000000304212236473702014000 0ustar0000000000000000

  
    
  
  
    
      
      2
    
    
      
      =
    
    
      
        
        
        
      
      
        
          
            
          
          
            
              
                
                
                
              
              
                
                  
                  3
                
                
                  
                  
                
                
                  
                  x
                
              
            
            
              
              ×
            
            
              
              2
            
          
          
            
              
              3
            
            
              
              
            
            
              
              x
            
          
        
      
    
  

texmath-0.6.5.2/tests/02.tex0000644000000000000000000000007412236473702013636 0ustar00000000000000002 = \left(
 \frac{\left(3-x\right) \times 2}{3-x}
 \right)

texmath-0.6.5.2/tests/02.xhtml0000644000000000000000000000161212236473702014171 0ustar0000000000000000

  
    
  
  
    
      
        2
        =
        
          (
          
            
              
                (
                3
                
                x
                )
              
              ×
              2
            
            
              3
              
              x
            
          
          )
        
      
    
  

texmath-0.6.5.2/tests/03.omml0000644000000000000000000000145712236473702014011 0ustar0000000000000000

  
    
  
  
    
      
      a
    
    
      
        
          
          x
        
      
      
        
          
          2
        
      
    
    
      
      +
    
    
      
      b
    
    
      
      x
    
    
      
      +
    
    
      
      c
    
    
      
      =
    
    
      
      0
    
  

texmath-0.6.5.2/tests/03.tex0000644000000000000000000000002312236473702013631 0ustar0000000000000000ax^2 + bx + c = 0

texmath-0.6.5.2/tests/03.xhtml0000644000000000000000000000102512236473702014170 0ustar0000000000000000

  
    
  
  
    
      
        a
        
          x
          2
        
        +
        b
        x
        +
        c
        =
        0
      
    
  

texmath-0.6.5.2/tests/04.omml0000644000000000000000000000333212236473702014004 0ustar0000000000000000

  
    
  
  
    
      
        
          
          S
        
      
      
        
          
            
          
          new
        
      
    
    
      
      =
    
    
      
        
          
          S
        
      
      
        
          
            
          
          old
        
      
    
    
      
      
    
    
      
        
      
      
        
          
            
              
                
                
                
              
              
                
                  
                  5
                
                
                  
                  
                
                
                  
                  T
                
              
            
          
          
            
              
              2
            
          
        
      
      
        
          
          2
        
      
    
  

texmath-0.6.5.2/tests/04.tex0000644000000000000000000000010512236473702013633 0ustar0000000000000000S_{\text{new}} = S_{\text{old}} - \frac{ \left( 5-T \right) ^2} {2}

texmath-0.6.5.2/tests/04.xhtml0000644000000000000000000000153612236473702014200 0ustar0000000000000000

  
    
  
  
    
      
        
          S
          new
        
        =
        
          S
          old
        
        
        
          
            
              (
              5
              
              T
              )
            
            2
          
          2
        
      
    
  

texmath-0.6.5.2/tests/05.omml0000644000000000000000000000525012236473702014006 0ustar0000000000000000

  
    
  
  
    
      
        
        
        
        
      
      
      
        
          
          a
        
      
      
        
          
          x
        
      
    
    
      
        
        
        
        
      
      
        
          
          f
        
      
      
        
          
          a
        
      
      
        
          
          s
        
      
    
    
      
      (
    
    
      
      y
    
    
      
      )
    
    
      
      
    
    
      
      d
    
    
      
      y
    
    
      
      
    
    
      
      d
    
    
      
      s
    
    
      
      =
    
    
      
        
        
        
        
      
      
        
          
          f
        
      
      
        
          
          a
        
      
      
        
          
          x
        
      
    
    
      
      (
    
    
      
      y
    
    
      
      )
    
    
      
      (
    
    
      
      x
    
    
      
      
    
    
      
      y
    
    
      
      )
    
    
      
      
    
    
      
      d
    
    
      
      y
    
  

texmath-0.6.5.2/tests/05.tex0000644000000000000000000000010012236473702013627 0ustar0000000000000000\int_a^x \!\!\!\int_a^s f(y)\,dy\,ds
 = \int_a^x f(y)(x-y)\,dy

texmath-0.6.5.2/tests/05.xhtml0000644000000000000000000000243712236473702014202 0ustar0000000000000000

  
    
  
  
    
      
        
          
          a
          x
        
        
        
        
        
          
          a
          s
        
        f
        (
        y
        )
        
        d
        y
        
        d
        s
        =
        
          
          a
          x
        
        f
        (
        y
        )
        (
        x
        
        y
        )
        
        d
        y
      
    
  

texmath-0.6.5.2/tests/06.omml0000644000000000000000000001042512236473702014007 0ustar0000000000000000

  
    
  
  
    
      
        
        
        
        
      
      
        
          
            
            
            
            
          
          
            
              
                
              
              
                
                  
                    
                      
                      m
                    
                  
                  
                    
                      
                      2
                    
                  
                
                
                  
                  
                
                
                  
                  n
                
              
              
                
                  
                    
                      
                      3
                    
                  
                  
                    
                      
                      m
                    
                  
                
                
                  
                    
                    
                    
                  
                  
                    
                      
                      m
                    
                    
                      
                      
                    
                    
                      
                        
                          
                          3
                        
                      
                      
                        
                          
                          n
                        
                      
                    
                    
                      
                      +
                    
                    
                      
                      n
                    
                    
                      
                      
                    
                    
                      
                        
                          
                          3
                        
                      
                      
                        
                          
                          m
                        
                      
                    
                  
                
              
            
          
          
            
              
              n
            
            
              
              =
            
            
              
              1
            
          
          
            
              
              
            
          
        
      
      
        
          
          m
        
        
          
          =
        
        
          
          1
        
      
      
        
          
          
        
      
    
  

texmath-0.6.5.2/tests/06.tex0000644000000000000000000000012212236473702013634 0ustar0000000000000000\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}
 {3^m\left(m\,3^n+n\,3^m\right)}

texmath-0.6.5.2/tests/06.xhtml0000644000000000000000000000274512236473702014205 0ustar0000000000000000

  
    
  
  
    
      
        
          
          
            m
            =
            1
          
          
        
        
          
          
            n
            =
            1
          
          
        
        
          
            
              m
              2
            
            
            n
          
          
            
              3
              m
            
            
              (
              m
              
              
                3
                n
              
              +
              n
              
              
                3
                m
              
              )
            
          
        
      
    
  

texmath-0.6.5.2/tests/07.omml0000644000000000000000000000301512236473702014005 0ustar0000000000000000

  
    
  
  
    
      
      u
    
    
      
      ʺ
    
    
      
      +
    
    
      
      p
    
    
      
      (
    
    
      
      x
    
    
      
      )
    
    
      
      u
    
    
      
      ʹ
    
    
      
      +
    
    
      
      q
    
    
      
      (
    
    
      
      x
    
    
      
      )
    
    
      
      u
    
    
      
      =
    
    
      
      f
    
    
      
      (
    
    
      
      x
    
    
      
      )
    
    
      
      ,
    
    
      
      
    
    
      
      x
    
    
      
      >
    
    
      
      a
    
  

texmath-0.6.5.2/tests/07.tex0000644000000000000000000000004512236473702013641 0ustar0000000000000000u'' + p(x)u' + q(x)u=f(x),\quad x>a

texmath-0.6.5.2/tests/07.xhtml0000644000000000000000000000160612236473702014201 0ustar0000000000000000

  
    
  
  
    
      
        u
        ʺ
        +
        p
        (
        x
        )
        u
        ʹ
        +
        q
        (
        x
        )
        u
        =
        f
        (
        x
        )
        ,
        
        x
        >
        a
      
    
  

texmath-0.6.5.2/tests/08.omml0000644000000000000000000000502112236473702014005 0ustar0000000000000000

  
    
  
  
    
      
      
    
    
      
        
      
      
        
          
          z
        
      
    
    
      
      
    
    
      
      =
    
    
      
      
    
    
      
      z
    
    
      
      
    
    
      
      ,
    
    
      
      
    
    
      
      (
    
    
      
        
      
      
        
          
          z
        
      
    
    
      
        
          
          )
        
      
      
        
          
          n
        
      
    
    
      
      
    
    
      
      =
    
    
      
      
    
    
      
      z
    
    
      
        
          
          
        
      
      
        
          
          n
        
      
    
    
      
      ,
    
    
      
        
      
      arg
    
    
      
      (
    
    
      
        
          
          z
        
      
      
        
          
          n
        
      
    
    
      
      )
    
    
      
      =
    
    
      
      n
    
    
      
        
      
      arg
    
    
      
      (
    
    
      
      z
    
    
      
      )
    
  

texmath-0.6.5.2/tests/08.tex0000644000000000000000000000010112236473702013633 0ustar0000000000000000|\bar{z}| = |z|,
 |(\bar{z})^n| = |z|^n,
 \arg(z^n) = n \arg(z)

texmath-0.6.5.2/tests/08.xhtml0000644000000000000000000000257412236473702014207 0ustar0000000000000000

  
    
  
  
    
      
        
        
          z
          
        
        
        =
        
        z
        
        ,
        
        (
        
          z
          
        
        
          )
          n
        
        
        =
        
        z
        
          
          n
        
        ,
        arg
        (
        
          z
          n
        
        )
        =
        n
        arg
        (
        z
        )
      
    
  

texmath-0.6.5.2/tests/09.omml0000644000000000000000000000265212236473702014015 0ustar0000000000000000

  
    
  
  
    
      
        
          
            
          
          lim
        
      
      
        
          
          z
        
        
          
          
        
        
          
            
              
              z
            
          
          
            
              
              0
            
          
        
      
    
    
      
      f
    
    
      
      (
    
    
      
      z
    
    
      
      )
    
    
      
      =
    
    
      
      f
    
    
      
      (
    
    
      
        
          
          z
        
      
      
        
          
          0
        
      
    
    
      
      )
    
  

texmath-0.6.5.2/tests/09.tex0000644000000000000000000000004512236473702013643 0ustar0000000000000000\lim_{z\rightarrow z_0} f(z)=f(z_0)

texmath-0.6.5.2/tests/09.xhtml0000644000000000000000000000147712236473702014211 0ustar0000000000000000

  
    
  
  
    
      
        
          lim
          
            z
            
            
              z
              0
            
          
        
        f
        (
        z
        )
        =
        f
        (
        
          z
          0
        
        )
      
    
  

texmath-0.6.5.2/tests/10.omml0000644000000000000000000001116712236473702014006 0ustar0000000000000000

  
    
  
  
    
      
        
          
          ϕ
        
      
      
        
          
          n
        
      
    
    
      
      (
    
    
      
      κ
    
    
      
      )
    
    
      
      =
    
    
      
        
      
      
        
          
          1
        
      
      
        
          
          4
        
        
          
            
              
              π
            
          
          
            
              
              2
            
          
        
        
          
            
              
              κ
            
          
          
            
              
              2
            
          
        
      
    
    
      
        
        
        
        
      
      
        
          
            
          
          
            
              
                
              
              sin
            
            
              
              (
            
            
              
              κ
            
            
              
              R
            
            
              
              )
            
          
          
            
              
              κ
            
            
              
              R
            
          
        
      
      
        
          
          0
        
      
      
        
          
          
        
      
    
    
      
        
      
      
        
          
          
        
      
      
        
          
          
        
        
          
          R
        
      
    
    
      
        
        
        
      
      
        
          
            
              
              R
            
          
          
            
              
              2
            
          
        
        
          
            
          
          
            
              
              
            
            
              
                
                  
                  D
                
              
              
                
                  
                  n
                
              
            
            
              
              (
            
            
              
              R
            
            
              
              )
            
          
          
            
              
              
            
            
              
              R
            
          
        
      
    
    
      
      
    
    
      
      d
    
    
      
      R
    
  

texmath-0.6.5.2/tests/10.tex0000644000000000000000000000026012236473702013632 0ustar0000000000000000\phi_n(\kappa) =
 \frac{1}{4\pi^2\kappa^2} \int_0^\infty
 \frac{\sin(\kappa R)}{\kappa R}
 \frac{\partial}{\partial R}
 \left[R^2\frac{\partial D_n(R)}{\partial R}\right]\,dR

texmath-0.6.5.2/tests/10.xhtml0000644000000000000000000000370512236473702014175 0ustar0000000000000000

  
    
  
  
    
      
        
          ϕ
          n
        
        (
        κ
        )
        =
        
          1
          
            4
            
              π
              2
            
            
              κ
              2
            
          
        
        
          
          0
          
        
        
          
            sin
            (
            κ
            R
            )
          
          
            κ
            R
          
        
        
          
          
            
            R
          
        
        
          [
          
            R
            2
          
          
            
              
              
                D
                n
              
              (
              R
              )
            
            
              
              R
            
          
          ]
        
        
        d
        R
      
    
  

texmath-0.6.5.2/tests/11.omml0000644000000000000000000000537312236473702014011 0ustar0000000000000000

  
    
  
  
    
      
        
          
          ϕ
        
      
      
        
          
          n
        
      
    
    
      
      (
    
    
      
      κ
    
    
      
      )
    
    
      
      =
    
    
      
      0
    
    
      
      .
    
    
      
      033
    
    
      
        
          
          C
        
      
      
        
          
          n
        
      
      
        
          
          2
        
      
    
    
      
        
          
          κ
        
      
      
        
          
          
        
        
          
          11
        
        
          
          /
        
        
          
          3
        
      
    
    
      
      ,
    
    
      
      
    
    
      
        
      
      
        
          
          1
        
      
      
        
          
            
              
              L
            
          
          
            
              
              0
            
          
        
      
    
    
      
      
    
    
      
      κ
    
    
      
      
    
    
      
        
      
      
        
          
          1
        
      
      
        
          
            
              
              l
            
          
          
            
              
              0
            
          
        
      
    
  

texmath-0.6.5.2/tests/11.tex0000644000000000000000000000013312236473702013632 0ustar0000000000000000\phi_n(\kappa) = 
 0.033C_n^2\kappa^{-11/3},\quad
 \frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}

texmath-0.6.5.2/tests/11.xhtml0000644000000000000000000000230112236473702014165 0ustar0000000000000000

  
    
  
  
    
      
        
          ϕ
          n
        
        (
        κ
        )
        =
        0
        .
        033
        
          C
          n
          2
        
        
          κ
          
            
            11
            /
            3
          
        
        ,
        
        
          1
          
            L
            0
          
        
        
        κ
        
        
          1
          
            l
            0
          
        
      
    
  

texmath-0.6.5.2/tests/12.omml0000644000000000000000000000707012236473702014006 0ustar0000000000000000

  
    
  
  
    
      
      f
    
    
      
      (
    
    
      
      x
    
    
      
      )
    
    
      
      =
    
    
      
        
        
        
      
      
        
          
            
            
            
              
                
                  
                
              
              
                
                  
                
              
              
                
                  
                
              
            
          
          
            
              
                
                1
              
            
            
              
                
                
              
              
                
                1
              
              
                
                
              
              
                
                x
              
              
                
                <
              
              
                
                0
              
            
          
          
            
              
                
                  
                
                
                  
                    
                    1
                  
                
                
                  
                    
                    2
                  
                
              
            
            
              
                
                x
              
              
                
                =
              
              
                
                0
              
            
          
          
            
              
                
                1
              
              
                
                
              
              
                
                  
                    
                    x
                  
                
                
                  
                    
                    2
                  
                
              
            
            
              
                
                  
                
                otherwise
              
            
          
        
      
    
  

texmath-0.6.5.2/tests/12.tex0000644000000000000000000000015512236473702013637 0ustar0000000000000000f(x) =
 \begin{cases}
 1 & -1 \le x < 0 \\
 \frac{1}{2} & x = 0 \\
 1 - x^2 & \mbox{otherwise}
 \end{cases}

texmath-0.6.5.2/tests/12.xhtml0000644000000000000000000000274412236473702014201 0ustar0000000000000000

  
    
  
  
    
      
        f
        (
        x
        )
        =
        
          {
          
            
              
                1
              
              
                
                1
                
                x
                <
                0
              
            
            
              
                
                  1
                  2
                
              
              
                x
                =
                0
              
            
            
              
                1
                
                
                  x
                  2
                
              
              
                otherwise
              
            
          
        
      
    
  

texmath-0.6.5.2/tests/13.omml0000644000000000000000000001473512236473702014015 0ustar0000000000000000

  
    
  
  
    
      
      
        
          
          p
        
      
    
    
      
        
          
          F
        
      
      
        
          
          q
        
      
    
    
      
      (
    
    
      
        
          
          a
        
      
      
        
          
          1
        
      
    
    
      
      ,
    
    
      
      
    
    
      
      ,
    
    
      
        
          
          a
        
      
      
        
          
          p
        
      
    
    
      
      ;
    
    
      
        
          
          c
        
      
      
        
          
          1
        
      
    
    
      
      ,
    
    
      
      
    
    
      
      ,
    
    
      
        
          
          c
        
      
      
        
          
          q
        
      
    
    
      
      ;
    
    
      
      z
    
    
      
      )
    
    
      
      =
    
    
      
        
        
        
        
      
      
        
          
            
          
          
            
              
              (
            
            
              
                
                  
                  a
                
              
              
                
                  
                  1
                
              
            
            
              
                
                  
                  )
                
              
              
                
                  
                  n
                
              
            
            
              
              
            
            
              
              (
            
            
              
                
                  
                  a
                
              
              
                
                  
                  p
                
              
            
            
              
                
                  
                  )
                
              
              
                
                  
                  n
                
              
            
          
          
            
              
              (
            
            
              
                
                  
                  c
                
              
              
                
                  
                  1
                
              
            
            
              
                
                  
                  )
                
              
              
                
                  
                  n
                
              
            
            
              
              
            
            
              
              (
            
            
              
                
                  
                  c
                
              
              
                
                  
                  q
                
              
            
            
              
                
                  
                  )
                
              
              
                
                  
                  n
                
              
            
          
        
      
      
        
          
          n
        
        
          
          =
        
        
          
          0
        
      
      
        
          
          
        
      
    
    
      
        
      
      
        
          
            
              
              z
            
          
          
            
              
              n
            
          
        
      
      
        
          
          n
        
        
          
          !
        
      
    
  

texmath-0.6.5.2/tests/13.tex0000644000000000000000000000020012236473702013627 0ustar0000000000000000{}_pF_q(a_1,\dots,a_p;c_1,\dots,c_q;z)
 = \sum_{n=0}^\infty
 \frac{(a_1)_n\cdots(a_p)_n}{(c_1)_n\cdots(c_q)_n}
 \frac{z^n}{n!}

texmath-0.6.5.2/tests/13.xhtml0000644000000000000000000000467312236473702014205 0ustar0000000000000000

  
    
  
  
    
      
        
          
          p
        
        
          F
          q
        
        (
        
          a
          1
        
        ,
        
        ,
        
          a
          p
        
        ;
        
          c
          1
        
        ,
        
        ,
        
          c
          q
        
        ;
        z
        )
        =
        
          
          
            n
            =
            0
          
          
        
        
          
            (
            
              a
              1
            
            
              )
              n
            
            
            (
            
              a
              p
            
            
              )
              n
            
          
          
            (
            
              c
              1
            
            
              )
              n
            
            
            (
            
              c
              q
            
            
              )
              n
            
          
        
        
          
            z
            n
          
          
            n
            !
          
        
      
    
  

texmath-0.6.5.2/tests/14.omml0000644000000000000000000000137412236473702014011 0ustar0000000000000000

  
    
  
  
    
      
        
      
      
        
          
          a
        
      
      
        
          
          b
        
      
    
    
      
       
    
    
      
        
      
      
        
          
          a
        
      
      
        
          
          b
        
      
    
  

texmath-0.6.5.2/tests/14.tex0000644000000000000000000000003712236473702013640 0ustar0000000000000000 \frac {a}{b}\  \tfrac {a}{b}

texmath-0.6.5.2/tests/14.xhtml0000644000000000000000000000103512236473702014173 0ustar0000000000000000

  
    
  
  
    
      
        
          a
          b
        
         
        
          
            a
            b
          
        
      
    
  

texmath-0.6.5.2/tests/15.omml0000644000000000000000000000065112236473702014007 0ustar0000000000000000

  
    
  
  
    
      
        
      
      
        
          
          a
        
      
      
        
          
          2
        
      
    
  

texmath-0.6.5.2/tests/15.tex0000644000000000000000000000002112236473702013632 0ustar0000000000000000\frac{{a}}{{2}}

texmath-0.6.5.2/tests/15.xhtml0000644000000000000000000000057712236473702014206 0ustar0000000000000000

  
    
  
  
    
      
        
          a
          2
        
      
    
  

texmath-0.6.5.2/tests/16.omml0000644000000000000000000000046712236473702014015 0ustar0000000000000000

  
    
  
  
    
      
      3
    
    
      
      ×
    
    
      
      4
    
  

texmath-0.6.5.2/tests/16.tex0000644000000000000000000000001212236473702013633 0ustar00000000000000003\times4

texmath-0.6.5.2/tests/16.xhtml0000644000000000000000000000055612236473702014204 0ustar0000000000000000

  
    
  
  
    
      
        3
        ×
        4
      
    
  

texmath-0.6.5.2/tests/17.omml0000644000000000000000000000102612236473702014006 0ustar0000000000000000

  
    
  
  
    
      
      x
    
    
      
      *
    
    
      
      4
    
    
      
      =
    
    
      
      4
    
    
      
      *
    
    
      
      x
    
  

texmath-0.6.5.2/tests/17.tex0000644000000000000000000000001212236473702013634 0ustar0000000000000000x*4 = 4*x
texmath-0.6.5.2/tests/17.xhtml0000644000000000000000000000067112236473702014203 0ustar0000000000000000

  
    
  
  
    
      
        x
        *
        4
        =
        4
        *
        x
      
    
  

texmath-0.6.5.2/tests/18.omml0000644000000000000000000000073712236473702014017 0ustar0000000000000000

  
    
  
  
    
      
      1
    
    
      
      .
    
    
      
      3
    
    
      
      ×
    
    
      
      .
    
    
      
      2
    
  

texmath-0.6.5.2/tests/18.tex0000644000000000000000000000001612236473702013641 0ustar00000000000000001.3 \times .2
texmath-0.6.5.2/tests/18.xhtml0000644000000000000000000000064712236473702014207 0ustar0000000000000000

  
    
  
  
    
      
        1
        .
        3
        ×
        .
        2
      
    
  

texmath-0.6.5.2/tests/19.omml0000644000000000000000000002611212236473702014013 0ustar0000000000000000

  
    
  
  
    
      
        
        
        
      
      
        
          
            
            
            
              
                
                  
                
              
              
                
                  
                
              
              
                
                  
                
              
            
          
          
            
              
                
                  
                
                
                  
                    
                    
                  
                  
                    
                      
                        
                        x
                      
                    
                    
                      
                        
                        1
                      
                    
                  
                
                
                  
                    
                    
                  
                  
                    
                      
                        
                        y
                      
                    
                    
                      
                        
                        1
                      
                    
                  
                
              
            
            
              
                
                  
                
                
                  
                    
                    
                  
                  
                    
                      
                        
                        x
                      
                    
                    
                      
                        
                        2
                      
                    
                  
                
                
                  
                    
                    
                  
                  
                    
                      
                        
                        y
                      
                    
                    
                      
                        
                        1
                      
                    
                  
                
              
            
          
          
            
              
                
                
              
            
          
          
            
              
                
                  
                
                
                  
                    
                    
                  
                  
                    
                      
                        
                        x
                      
                    
                    
                      
                        
                        1
                      
                    
                  
                
                
                  
                    
                    
                  
                  
                    
                      
                        
                        y
                      
                    
                    
                      
                        
                        2
                      
                    
                  
                
              
            
            
              
                
                  
                
                
                  
                    
                    
                  
                  
                    
                      
                        
                        x
                      
                    
                    
                      
                        
                        2
                      
                    
                  
                
                
                  
                    
                    
                  
                  
                    
                      
                        
                        y
                      
                    
                    
                      
                        
                        2
                      
                    
                  
                
              
            
          
        
      
    
    
      
        
        
        
      
      
        
          
            
            
            
              
                
                  
                
              
              
                
                  
                
              
            
          
          
            
              
                
                1
              
            
            
              
                
                2
              
            
          
          
            
              
                
                3
              
            
            
              
                
                4
              
            
          
        
      
    
    
      
        
        
        
      
      
        
          
            
            
            
              
                
                  
                
              
              
                
                  
                
              
            
          
          
            
              
                
                1
              
            
            
              
                
                2
              
            
          
          
            
              
                
                3
              
            
            
              
                
                4
              
            
          
        
      
    
    
      
        
        
        
      
      
        
          
            
            
            
              
                
                  
                
              
              
                
                  
                
              
            
          
          
            
              
                
                1
              
            
            
              
                
                2
              
            
          
          
            
              
                
                3
              
            
            
              
                
                4
              
            
          
        
      
    
    
      
        
        
        
      
      
        
          
            
            
            
              
                
                  
                
              
              
                
                  
                
              
            
          
          
            
              
                
                1
              
            
            
              
                
                2
              
            
          
          
            
              
                
                3
              
            
            
              
                
                4
              
            
          
        
      
    
  

texmath-0.6.5.2/tests/19.tex0000644000000000000000000000062212236473702013645 0ustar0000000000000000\begin{bmatrix} 
   \dfrac{\partial x_1}{\partial y_1} & \dfrac{\partial x_2}{\partial y_1} 
\\ ~
\\ \dfrac{\partial x_1}{\partial y_2} & \dfrac{\partial x_2}{\partial y_2}  
\end{bmatrix}

\begin{pmatrix} 
   1 & 2 \\
   3 & 4
\end{pmatrix}

\begin{Bmatrix} 
   1 & 2 \\
   3 & 4
\end{Bmatrix}

\begin{vmatrix} 
   1 & 2 \\
   3 & 4
\end{vmatrix}

\begin{Vmatrix} 
   1 & 2 \\
   3 & 4
\end{Vmatrix}

texmath-0.6.5.2/tests/19.xhtml0000644000000000000000000001164312236473702014206 0ustar0000000000000000

  
    
  
  
    
      
        
          [
          
            
              
                
                  
                    
                      
                      
                        x
                        1
                      
                    
                    
                      
                      
                        y
                        1
                      
                    
                  
                
              
              
                
                  
                    
                      
                      
                        x
                        2
                      
                    
                    
                      
                      
                        y
                        1
                      
                    
                  
                
              
            
            
              
                
              
            
            
              
                
                  
                    
                      
                      
                        x
                        1
                      
                    
                    
                      
                      
                        y
                        2
                      
                    
                  
                
              
              
                
                  
                    
                      
                      
                        x
                        2
                      
                    
                    
                      
                      
                        y
                        2
                      
                    
                  
                
              
            
          
          ]
        
        
          (
          
            
              
                1
              
              
                2
              
            
            
              
                3
              
              
                4
              
            
          
          )
        
        
          {
          
            
              
                1
              
              
                2
              
            
            
              
                3
              
              
                4
              
            
          
          }
        
        
          
          
            
              
                1
              
              
                2
              
            
            
              
                3
              
              
                4
              
            
          
          
        
        
          
          
            
              
                1
              
              
                2
              
            
            
              
                3
              
              
                4
              
            
          
          
        
      
    
  

texmath-0.6.5.2/tests/20.omml0000644000000000000000000003625512236473702014014 0ustar0000000000000000

  
    
  
  
    
      
        
        
      
      A
    
    
      
        
        
      
      B
    
    
      
        
        
      
      C
    
    
      
        
        
      
      D
    
    
      
        
        
      
      E
    
    
      
        
        
      
      F
    
    
      
        
        
      
      G
    
    
      
        
        
      
      H
    
    
      
        
        
      
      I
    
    
      
        
        
      
      J
    
    
      
        
        
      
      K
    
    
      
        
        
      
      L
    
    
      
        
        
      
      M
    
    
      
        
        
      
      N
    
    
      
        
        
      
      O
    
    
      
        
        
      
      P
    
    
      
        
        
      
      Q
    
    
      
        
        
      
      R
    
    
      
        
        
      
      S
    
    
      
        
        
      
      T
    
    
      
        
        
      
      U
    
    
      
        
        
      
      V
    
    
      
        
        
      
      W
    
    
      
        
        
      
      X
    
    
      
        
        
      
      Y
    
    
      
        
        
      
      Z
    
    
      
        
        
      
      a
    
    
      
        
        
      
      b
    
    
      
        
        
      
      c
    
    
      
        
        
      
      d
    
    
      
        
        
      
      e
    
    
      
        
        
      
      f
    
    
      
        
        
      
      g
    
    
      
        
        
      
      h
    
    
      
        
        
      
      i
    
    
      
        
        
      
      j
    
    
      
        
        
      
      k
    
    
      
        
        
      
      l
    
    
      
        
        
      
      m
    
    
      
        
        
      
      n
    
    
      
        
        
      
      o
    
    
      
        
        
      
      p
    
    
      
        
        
      
      q
    
    
      
        
        
      
      r
    
    
      
        
        
      
      s
    
    
      
        
        
      
      t
    
    
      
        
        
      
      u
    
    
      
        
        
      
      v
    
    
      
        
        
      
      w
    
    
      
        
        
      
      x
    
    
      
        
        
      
      y
    
    
      
        
        
      
      z
    
    
      
        
        
      
      A
    
    
      
        
        
      
      B
    
    
      
        
        
      
      C
    
    
      
        
        
      
      D
    
    
      
        
        
      
      E
    
    
      
        
        
      
      F
    
    
      
        
        
      
      G
    
    
      
        
        
      
      H
    
    
      
        
        
      
      I
    
    
      
        
        
      
      J
    
    
      
        
        
      
      K
    
    
      
        
        
      
      L
    
    
      
        
        
      
      M
    
    
      
        
        
      
      N
    
    
      
        
        
      
      O
    
    
      
        
        
      
      P
    
    
      
        
        
      
      Q
    
    
      
        
        
      
      R
    
    
      
        
        
      
      S
    
    
      
        
        
      
      T
    
    
      
        
        
      
      U
    
    
      
        
        
      
      V
    
    
      
        
        
      
      W
    
    
      
        
        
      
      X
    
    
      
        
        
      
      Y
    
    
      
        
        
      
      Z
    
    
      
        
        
      
      a
    
    
      
        
        
      
      b
    
    
      
        
        
      
      c
    
    
      
        
        
      
      d
    
    
      
        
        
      
      e
    
    
      
        
        
      
      f
    
    
      
        
        
      
      g
    
    
      
        
        
      
      h
    
    
      
        
        
      
      i
    
    
      
        
        
      
      j
    
    
      
        
        
      
      k
    
    
      
        
        
      
      l
    
    
      
        
        
      
      m
    
    
      
        
        
      
      n
    
    
      
        
        
      
      o
    
    
      
        
        
      
      p
    
    
      
        
        
      
      q
    
    
      
        
        
      
      r
    
    
      
        
        
      
      s
    
    
      
        
        
      
      t
    
    
      
        
        
      
      u
    
    
      
        
        
      
      v
    
    
      
        
        
      
      w
    
    
      
        
        
      
      x
    
    
      
        
        
      
      y
    
    
      
        
        
      
      z
    
    
      
        
        
      
      0
    
    
      
        
        
      
      1
    
    
      
        
        
      
      2
    
    
      
        
        
      
      3
    
    
      
        
        
      
      4
    
    
      
        
        
      
      5
    
    
      
        
        
      
      6
    
    
      
        
        
      
      7
    
    
      
        
        
      
      8
    
    
      
        
        
      
      9
    
    
      
        
        
      
      0
    
  

texmath-0.6.5.2/tests/20.tex0000644000000000000000000000244512236473702013642 0ustar0000000000000000\mathcal{A}
\mathcal{B}
\mathcal{C}
\mathcal{D}
\mathcal{E}
\mathcal{F}
\mathcal{G}
\mathcal{H}
\mathcal{I}
\mathcal{J}
\mathcal{K}
\mathcal{L}
\mathcal{M}
\mathcal{N}
\mathcal{O}
\mathcal{P}
\mathcal{Q}
\mathcal{R}
\mathcal{S}
\mathcal{T}
\mathcal{U}
\mathcal{V}
\mathcal{W}
\mathcal{X}
\mathcal{Y}
\mathcal{Z}
\mathcal{a}
\mathcal{b}
\mathcal{c}
\mathcal{d}
\mathcal{e}
\mathcal{f}
\mathcal{g}
\mathcal{h}
\mathcal{i}
\mathcal{j}
\mathcal{k}
\mathcal{l}
\mathcal{m}
\mathcal{n}
\mathcal{o}
\mathcal{p}
\mathcal{q}
\mathcal{r}
\mathcal{s}
\mathcal{t}
\mathcal{u}
\mathcal{v}
\mathcal{w}
\mathcal{x}
\mathcal{y}
\mathcal{z}
\mathbb{A}
\mathbb{B}
\mathbb{C}
\mathbb{D}
\mathbb{E}
\mathbb{F}
\mathbb{G}
\mathbb{H}
\mathbb{I}
\mathbb{J}
\mathbb{K}
\mathbb{L}
\mathbb{M}
\mathbb{N}
\mathbb{O}
\mathbb{P}
\mathbb{Q}
\mathbb{R}
\mathbb{S}
\mathbb{T}
\mathbb{U}
\mathbb{V}
\mathbb{W}
\mathbb{X}
\mathbb{Y}
\mathbb{Z}
\mathbb{a}
\mathbb{b}
\mathbb{c}
\mathbb{d}
\mathbb{e}
\mathbb{f}
\mathbb{g}
\mathbb{h}
\mathbb{i}
\mathbb{j}
\mathbb{k}
\mathbb{l}
\mathbb{m}
\mathbb{n}
\mathbb{o}
\mathbb{p}
\mathbb{q}
\mathbb{r}
\mathbb{s}
\mathbb{t}
\mathbb{u}
\mathbb{v}
\mathbb{w}
\mathbb{x}
\mathbb{y}
\mathbb{z}
\mathbb{0}
\mathbb{1}
\mathbb{2}
\mathbb{3}
\mathbb{4}
\mathbb{5}
\mathbb{6}
\mathbb{7}
\mathbb{8}
\mathbb{9}
\mathbb{0}
texmath-0.6.5.2/tests/20.xhtml0000644000000000000000000001433612236473702014200 0ustar0000000000000000

  
    
  
  
    
      
        𝒜
        
        𝒞
        𝒟
        
        
        𝒢
        
        
        𝒥
        𝒦
        
        
        𝒩
        𝒪
        𝒫
        𝒬
        
        𝒮
        𝒯
        𝒰
        𝒱
        𝒲
        𝒳
        𝒴
        𝒵
        𝒶
        𝒷
        𝒸
        𝒹
        
        𝒻
        
        𝒽
        𝒾
        𝒿
        𝓀
        𝓁
        𝓂
        𝓃
        
        𝓅
        𝓆
        𝓇
        𝓈
        𝓉
        𝓊
        𝓋
        𝓌
        𝓍
        𝓎
        𝓏
        𝔸
        𝔹
        
        𝔻
        𝔼
        𝔽
        𝔾
        
        𝕀
        𝕁
        𝕂
        𝕃
        𝕄
        
        𝕆
        
        
        
        𝕊
        𝕋
        𝕌
        𝕍
        𝕎
        𝕏
        𝕐
        
        𝕒
        𝕓
        𝕔
        𝕕
        𝕖
        𝕗
        𝕘
        𝕙
        𝕚
        𝕛
        𝕜
        𝕝
        𝕞
        𝕟
        𝕠
        𝕡
        𝕢
        𝕣
        𝕤
        𝕥
        𝕦
        𝕧
        𝕨
        𝕩
        𝕪
        𝕫
        𝟘
        𝟙
        𝟚
        𝟛
        𝟜
        𝟝
        𝟞
        𝟟
        𝟠
        𝟡
        𝟘
      
    
  

texmath-0.6.5.2/tests/21.omml0000644000000000000000000000164212236473702014005 0ustar0000000000000000

  
    
  
  
    
      
        
          
          e
        
      
      
        
          
          1
        
      
    
    
      
      =
    
    
      
        
          
          b
        
      
      
        
          
          2
        
      
    
    
      
      +
    
    
      
        
          
          c
        
      
      
        
          
          22
        
      
    
  

texmath-0.6.5.2/tests/21.tex0000644000000000000000000000002612236473702013634 0ustar0000000000000000e_ 1 = b^ 2 + c^ {22}
texmath-0.6.5.2/tests/21.xhtml0000644000000000000000000000106612236473702014175 0ustar0000000000000000

  
    
  
  
    
      
        
          e
          1
        
        =
        
          b
          2
        
        +
        
          c
          22
        
      
    
  

texmath-0.6.5.2/tests/22.omml0000644000000000000000000003306512236473702014012 0ustar0000000000000000

  
    
  
  
    
      
        
        
        
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
        
      
      
        
          
            
              
              
            
            textrm
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathrm
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathup
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            text
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mbox
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathbf
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathbfup
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            textbf
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathit
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            textit
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathtt
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            texttt
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathsf
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathsfup
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathbb
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathcal
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathscr
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathfrak
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathbfit
          
        
        
          
            
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathbfsfup
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathbfsfit
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathbfscr
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathbffrak
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathbfcal
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
      
        
          
            
              
              
            
            mathsfit
          
        
        
          
            
              
              
            
            ABCabc
          
        
      
    
  

texmath-0.6.5.2/tests/22.tex0000644000000000000000000000220112236473702013632 0ustar0000000000000000\begin{array}{ll}
\texttt{textrm}     & \textrm    {ABCabc} \\
\texttt{mathrm}     & \mathrm    {ABCabc} \\
\texttt{mathup}     & \mathup    {ABCabc} \\
\texttt{text}       & \text      {ABCabc} \\
\texttt{mbox}       & \mbox      {ABCabc} \\
\texttt{mathbf}     & \mathbf    {ABCabc} \\
\texttt{mathbfup}   & \mathbfup  {ABCabc} \\
\texttt{textbf}     & \textbf    {ABCabc} \\
\texttt{mathit}     & \mathit    {ABCabc} \\
\texttt{textit}     & \textit    {ABCabc} \\
\texttt{mathtt}     & \mathtt    {ABCabc} \\
\texttt{texttt}     & \texttt    {ABCabc} \\
\texttt{mathsf}     & \mathsf    {ABCabc} \\
\texttt{mathsfup}   & \mathsfup  {ABCabc} \\
\texttt{mathbb}     & \mathbb    {ABCabc} \\
\texttt{mathcal}    & \mathcal   {ABCabc} \\
\texttt{mathscr}    & \mathscr   {ABCabc} \\
\texttt{mathfrak}   & \mathfrak  {ABCabc} \\
\texttt{mathbfit}   & \mathbfit  {ABCabc} \\
\texttt{mathbfsfup} & \mathbfsfup{ABCabc} \\
\texttt{mathbfsfit} & \mathbfsfit{ABCabc} \\
\texttt{mathbfscr}  & \mathbfscr {ABCabc} \\
\texttt{mathbffrak} & \mathbffrak{ABCabc} \\
\texttt{mathbfcal}  & \mathbfcal {ABCabc} \\
\texttt{mathsfit}   & \mathsfit  {ABCabc}
\end{array}

texmath-0.6.5.2/tests/22.xhtml0000644000000000000000000001571212236473702014201 0ustar0000000000000000

  
    
  
  
    
      
        
          
            
              textrm
            
            
              ABCabc
            
          
          
            
              mathrm
            
            
              ABCabc
            
          
          
            
              mathup
            
            
              ABCabc
            
          
          
            
              text
            
            
              ABCabc
            
          
          
            
              mbox
            
            
              ABCabc
            
          
          
            
              mathbf
            
            
              ABCabc
            
          
          
            
              mathbfup
            
            
              ABCabc
            
          
          
            
              textbf
            
            
              ABCabc
            
          
          
            
              mathit
            
            
              ABCabc
            
          
          
            
              textit
            
            
              ABCabc
            
          
          
            
              mathtt
            
            
              ABCabc
            
          
          
            
              texttt
            
            
              ABCabc
            
          
          
            
              mathsf
            
            
              ABCabc
            
          
          
            
              mathsfup
            
            
              ABCabc
            
          
          
            
              mathbb
            
            
              𝔸𝔹ℂ𝕒𝕓𝕔
            
          
          
            
              mathcal
            
            
              𝒜ℬ𝒞𝒶𝒷𝒸
            
          
          
            
              mathscr
            
            
              𝒜ℬ𝒞𝒶𝒷𝒸
            
          
          
            
              mathfrak
            
            
              𝔄𝔅ℭ𝔞𝔟𝔠
            
          
          
            
              mathbfit
            
            
              ABCabc
            
          
          
            
              mathbfsfup
            
            
              ABCabc
            
          
          
            
              mathbfsfit
            
            
              ABCabc
            
          
          
            
              mathbfscr
            
            
              𝓐𝓑𝓒𝓪𝓫𝓬
            
          
          
            
              mathbffrak
            
            
              𝕬𝕭𝕮𝖆𝖇𝖈
            
          
          
            
              mathbfcal
            
            
              𝓐𝓑𝓒𝓪𝓫𝓬
            
          
          
            
              mathsfit
            
            
              ABCabc
            
          
        
      
    
  

texmath-0.6.5.2/tests/axiom_of_power_set.omml0000644000000000000000000000322012236473702017445 0ustar0000000000000000

  
    
  
  
    
      
      
    
    
      
      A
    
    
      
      
    
    
      
      
    
    
      
      P
    
    
      
      
    
    
      
      
    
    
      
      B
    
    
      
      
    
    
      
      [
    
    
      
      B
    
    
      
      
    
    
      
      P
    
    
      
      
    
    
      
      
    
    
      
      C
    
    
      
      
    
    
      
      (
    
    
      
      C
    
    
      
      
    
    
      
      B
    
    
      
      
    
    
      
      C
    
    
      
      
    
    
      
      A
    
    
      
      )
    
    
      
      ]
    
  

texmath-0.6.5.2/tests/axiom_of_power_set.tex0000644000000000000000000000014412236473702017303 0ustar0000000000000000   \forall A \, \exists P \, \forall B \, [B \in P \iff \forall C \, (C \in B \Rightarrow C \in A)]
texmath-0.6.5.2/tests/axiom_of_power_set.xhtml0000644000000000000000000000171312236473702017642 0ustar0000000000000000

  
    
  
  
    
      
        
        A
        
        
        P
        
        
        B
        
        [
        B
        
        P
        
        
        C
        
        (
        C
        
        B
        
        C
        
        A
        )
        ]
      
    
  

texmath-0.6.5.2/tests/binomial_coefficient.omml0000644000000000000000000000556612236473702017724 0ustar0000000000000000

  
    
  
  
    
      
        
      
      C
    
    
      
      (
    
    
      
      n
    
    
      
      ,
    
    
      
      k
    
    
      
      )
    
    
      
      =
    
    
      
        
          
            
          
          C
        
      
      
        
          
          k
        
      
      
        
          
          n
        
      
    
    
      
      =
    
    
      
      
        
          
          n
        
      
    
    
      
        
          
            
          
          C
        
      
      
        
          
          k
        
      
    
    
      
      =
    
    
      
        
      
      
        
          
            
          
          
            
              
              n
            
          
          
            
              
              k
            
          
        
      
    
    
      
      =
    
    
      
        
      
      
        
          
          n
        
        
          
          !
        
      
      
        
          
          k
        
        
          
          !
        
        
          
          
        
        
          
          (
        
        
          
          n
        
        
          
          
        
        
          
          k
        
        
          
          )
        
        
          
          !
        
      
    
  

texmath-0.6.5.2/tests/binomial_coefficient.tex0000644000000000000000000000013712236473702017545 0ustar0000000000000000   \mathbf{C}(n,k) = \mathbf{C}_k^n = {}_n\mathbf{C}_k = \binom{n}{k} = \frac{n!}{k!\,(n -k)!}
texmath-0.6.5.2/tests/binomial_coefficient.xhtml0000644000000000000000000000256512236473702020110 0ustar0000000000000000

  
    
  
  
    
      
        C
        (
        n
        ,
        k
        )
        =
        
          C
          k
          n
        
        =
        
          
          n
        
        
          C
          k
        
        =
        
          
            n
            k
          
        
        =
        
          
            n
            !
          
          
            k
            !
            
            (
            n
            
            k
            )
            !
          
        
      
    
  

texmath-0.6.5.2/tests/complex_number.omml0000644000000000000000000000440412236473702016601 0ustar0000000000000000

  
    
  
  
    
      
      c
    
    
      
      =
    
    
      
        
          
            
          
          
            
              
                
                  
                    
                      
                      a
                    
                  
                  
                    
                      
                      
                    
                  
                
              
              
                
                  
                    
                  
                  real
                
              
            
            
              
              +
            
            
              
                
                  
                    
                      
                      b
                    
                    
                      
                        
                      
                      i
                    
                  
                  
                    
                      
                      
                    
                  
                
              
              
                
                  
                    
                  
                  imaginary
                
              
            
          
        
      
      
        
          
            
          
          complex number
        
      
    
  

texmath-0.6.5.2/tests/complex_number.tex0000644000000000000000000000021112236473702016425 0ustar0000000000000000 c = \overbrace
     { \underbrace{a}_\text{real}
       +
       \underbrace{b\mathrm{i}}_\text{imaginary}
     }^\text{complex number}
texmath-0.6.5.2/tests/complex_number.xhtml0000644000000000000000000000220212236473702016763 0ustar0000000000000000

  
    
  
  
    
      
        c
        =
        
          
            
              
                
                  a
                  
                
                real
              
              +
              
                
                  
                    b
                    i
                  
                  
                
                imaginary
              
            
            
          
          complex number
        
      
    
  

texmath-0.6.5.2/tests/deMorgans_law.omml0000644000000000000000000000632512236473702016350 0ustar0000000000000000

  
    
  
  
    
      
      ¬
    
    
      
      (
    
    
      
      p
    
    
      
      
    
    
      
      q
    
    
      
      )
    
    
      
      
    
    
      
      (
    
    
      
      ¬
    
    
      
      p
    
    
      
      )
    
    
      
      
    
    
      
      (
    
    
      
      ¬
    
    
      
      q
    
    
      
      )
    
    
      
        
      
      
        
          
            
            
            
            
          
          
            
              
                
                  
                  A
                
              
              
                
                  
                  i
                
              
            
          
          
            
              
              i
            
            
              
              =
            
            
              
              1
            
          
          
            
              
              n
            
          
        
      
    
    
      
      =
    
    
      
        
        
        
        
      
      
        
          
            
          
          
            
              
                
                  
                  A
                
              
              
                
                  
                  i
                
              
            
          
        
      
      
        
          
          i
        
        
          
          =
        
        
          
          1
        
      
      
        
          
          n
        
      
    
  

texmath-0.6.5.2/tests/deMorgans_law.tex0000644000000000000000000000016212236473702016175 0ustar0000000000000000  \neg(p\wedge q)\iff(\neg p)\vee(\neg q)
  \overline{\bigcup_{i=1}^{n} A_{i}}=\bigcap_{i=1}^{n} \overline{A_{i}}
texmath-0.6.5.2/tests/deMorgans_law.xhtml0000644000000000000000000000273712236473702016543 0ustar0000000000000000

  
    
  
  
    
      
        ¬
        (
        p
        
        q
        )
        
        (
        ¬
        p
        )
        
        (
        ¬
        q
        )
        
          
            
              
              
                i
                =
                1
              
              n
            
            
              A
              i
            
          
          ¯
        
        =
        
          
          
            i
            =
            1
          
          n
        
        
          
            A
            i
          
          ¯
        
      
    
  

texmath-0.6.5.2/tests/differentiable_manifold.omml0000644000000000000000000001726112236473702020403 0ustar0000000000000000

  
    
  
  
    
      
        
          
          γ
        
      
      
        
          
          1
        
      
    
    
      
      
    
    
      
        
          
          γ
        
      
      
        
          
          2
        
      
    
    
      
      
    
    
      
      {
    
    
      
        
        
        
          
            
              
            
          
          
            
              
            
          
        
      
      
        
          
            
              
                
                γ
              
            
            
              
                
                1
              
            
          
          
            
            (
          
          
            
            0
          
          
            
            )
          
          
            
            =
          
          
            
              
                
                γ
              
            
            
              
                
                2
              
            
          
          
            
            (
          
          
            
            0
          
          
            
            )
          
          
            
            =
          
          
            
            p
          
          
            
            ,
          
          
            
              
            
            and 
          
        
      
      
        
          
            
              
                
                  
                  
                  
                
                
                  
                    
                      
                    
                    
                      
                        
                          
                        
                        d
                      
                    
                    
                      
                        
                          
                        
                        d
                      
                      
                        
                        t
                      
                    
                  
                  
                    
                    ϕ
                  
                  
                    
                    
                  
                  
                    
                      
                        
                        γ
                      
                    
                    
                      
                        
                        1
                      
                    
                  
                  
                    
                    (
                  
                  
                    
                    t
                  
                  
                    
                    )
                  
                
              
            
            
              
                
                t
              
              
                
                =
              
              
                
                0
              
            
          
          
            
            =
          
          
            
              
                
                  
                  
                  
                
                
                  
                    
                      
                    
                    
                      
                        
                          
                        
                        d
                      
                    
                    
                      
                        
                          
                        
                        d
                      
                      
                        
                        t
                      
                    
                  
                  
                    
                    ϕ
                  
                  
                    
                    
                  
                  
                    
                      
                        
                        γ
                      
                    
                    
                      
                        
                        2
                      
                    
                  
                  
                    
                    (
                  
                  
                    
                    t
                  
                  
                    
                    )
                  
                
              
            
            
              
                
                t
              
              
                
                =
              
              
                
                0
              
            
          
        
      
    
    
      
      
    
  

texmath-0.6.5.2/tests/differentiable_manifold.tex0000644000000000000000000000042312236473702020227 0ustar0000000000000000   \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.
texmath-0.6.5.2/tests/differentiable_manifold.xhtml0000644000000000000000000000623212236473702020567 0ustar0000000000000000

  
    
  
  
    
      
        
          γ
          1
        
        
        
          γ
          2
        
        
        {
        
          
            
              
                γ
                1
              
              (
              0
              )
              =
              
                γ
                2
              
              (
              0
              )
              =
              p
              ,
              
                and 
                
              
            
          
          
            
              
                
                  
                  
                    d
                    
                      d
                      t
                    
                  
                  ϕ
                  
                  
                    γ
                    1
                  
                  (
                  t
                  )
                  
                
                
                  t
                  =
                  0
                
              
              =
              
                
                  
                  
                    d
                    
                      d
                      t
                    
                  
                  ϕ
                  
                  
                    γ
                    2
                  
                  (
                  t
                  )
                  
                
                
                  t
                  =
                  0
                
              
            
          
        
        
      
    
  

texmath-0.6.5.2/tests/divergence.omml0000644000000000000000000000474312236473702015703 0ustar0000000000000000

  
    
  
  
    
      
      
    
    
      
      
    
    
      
        
      
      
        
          
          v
        
      
    
    
      
      =
    
    
      
        
      
      
        
          
          
        
        
          
            
              
              v
            
          
          
            
              
              x
            
          
        
      
      
        
          
          
        
        
          
          x
        
      
    
    
      
      +
    
    
      
        
      
      
        
          
          
        
        
          
            
              
              v
            
          
          
            
              
              y
            
          
        
      
      
        
          
          
        
        
          
          y
        
      
    
    
      
      +
    
    
      
        
      
      
        
          
          
        
        
          
            
              
              v
            
          
          
            
              
              z
            
          
        
      
      
        
          
          
        
        
          
          z
        
      
    
  

texmath-0.6.5.2/tests/divergence.tex0000644000000000000000000000020712236473702015526 0ustar0000000000000000   \nabla \cdot \vec{v} =
   \frac{\partial v_x}{\partial x} +
   \frac{\partial v_y}{\partial y} +
   \frac{\partial v_z}{\partial z}
texmath-0.6.5.2/tests/divergence.xhtml0000644000000000000000000000241512236473702016065 0ustar0000000000000000

  
    
  
  
    
      
        
        
        
          v
          
        
        =
        
          
            
            
              v
              x
            
          
          
            
            x
          
        
        +
        
          
            
            
              v
              y
            
          
          
            
            y
          
        
        +
        
          
            
            
              v
              z
            
          
          
            
            z
          
        
      
    
  

texmath-0.6.5.2/tests/ensuremath.omml0000644000000000000000000000056012236473702015734 0ustar0000000000000000

  
    
  
  
    
      
        
          
          π
        
      
      
        
          
          2
        
      
    
  

texmath-0.6.5.2/tests/ensuremath.tex0000644000000000000000000000002312236473702015562 0ustar0000000000000000\ensuremath{\pi^2}
texmath-0.6.5.2/tests/ensuremath.xhtml0000644000000000000000000000057612236473702016133 0ustar0000000000000000

  
    
  
  
    
      
        
          π
          2
        
      
    
  

texmath-0.6.5.2/tests/labels.omml0000644000000000000000000000046612236473702015030 0ustar0000000000000000

  
    
  
  
    
      
      2
    
    
      
      +
    
    
      
      2
    
  

texmath-0.6.5.2/tests/labels.tex0000644000000000000000000000002312236473702014651 0ustar00000000000000002 + 2
\label{myeq}
texmath-0.6.5.2/tests/labels.xhtml0000644000000000000000000000055512236473702015217 0ustar0000000000000000

  
    
  
  
    
      
        2
        +
        2
      
    
  

texmath-0.6.5.2/tests/macros.omml0000644000000000000000000000130012236473702015036 0ustar0000000000000000

  
    
  
  
    
      
      25
    
    
      
      y
    
    
      
      +
    
    
      
      3
    
    
      
      x
    
    
      
      +
    
    
      
      3
    
    
      
      x
    
    
      
      +
    
    
      
      α
    
  

texmath-0.6.5.2/tests/macros.tex0000644000000000000000000000033412236473702014700 0ustar0000000000000000\newcommand{\abc}{5}
\newcommand{\xyz}[2][x]{%
#1 + #2%
}
\renewcommand{%
\phi%
}{%
\theta%
}
% comment
\newcommand{\aaa}{\b{2}}
\renewcommand{\phi}{\aaa}
\newcommand{\b}[1]{#1}

\phi
\abc
\xyz[y] {3}
\xyz 3
\xyz \alpha
texmath-0.6.5.2/tests/macros.xhtml0000644000000000000000000000076412236473702015243 0ustar0000000000000000

  
    
  
  
    
      
        25
        y
        +
        3
        x
        +
        3
        x
        +
        α
      
    
  

texmath-0.6.5.2/tests/moore_determinant.omml0000644000000000000000000002055112236473702017276 0ustar0000000000000000

  
    
  
  
    
      
      M
    
    
      
      =
    
    
      
        
        
        
      
      
        
          
            
            
            
              
                
                  
                
              
              
                
                  
                
              
              
                
                  
                
              
              
                
                  
                
              
            
          
          
            
              
                
                  
                    
                    α
                  
                
                
                  
                    
                    1
                  
                
              
            
            
              
                
                  
                    
                    α
                  
                
                
                  
                    
                    1
                  
                
                
                  
                    
                    q
                  
                
              
            
            
              
                
                
              
            
            
              
                
                  
                    
                    α
                  
                
                
                  
                    
                    1
                  
                
                
                  
                    
                      
                        
                        q
                      
                    
                    
                      
                        
                        n
                      
                      
                        
                        
                      
                      
                        
                        1
                      
                    
                  
                
              
            
          
          
            
              
                
                  
                    
                    α
                  
                
                
                  
                    
                    2
                  
                
              
            
            
              
                
                  
                    
                    α
                  
                
                
                  
                    
                    2
                  
                
                
                  
                    
                    q
                  
                
              
            
            
              
                
                
              
            
            
              
                
                  
                    
                    α
                  
                
                
                  
                    
                    2
                  
                
                
                  
                    
                      
                        
                        q
                      
                    
                    
                      
                        
                        n
                      
                      
                        
                        
                      
                      
                        
                        1
                      
                    
                  
                
              
            
          
          
            
              
                
                
              
            
            
              
                
                
              
            
            
              
                
                
              
            
            
              
                
                
              
            
          
          
            
              
                
                  
                    
                    α
                  
                
                
                  
                    
                    m
                  
                
              
            
            
              
                
                  
                    
                    α
                  
                
                
                  
                    
                    m
                  
                
                
                  
                    
                    q
                  
                
              
            
            
              
                
                
              
            
            
              
                
                  
                    
                    α
                  
                
                
                  
                    
                    m
                  
                
                
                  
                    
                      
                        
                        q
                      
                    
                    
                      
                        
                        n
                      
                      
                        
                        
                      
                      
                        
                        1
                      
                    
                  
                
              
            
          
        
      
    
  

texmath-0.6.5.2/tests/moore_determinant.tex0000644000000000000000000000043612236473702017132 0ustar0000000000000000   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}
texmath-0.6.5.2/tests/moore_determinant.xhtml0000644000000000000000000000633012236473702017465 0ustar0000000000000000

  
    
  
  
    
      
        M
        =
        
          [
          
            
              
                
                  α
                  1
                
              
              
                
                  α
                  1
                  q
                
              
              
                
              
              
                
                  α
                  1
                  
                    q
                    
                      n
                      
                      1
                    
                  
                
              
            
            
              
                
                  α
                  2
                
              
              
                
                  α
                  2
                  q
                
              
              
                
              
              
                
                  α
                  2
                  
                    q
                    
                      n
                      
                      1
                    
                  
                
              
            
            
              
                
              
              
                
              
              
                
              
              
                
              
            
            
              
                
                  α
                  m
                
              
              
                
                  α
                  m
                  q
                
              
              
                
              
              
                
                  α
                  m
                  
                    q
                    
                      n
                      
                      1
                    
                  
                
              
            
          
          ]
        
      
    
  

texmath-0.6.5.2/tests/notin.omml0000644000000000000000000000103412236473702014705 0ustar0000000000000000

  
    
  
  
    
      
      x
    
    
      
      
    
    
      
      y
    
    
      
      
    
    
      
      x
    
    
      
      
    
    
      
      y
    
  

texmath-0.6.5.2/tests/notin.tex0000644000000000000000000000003312236473702014537 0ustar0000000000000000x \in y
\wedge
x \not\in y
texmath-0.6.5.2/tests/notin.xhtml0000644000000000000000000000067712236473702015111 0ustar0000000000000000

  
    
  
  
    
      
        x
        
        y
        
        x
        
        y
      
    
  

texmath-0.6.5.2/tests/quadratic_formula.omml0000644000000000000000000000311312236473702017260 0ustar0000000000000000

  
    
  
  
    
      
      x
    
    
      
      =
    
    
      
        
      
      
        
          
          
        
        
          
          b
        
        
          
          ±
        
        
          
            
          
          
          
            
              
                
                  
                  b
                
              
              
                
                  
                  2
                
              
            
            
              
              
            
            
              
              4
            
            
              
              a
            
            
              
              c
            
          
        
      
      
        
          
          2
        
        
          
          a
        
      
    
  

texmath-0.6.5.2/tests/quadratic_formula.tex0000644000000000000000000000004412236473702017114 0ustar0000000000000000   x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
texmath-0.6.5.2/tests/quadratic_formula.xhtml0000644000000000000000000000154212236473702017454 0ustar0000000000000000

  
    
  
  
    
      
        x
        =
        
          
            
            b
            ±
            
              
                
                  b
                  2
                
                
                4
                a
                c
              
            
          
          
            2
            a
          
        
      
    
  

texmath-0.6.5.2/tests/runtests.sh0000644000000000000000000000232112236473702015113 0ustar0000000000000000#!/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 'texmath' won't be built.
# Exit status is number of failed tests.
TESTPROG=../dist/build/texmath/texmath
totalfailures=0

for format in xhtml omml; do
  failures=0
  passes=0
  if [ -f $TESTPROG ]; then
      for t in *.tex; do
          $TESTPROG --${format} <$t >tmp
          testname="Test ${t%.tex} ${format}"
          if [ "$?" -ne "0" ]; then
            echo "${testname} FAILED"
            failures=`expr $failures + 1`
          else
            diff -u ${t%.tex}.${format} tmp >tmpdiff
            if [ "$?" -ne "0" ]; then
                echo "${testname} (- expected, + actual):"
                cat tmpdiff
                failures=`expr $failures + 1`
            else
                echo "${testname} PASSED"
                passes=`expr $passes + 1`
            fi
          fi
      done
  else
      echo "Test executable not built. NOT running tests."
  fi
  echo "$format: $passes tests passed, $failures tests failed."
  totalfailures=`expr $totalfailures + $failures`
done
echo "$totalfailures tests failed total."
exit $failures


texmath-0.6.5.2/tests/schwinger_dyson.omml0000644000000000000000000001106012236473702016763 0ustar0000000000000000

  
    
  
  
    
      
        
        
        
      
      
        
          
          ψ
        
        
          
            
            
            
          
          
            
              
                
                
              
              T
            
            
              
                
                
                
              
              
                
                  
                    
                  
                  
                    
                      
                      δ
                    
                  
                  
                    
                      
                      δ
                    
                    
                      
                      ϕ
                    
                  
                
                
                  
                  F
                
                
                  
                  [
                
                
                  
                  ϕ
                
                
                  
                  ]
                
              
            
          
        
        
          
          ψ
        
      
    
    
      
      =
    
    
      
      
    
    
      
        
      
      i
    
    
      
        
        
        
      
      
        
          
          ψ
        
        
          
            
            
            
          
          
            
              
                
                
              
              T
            
            
              
                
                
                
              
              
                
                  
                  F
                
                
                  
                  [
                
                
                  
                  ϕ
                
                
                  
                  ]
                
                
                  
                    
                  
                  
                    
                      
                      δ
                    
                  
                  
                    
                      
                      δ
                    
                    
                      
                      ϕ
                    
                  
                
                
                  
                  S
                
                
                  
                  [
                
                
                  
                  ϕ
                
                
                  
                  ]
                
              
            
          
        
        
          
          ψ
        
      
    
  

texmath-0.6.5.2/tests/schwinger_dyson.tex0000644000000000000000000000035112236473702016620 0ustar0000000000000000   \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
texmath-0.6.5.2/tests/schwinger_dyson.xhtml0000644000000000000000000000377712236473702017173 0ustar0000000000000000

  
    
  
  
    
      
        
          
          ψ
          
            
            𝒯
            
              {
              
                δ
                
                  δ
                  ϕ
                
              
              F
              [
              ϕ
              ]
              }
            
            
          
          ψ
          
        
        =
        
        i
        
          
          ψ
          
            
            𝒯
            
              {
              F
              [
              ϕ
              ]
              
                δ
                
                  δ
                  ϕ
                
              
              S
              [
              ϕ
              ]
              }
            
            
          
          ψ
          
        
      
    
  

texmath-0.6.5.2/tests/sophomores_dream.omml0000644000000000000000000000536212236473702017134 0ustar0000000000000000

  
    
  
  
    
      
        
        
        
        
      
      
        
          
            
              
              x
            
          
          
            
              
              x
            
          
        
      
      
        
          
          0
        
      
      
        
          
          1
        
      
    
    
      
      
    
    
      
        
      
      d
    
    
      
      x
    
    
      
      =
    
    
      
        
        
        
        
      
      
        
          
          (
        
        
          
          
        
        
          
          1
        
        
          
            
              
              )
            
          
          
            
              
              n
            
            
              
              +
            
            
              
              1
            
          
        
        
          
          
        
        
          
            
              
              n
            
          
          
            
              
              
            
            
              
              n
            
          
        
      
      
        
          
          n
        
        
          
          =
        
        
          
          1
        
      
      
        
          
          
        
      
    
  

texmath-0.6.5.2/tests/sophomores_dream.tex0000644000000000000000000000011112236473702016753 0ustar0000000000000000   \int_0^1 x^x\,\mathrm{d}x = \sum_{n = 1}^\infty{(-1)^{n + 1}\,n^{-n}}
texmath-0.6.5.2/tests/sophomores_dream.xhtml0000644000000000000000000000240312236473702017315 0ustar0000000000000000

  
    
  
  
    
      
        
          
          0
          1
        
        
          x
          x
        
        
        d
        x
        =
        
          
          
            n
            =
            1
          
          
        
        
          (
          
          1
          
            )
            
              n
              +
              1
            
          
          
          
            n
            
              
              n
            
          
        
      
    
  

texmath-0.6.5.2/tests/sphere_volume.omml0000644000000000000000000003104212236473702016435 0ustar0000000000000000

  
    
  
  
    
      
      S
    
    
      
      =
    
    
      
      {
    
    
      
      0
    
    
      
      
    
    
      
      ϕ
    
    
      
      
    
    
      
      2
    
    
      
      π
    
    
      
      ,
    
    
      
       
    
    
      
      0
    
    
      
      
    
    
      
      θ
    
    
      
      
    
    
      
      π
    
    
      
      ,
    
    
      
       
    
    
      
      0
    
    
      
      
    
    
      
      ρ
    
    
      
      
    
    
      
      R
    
    
      
      }
    
    
      
        
        
        
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
          
            
              
            
          
        
      
      
        
          
            
              
            
            Volume
          
        
        
          
            
            =
          
          
            
              
              
              
              
            
            
            
            
              
                
                S
              
            
          
          
            
              
                
                ρ
              
            
            
              
                
                2
              
            
          
          
            
              
            
            sin
          
          
            
            θ
          
          
            
            
          
          
            
              
            
            d
          
          
            
            ρ
          
          
            
            
          
          
            
              
            
            d
          
          
            
            θ
          
          
            
            
          
          
            
              
            
            d
          
          
            
            ϕ
          
        
      
      
        
        
          
            
            =
          
          
            
              
              
              
              
            
            
            
              
                
                0
              
            
            
              
                
                2
              
              
                
                π
              
            
          
          
            
              
            
            d
          
          
            
            ϕ
          
          
            
            
          
          
            
              
              
              
              
            
            
            
              
                
                0
              
            
            
              
                
                π
              
            
          
          
            
              
            
            sin
          
          
            
            θ
          
          
            
            
          
          
            
              
            
            d
          
          
            
            θ
          
          
            
            
          
          
            
              
              
              
              
            
            
            
              
                
                0
              
            
            
              
                
                R
              
            
          
          
            
              
                
                ρ
              
            
            
              
                
                2
              
            
          
          
            
              
            
            d
          
          
            
            ρ
          
        
      
      
        
        
          
            
            =
          
          
            
            ϕ
          
          
            
              
                
                
              
            
            
              
                
                0
              
            
            
              
                
                2
              
              
                
                π
              
            
          
          
            
             
          
          
            
            (
          
          
            
            
          
          
            
              
            
            cos
          
          
            
            θ
          
          
            
            )
          
          
            
              
                
                
              
            
            
              
                
                0
              
            
            
              
                
                π
              
            
          
          
            
             
          
          
            
              
            
            
              
                
                1
              
            
            
              
                
                3
              
            
          
          
            
              
                
                ρ
              
            
            
              
                
                3
              
            
          
          
            
              
                
                
              
            
            
              
                
                0
              
            
            
              
                
                R
              
            
          
        
      
      
        
        
          
            
            =
          
          
            
            2
          
          
            
            π
          
          
            
            ×
          
          
            
            2
          
          
            
            ×
          
          
            
              
            
            
              
                
                1
              
            
            
              
                
                3
              
            
          
          
            
              
                
                R
              
            
            
              
                
                3
              
            
          
        
      
      
        
        
          
            
            =
          
          
            
              
            
            
              
                
                4
              
            
            
              
                
                3
              
            
          
          
            
            π
          
          
            
              
                
                R
              
            
            
              
                
                3
              
            
          
        
      
    
  

texmath-0.6.5.2/tests/sphere_volume.tex0000644000000000000000000000074212236473702016274 0ustar0000000000000000S = \{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*}
texmath-0.6.5.2/tests/sphere_volume.xhtml0000644000000000000000000001223412236473702016627 0ustar0000000000000000

  
    
  
  
    
      
        S
        =
        {
        0
        
        ϕ
        
        2
        π
        ,
         
        0
        
        θ
        
        π
        ,
         
        0
        
        ρ
        
        R
        }
        
          
            
              Volume
            
            
              =
              
                
                S
              
              
              
                ρ
                2
              
              sin
              θ
              
              d
              ρ
              
              d
              θ
              
              d
              ϕ
            
          
          
            
            
              =
              
                
                0
                
                  2
                  π
                
              
              
              d
              ϕ
              
              
                
                0
                π
              
              
              sin
              θ
              
              d
              θ
              
              
                
                0
                R
              
              
              
                ρ
                2
              
              d
              ρ
            
          
          
            
            
              =
              ϕ
              
                
                0
                
                  2
                  π
                
              
               
              (
              
              cos
              θ
              )
              
                
                0
                π
              
               
              
                
                  1
                  3
                
              
              
                ρ
                3
              
              
                
                0
                R
              
            
          
          
            
            
              =
              2
              π
              ×
              2
              ×
              
                
                  1
                  3
                
              
              
                R
                3
              
            
          
          
            
            
              =
              
                
                  4
                  3
                
              
              π
              
                R
                3
              
            
          
        
      
    
  

texmath-0.6.5.2/tests/stackrel.omml0000644000000000000000000000121612236473702015370 0ustar0000000000000000

  
    
  
  
    
      
        
          
          u
        
      
      
        
          
          n
        
      
    
    
      
        
          
          
        
      
      
        
          
          w
        
      
    
    
      
      u
    
  

texmath-0.6.5.2/tests/stackrel.tex0000644000000000000000000000003112236473702015216 0ustar0000000000000000u_n \stackrel{w}{\to} u

texmath-0.6.5.2/tests/stackrel.xhtml0000644000000000000000000000073512236473702015565 0ustar0000000000000000

  
    
  
  
    
      
        
          u
          n
        
        
          
          w
        
        u
      
    
  

texmath-0.6.5.2/tests/subsup.omml0000644000000000000000000001664012236473702015110 0ustar0000000000000000

  
    
  
  
    
      
        
          
          x
        
      
      
        
          
          b
        
      
      
        
          
          a
        
      
    
    
      
      
    
    
      
        
          
          x
        
      
      
        
          
          b
        
      
      
        
          
          a
        
      
    
    
      
      
    
    
      
        
          
            
          
          min
        
      
      
        
          
          A
        
      
    
    
      
      
    
    
      
        
          
            
          
          max
        
      
      
        
          
          B
        
      
    
    
      
      
    
    
      
        
          
            
          
          det
        
      
      
        
          
          C
        
      
    
    
      
      
    
    
      
        
          
            
          
          Pr
        
      
      
        
          
          A
        
      
    
    
      
      
    
    
      
        
          
            
          
          gcd
        
      
      
        
          
          A
        
      
    
    
      
      
    
    
      
        
          
            
          
          
            
              
              u
            
          
        
      
      
        
          
          2
        
      
    
    
      
      
    
    
      
        
          
            
          
          
            
              
              u
            
          
        
      
      
        
          
          ɛ
        
      
    
    
      
      
    
    
      
        
          
            
          
          
            
              
              u
            
          
        
      
      
        
          
          b
        
      
      
        
          
          a
        
      
    
    
      
      
    
    
      
        
          
            
          
          
            
              
              a
            
            
              
              +
            
            
              
              b
            
          
        
      
      
        
          
            
          
          term
        
      
    
    
      
      
    
    
      
        
          
            
          
          
            
              
              a
            
            
              
              +
            
            
              
              b
            
          
        
      
      
        
          
          c
        
      
    
    
      
      
    
    
      
        
          
            
              
              a
            
            
              
              +
            
            
              
              b
            
          
          
            
              
              
            
          
        
      
      
        
          
          c
        
      
    
    
      
      
    
    
      
        
          
            
              
              a
            
            
              
              +
            
            
              
              b
            
          
          
            
              
              
            
          
        
      
      
        
          
          c
        
      
    
    
      
        
          
          
        
      
      
        
          
          H
        
      
    
    
      
      e
    
    
      
      3
    
    
      
        
          
          
        
      
      
        
          
          x
        
      
    
    
      
      A
    
    
      
        
          
          
        
      
      
        
          
          x
        
      
      
        
          
          3
        
      
    
  

texmath-0.6.5.2/tests/subsup.tex0000644000000000000000000000046212236473702014737 0ustar0000000000000000 x^a_b\quad
 x_b^a\quad
 \min_A\quad
 \max_B\quad
 \det_C\quad
 \Pr_A\quad
 \gcd_A\quad
 \dot{u}^2\quad
 \overline{u}_\varepsilon\quad
 \underline{u}^a_b\quad
 \overbrace{a+b}^{\text{term}}\quad
 \overbracket{a+b}^{c}\quad
 \underbrace{a+b}_{c}\quad
 \underbracket{a+b}_{c}\quad
 ^He3\quad
 _xA\quad
 _x^3
texmath-0.6.5.2/tests/subsup.xhtml0000644000000000000000000000610212236473702015270 0ustar0000000000000000

  
    
  
  
    
      
        
          x
          b
          a
        
        
        
          x
          b
          a
        
        
        
          min
          A
        
        
        
          max
          B
        
        
        
          det
          C
        
        
        
          Pr
          A
        
        
        
          gcd
          A
        
        
        
          
            u
            ̇
          
          2
        
        
        
          
            u
            ¯
          
          ɛ
        
        
        
          
            u
            ¯
          
          b
          a
        
        
        
          
            
              a
              +
              b
            
            
          
          term
        
        
        
          
            
              a
              +
              b
            
            
          
          c
        
        
        
          
            
              a
              +
              b
            
            
          
          c
        
        
        
          
            
              a
              +
              b
            
            
          
          c
        
        
          
          H
        
        e
        3
        
          
          x
        
        A
        
          
          x
          3
        
      
    
  

texmath-0.6.5.2/tests/unicode.omml0000644000000000000000000000065012236473702015207 0ustar0000000000000000

  
    
  
  
    
      
      f
    
    
      
      :
    
    
      
      X
    
    
      
      
    
    
      
      Y
    
  

texmath-0.6.5.2/tests/unicode.tex0000644000000000000000000000001412236473702015035 0ustar0000000000000000f : X → Y
texmath-0.6.5.2/tests/unicode.xhtml0000644000000000000000000000062512236473702015401 0ustar0000000000000000

  
    
  
  
    
      
        f
        :
        X
        
        Y
      
    
  

texmath-0.6.5.2/Text/0000755000000000000000000000000012236473702012454 5ustar0000000000000000texmath-0.6.5.2/Text/TeXMath.hs0000644000000000000000000000327112236473702014325 0ustar0000000000000000{-
Copyright (C) 2009-2012 John MacFarlane 

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-}

{- | Functions for converting LaTeX math formulas to MathML.
-}

module Text.TeXMath ( texMathToMathML, texMathToOMML, texMathToPandoc,
                      DisplayType(..) )
where
import Text.TeXMath.Parser
import Text.TeXMath.MathML
import Text.TeXMath.OMML
import Text.TeXMath.Pandoc
import Text.TeXMath.Types
import Text.XML.Light
import Text.Pandoc.Definition

texMathToMathML :: DisplayType -> String -> Either String Element
texMathToMathML dt inp = inp `seq`
  either Left (Right . toMathML dt) $ parseFormula inp

texMathToOMML :: DisplayType -> String -> Either String Element
texMathToOMML dt inp = inp `seq`
  either Left (Right . toOMML dt) $ parseFormula inp

texMathToPandoc :: DisplayType -> String -> Either String [Inline]
texMathToPandoc dt inp = inp `seq`
  either Left (Right . maybe fallback id . toPandoc dt) $ parseFormula inp
  where fallback = [Str $ delim ++ inp ++ delim]
        delim    = case dt of { DisplayInline -> "$"; DisplayBlock -> "$$" }
texmath-0.6.5.2/Text/TeXMath/0000755000000000000000000000000012236473702013766 5ustar0000000000000000texmath-0.6.5.2/Text/TeXMath/Macros.hs0000644000000000000000000001440512236473702015552 0ustar0000000000000000{-# LANGUAGE RankNTypes #-}
{-
Copyright (C) 2010 John MacFarlane 

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-}

{- | Functions for parsing LaTeX macro definitions and applying macros
 to LateX expressions.
-}

module Text.TeXMath.Macros ( Macro
                           , parseMacroDefinitions
                           , applyMacros
                           )
where

import Data.Char (isDigit, isLetter)
import Control.Monad
import Text.ParserCombinators.Parsec

data Macro = Macro { macroDefinition :: String
                   , macroParser     :: forall st . GenParser Char st String }

instance Show Macro where
  show m = "Macro " ++ show (macroDefinition m)

-- | 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 :: String -> ([Macro], String)
parseMacroDefinitions s =
  case parse pMacroDefinitions "input" s of
       Left _       -> ([], s)
       Right res    -> res

-- | Parses one or more macro definitions separated by comments & space.
-- Return list of macros parsed + remainder of string.
pMacroDefinitions :: GenParser Char st ([Macro], String)
pMacroDefinitions = do
  defs <- sepEndBy pMacroDefinition pSkipSpaceComments
  rest <- getInput
  return (reverse defs, rest)  -- reversed so later macros shadow earlier

-- | Parses a @\\newcommand@ or @\\renewcommand@ macro definition and
-- returns a 'Macro'.
pMacroDefinition :: GenParser Char st Macro
pMacroDefinition = newcommand

-- | Skip whitespace and comments.
pSkipSpaceComments :: GenParser Char st ()
pSkipSpaceComments = spaces >> skipMany (comment >> spaces)

-- | 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] -> String -> String
applyMacros [] = id
applyMacros ms = iterateToFixedPoint ((2 * length ms) + 1) $ applyMacrosOnce ms

------------------------------------------------------------------------------

iterateToFixedPoint :: Eq a => Int -> (a -> a) -> a -> a
iterateToFixedPoint 0     _ _ = error $
  "Macro application did not terminate in a reasonable time.\n" ++
  "Check your macros for loops."
iterateToFixedPoint limit f x =
  if x' == x
     then x'
     else iterateToFixedPoint (limit - 1) f x'
    where x' = f x

applyMacrosOnce :: [Macro] -> String -> String
applyMacrosOnce ms s =
  case parse (many tok) "input" s of
       Right r -> concat r
       Left _  -> s  -- just return original on error
    where tok = try $ do
                  skipComment
                  choice [ choice (map macroParser ms)
                         , ctrlseq
                         , count 1 anyChar ]

ctrlseq :: GenParser Char st String
ctrlseq = do
          char '\\'
          res <- many1 letter <|> count 1 anyChar
          return $ '\\' : res

newcommand :: GenParser Char st Macro
newcommand = try $ do
  char '\\'
  optional $ try $ string "re"
  string "newcommand"
  pSkipSpaceComments
  name <- inbraces <|> ctrlseq
  guard (take 1 name == "\\")
  let name' = drop 1 name
  pSkipSpaceComments
  numargs <- numArgs
  pSkipSpaceComments
  optarg <- if numargs > 0
               then optArg
               else return Nothing
  let numargs' = case optarg of
                   Just _  -> numargs - 1
                   Nothing -> numargs
  pSkipSpaceComments
  body <- inbraces <|> ctrlseq
  let defn = "\\newcommand{" ++ name ++ "}" ++
             (if numargs > 0 then ("[" ++ show numargs ++ "]") else "") ++
             case optarg of { Nothing -> ""; Just x -> "[" ++ x ++ "]"} ++
             "{" ++ body ++ "}"
  return $ Macro defn $ try $ do
    char '\\'
    string name'
    when (all isLetter name') $
      notFollowedBy letter
    pSkipSpaceComments
    opt <- case optarg of
                Nothing  -> return Nothing
                Just _   -> liftM (`mplus` optarg) optArg
    args <- count numargs' (pSkipSpaceComments >>
                  (inbraces <|> ctrlseq <|> count 1 anyChar))
    let args' = case opt of
                     Just x  -> x : args
                     Nothing -> args
    return $ apply args' body

apply :: [String] -> String -> String
apply args ('#':d:xs) | isDigit d =
  let argnum = read [d]
  in  if length args >= argnum
         then args !! (argnum - 1) ++ apply args xs
         else '#' : d : apply args xs
apply args ('\\':'#':xs) = '\\':'#' : apply args xs
apply args (x:xs) = x : apply args xs
apply _ "" = ""

skipComment :: GenParser Char st ()
skipComment = skipMany comment

comment :: GenParser Char st ()
comment = do
  char '%'
  skipMany (notFollowedBy newline >> anyChar)
  newline
  return ()

numArgs :: GenParser Char st Int
numArgs = option 0 $ do
  pSkipSpaceComments
  char '['
  pSkipSpaceComments
  n <- digit
  pSkipSpaceComments
  char ']'
  return $ read [n]

optArg :: GenParser Char st (Maybe String)
optArg = option Nothing $ (liftM Just $ inBrackets)

escaped :: String -> GenParser Char st String
escaped xs = try $ char '\\' >> oneOf xs >>= \x -> return ['\\',x]

inBrackets :: GenParser Char st String
inBrackets = try $ do
  char '['
  pSkipSpaceComments
  res <- manyTill (skipComment >> (escaped "[]" <|> count 1 anyChar))
          (try $ pSkipSpaceComments >> char ']')
  return $ concat res

inbraces :: GenParser Char st String
inbraces = try $ do
  char '{'
  res <- manyTill (skipComment >> (inbraces' <|> count 1 anyChar <|> escaped "{}"))
    (try $ skipComment >> char '}')
  return $ concat res

inbraces' :: GenParser Char st String
inbraces' = do
  res <- inbraces
  return $ '{' : (res ++ "}")

texmath-0.6.5.2/Text/TeXMath/MathML.hs0000644000000000000000000001676112236473702015457 0ustar0000000000000000{-
Copyright (C) 2009 John MacFarlane 

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-}

{- | Functions for writing a parsed formula as MathML.
-}

module Text.TeXMath.MathML (toMathML, showExp)
where

import qualified Data.Map as M
import Text.XML.Light
import Text.TeXMath.Types
import Text.TeXMath.ToUnicode
import Data.Generics (everywhere, mkT)

toMathML :: DisplayType -> [Exp] -> Element
toMathML dt exprs =
  add_attr dtattr $ math $ map showExp $ everywhere (mkT $ handleDownup dt) exprs
    where dtattr = Attr (unqual "display") dt'
          dt' =  case dt of
                      DisplayBlock  -> "block"
                      DisplayInline -> "inline"

math :: [Element] -> Element
math = add_attr (Attr (unqual "xmlns") "http://www.w3.org/1998/Math/MathML") . unode "math" . unode "mrow"

mrow :: [Element] -> Element
mrow = unode "mrow"

{- Firefox seems to set spacing based on its own dictionary,
-  so I believe this is unnecessary.
 
setSpacing :: String -> String -> Bool -> Element -> Element
setSpacing left right stretchy elt =
  add_attr (Attr (unqual "lspace") left) $
  add_attr (Attr (unqual "rspace") right) $
  if stretchy
     then add_attr (Attr (unqual "stretchy") "true") elt
     else elt

showSymbol (ESymbol s x) =
  case s of
    Ord   x  -> unode "mo" x
    Op    x  -> setSpacing "0" "0.167em" True $ unode "mo" x
    Bin   x  -> setSpacing "0.222em" "0.222em" False $ unode "mo" x
    Rel   x  -> setSpacing "0.278em" "0.278em" False $ unode "mo" x
    Open  x  -> setSpacing "0" "0" True $ unode "mo" x
    Close x  -> setSpacing "0" "0" True $ unode "mo" x
    Pun   x  -> setSpacing "0" "0.167em" False $ unode "mo" x
-}

unaryOps :: M.Map String String
unaryOps = M.fromList
  [ ("\\sqrt", "msqrt")
  , ("\\surd", "msqrt")
  ]

showUnary :: String -> Exp -> Element
showUnary c x =
  case M.lookup c unaryOps of
       Just c'  -> unode c' (showExp x)
       Nothing  -> error $ "Unknown unary op: " ++ c

binaryOps :: M.Map String ([Element] -> Element)
binaryOps = M.fromList
  [ ("\\frac", unode "mfrac")
  , ("\\tfrac", withAttribute "displaystyle" "false" .
                  unode "mstyle" . unode "mfrac")
  , ("\\dfrac", withAttribute "displaystyle" "true" .
                  unode "mstyle" . unode "mfrac")
  , ("\\sqrt", unode "mroot")
  , ("\\stackrel", unode "mover" . reverse)
  , ("\\overset", unode "mover" . reverse)
  , ("\\underset", unode "munder" . reverse)
  , ("\\binom", showBinom)
  ]

showBinom :: [Element] -> Element
showBinom lst = unode "mfenced" $ withAttribute "linethickness" "0" $ unode "mfrac" lst

showBinary :: String -> Exp -> Exp -> Element
showBinary c x y =
  case M.lookup c binaryOps of
       Just f   -> f [showExp x, showExp y]
       Nothing  -> error $ "Unknown binary op: " ++ c

spaceWidth :: String -> Element
spaceWidth w = withAttribute "width" w $ unode "mspace" ()

makeStretchy :: Element -> Element
makeStretchy = withAttribute "stretchy" "true"

makeScaled :: String -> Element -> Element
makeScaled s = withAttribute "minsize" s . withAttribute "maxsize" s

-- Note: Converts strings to unicode directly, as few renderers support those mathvariants.
makeText :: TextType -> String -> Element
makeText a s = if trailingSp
                  then mrow [s', sp]
                  else s'
  where sp = spaceWidth "0.333em"
        s' = withAttribute "mathvariant" attr $ unode "mtext" $ toUnicode a s 
        trailingSp = not (null s) && last s `elem` " \t"
        attr = case a of
                    TextNormal       -> "normal"
                    TextBold         -> "bold"
                    TextItalic       -> "italic"
                    TextMonospace    -> "monospace"
                    TextSansSerif    -> "sans-serif"
                    TextDoubleStruck -> "double-struck"
                    TextScript       -> "script"
                    TextFraktur      -> "fraktur"
                    TextBoldItalic          -> "bold-italic"
                    TextBoldSansSerif       -> "bold-sans-serif"
                    TextBoldSansSerifItalic -> "sans-serif-bold-italic"
                    TextBoldScript          -> "bold-script"
                    TextBoldFraktur         -> "bold-fraktur"
                    TextSansSerifItalic     -> "sans-serif-italic"

makeArray :: [Alignment] -> [ArrayLine] -> Element
makeArray as ls = unode "mtable" $
  map (unode "mtr" .
    zipWith (\a -> setAlignment a .  unode "mtd". map showExp) as') ls
   where setAlignment AlignLeft    = withAttribute "columnalign" "left"
         setAlignment AlignRight   = withAttribute "columnalign" "right"
         setAlignment AlignCenter  = withAttribute "columnalign" "center"
         setAlignment AlignDefault = id 
         as'                       = as ++ cycle [AlignDefault]

withAttribute :: String -> String -> Element -> Element
withAttribute a = add_attr . Attr (unqual a)

accent :: String -> Element
accent = add_attr (Attr (unqual "accent") "true") .
           unode "mo"

handleDownup :: DisplayType -> Exp -> Exp
handleDownup DisplayInline (EDown x y)     = ESub x y
handleDownup DisplayBlock  (EDown x y)     = EUnder x y
handleDownup DisplayInline (EUp x y)       = ESuper x y
handleDownup DisplayBlock  (EUp x y)       = EOver x y
handleDownup DisplayInline (EDownup x y z) = ESubsup x y z
handleDownup DisplayBlock  (EDownup x y z) = EUnderover x y z
handleDownup _             x               = x

showExp :: Exp -> Element
showExp e =
 case e of
   ENumber x        -> unode "mn" x
   EGrouped [x]     -> showExp x
   EGrouped xs      -> mrow $ map showExp xs
   EDelimited start end xs -> mrow $
                       [ makeStretchy (unode "mo" start) | not (null start) ] ++
                       map showExp xs ++
                       [ makeStretchy (unode "mo" end) | not (null end) ] 
   EIdentifier x    -> unode "mi" x
   EMathOperator x  -> unode "mi" x
   ESymbol Accent x -> accent x
   EStretchy (ESymbol Open x)  -> makeStretchy $ unode "mo" x
   EStretchy (ESymbol Close x) -> makeStretchy $ unode "mo" x
   ESymbol Open x   -> withAttribute "stretchy" "false" $ unode "mo" x
   ESymbol Close x  -> withAttribute "stretchy" "false" $ unode "mo" x
   ESymbol _ x      -> unode "mo" x
   ESpace x         -> spaceWidth x
   EBinary c x y    -> showBinary c x y
   ESub x y         -> unode "msub" $ map showExp [x, y]
   ESuper x y       -> unode "msup" $ map showExp [x, y]
   ESubsup x y z    -> unode "msubsup" $ map showExp [x, y, z]
   EUnder x y       -> unode "munder" $ map showExp [x, y]
   EOver x y        -> unode "mover" $ map showExp [x, y]
   EUnderover x y z -> unode "munderover" $ map showExp [x, y, z]
   EUnary c x       -> showUnary c x
   EStretchy x      -> makeStretchy $ showExp x
   EScaled s x      -> makeScaled s $ showExp x
   EArray as ls     -> makeArray as ls
   EText a s        -> makeText a s
   x                -> error $ "showExp encountered " ++ show x
                       -- note: EUp, EDown, EDownup should be removed by handleDownup

texmath-0.6.5.2/Text/TeXMath/OMML.hs0000644000000000000000000002467412236473702015103 0ustar0000000000000000{-
Copyright (C) 2012 John MacFarlane 

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-}

{- | Functions for writing a parsed formula as OMML.
-}

module Text.TeXMath.OMML (toOMML, showExp)
where

import Text.XML.Light
import Text.TeXMath.Types
import Data.Generics (everywhere, mkT)

toOMML :: DisplayType -> [Exp] -> Element
toOMML dt = container . concatMap showExp
            . everywhere (mkT $ handleDownup dt)
    where container = case dt of
                  DisplayBlock  -> \x -> mnode "oMathPara"
                                    [ mnode "oMathParaPr"
                                      $ mnodeA "jc" "center" ()
                                    , mnode "oMath" x ]
                  DisplayInline -> mnode "oMath"

mnode :: Node t => String -> t -> Element
mnode s = node (QName s Nothing (Just "m"))

mnodeA :: Node t => String -> String -> t -> Element
mnodeA s v = add_attr (Attr (QName "val" Nothing (Just "m")) v) . mnode s

str :: [Element] -> String -> Element
str props s = mnode "r" [ mnode "rPr" props
                        , mnode "t" s ]

showBinary :: String -> Exp -> Exp -> Element
showBinary c x y =
  case c of
       "\\frac" -> mnode "f" [ mnode "fPr" $
                                mnodeA "type" "bar" ()
                             , mnode "num" x'
                             , mnode "den" y']
       "\\dfrac" -> showBinary "\\frac" x y
       "\\tfrac" -> mnode "f" [ mnode "fPr" $
                                 mnodeA "type" "lin" ()
                              , mnode "num" x'
                              , mnode "den" y']
       "\\sqrt"  -> mnode "rad" [ mnode "radPr" $
                                   mnodeA "degHide" "on" ()
                                , mnode "deg" y'
                                , mnode "e" x']
       "\\stackrel" -> mnode "limUpp" [ mnode "e" y'
                                       , mnode "lim" x']
       "\\overset" -> mnode "limUpp" [ mnode "e" y'
                                     , mnode "lim" x' ]
       "\\underset" -> mnode "limLow" [ mnode "e" y'
                                      , mnode "lim" x' ]
       "\\binom"    -> mnode "d" [ mnode "dPr" $
                                     mnodeA "sepChr" "," ()
                                 , mnode "e" $
                                     mnode "f" [ mnode "fPr" $
                                                   mnodeA "type"
                                                     "noBar" ()
                                               , mnode "num" x'
                                               , mnode "den" y' ]] 
       _ -> error $ "Unknown binary operator " ++ c
    where x' = showExp x
          y' = showExp y

makeArray :: [Alignment] -> [ArrayLine] -> Element
makeArray as rs = mnode "m" $ mProps : map toMr rs
  where mProps = mnode "mPr"
                  [ mnodeA "baseJc" "center" ()
                  , mnodeA "plcHide" "on" ()
                  , mnode "mcs" $ map toMc as' ]
        as'    = take (length rs) $ as ++ cycle [AlignDefault]
        toMr r = mnode "mr" $ map (mnode "e" . concatMap showExp) r
        toMc a = mnode "mc" $ mnode "mcPr"
                            $ mnodeA "mcJc" (toAlign a) ()
        toAlign AlignLeft    = "left"
        toAlign AlignRight   = "right"
        toAlign AlignCenter  = "center"
        toAlign AlignDefault = "left"

makeText :: TextType -> String -> Element
makeText a s = str attrs s
  where attrs = case a of
                     TextNormal       -> [sty "p"]
                     TextBold         -> [sty "b"]
                     TextItalic       -> [sty "i"]
                     TextMonospace    -> [sty "p", scr "monospace"]
                     TextSansSerif    -> [sty "p", scr "sans-serif"]
                     TextDoubleStruck -> [sty "p", scr "double-struck"]
                     TextScript       -> [sty "p", scr "script"]
                     TextFraktur      -> [sty "p", scr "fraktur"]
                     TextBoldItalic    -> [sty "i"]
                     TextBoldSansSerif -> [sty "b", scr "sans-serif"]
                     TextBoldScript    -> [sty "b", scr "script"]
                     TextBoldFraktur   -> [sty "b", scr "fraktur"]
                     TextSansSerifItalic -> [sty "i", scr "sans-serif"]
                     TextBoldSansSerifItalic -> [sty "bi", scr "sans-serif"]
        sty x = mnodeA "sty" x ()
        scr x = mnodeA "scr" x ()

handleDownup :: DisplayType -> [Exp] -> [Exp]
handleDownup dt (exp' : xs) =
  case exp' of
       EDown x y
         | isNary x  -> EGrouped [constructor x y emptyGroup, next] : rest
         | otherwise -> case dt of
                             DisplayBlock  -> EUnder x y : xs
                             DisplayInline -> ESub x y : xs
       EUp   x y
         | isNary x  -> EGrouped [constructor x emptyGroup y, next] : rest
         | otherwise -> case dt of
                             DisplayBlock  -> EOver x y : xs
                             DisplayInline -> ESuper x y : xs
       EDownup x y z
         | isNary x  -> EGrouped [constructor x y z, next] : rest
         | otherwise -> case dt of
                             DisplayBlock  -> EUnderover x y z : xs
                             DisplayInline -> ESubsup x y z : xs
       ESub x y
         | isNary x  -> EGrouped [ESubsup x y emptyGroup, next] : rest
       ESuper x y
         | isNary x  -> EGrouped [ESubsup x emptyGroup y, next] : rest
       ESubsup x y z
         | isNary x  -> EGrouped [ESubsup x y z, next] : rest
       EOver x y
         | isNary x  -> EGrouped [EUnderover x y emptyGroup, next] : rest
       EUnder x y
         | isNary x  -> EGrouped [EUnderover x emptyGroup y, next] : rest
       EUnderover x y z
         | isNary x  -> EGrouped [EUnderover x y z, next] : rest
       _             -> exp' : next : rest
    where (next, rest) = case xs of
                              (t:ts) -> (t,ts)
                              []     -> (emptyGroup, [])
          emptyGroup = EGrouped []
          constructor = case dt of
                             DisplayBlock  -> EUnderover
                             DisplayInline -> ESubsup
handleDownup _ []            = []

showExp :: Exp -> [Element]
showExp e =
 case e of
   ENumber x        -> [str [] x]
   EGrouped [EUnderover (ESymbol Op s) y z, w] -> [makeNary "undOvr" s y z w]
   EGrouped [ESubsup (ESymbol Op s) y z, w] -> [makeNary "subSup" s y z w]
   EGrouped xs      -> concatMap showExp xs
   EDelimited start end xs ->
                       [mnode "d" [ mnode "dPr"
                                    [ mnodeA "begChr" start ()
                                    , mnodeA "endChr" end ()
                                    , mnode "grow" () ]
                                  , mnode "e" $ concatMap showExp xs
                                  ] ]

   EIdentifier x    -> [str [] x]
   EMathOperator x  -> [makeText TextNormal x]
   EStretchy x      -> showExp x  -- no support for stretchy in OMML
   ESymbol _ x      -> [str [] x]
   ESpace "0.167em" -> [str [] "\x2009"]
   ESpace "0.222em" -> [str [] "\x2005"]
   ESpace "0.278em" -> [str [] "\x2004"]
   ESpace "0.333em" -> [str [] "\x2004"]
   ESpace "1em"     -> [str [] "\x2001"]
   ESpace "2em"     -> [str [] "\x2001\x2001"]
   ESpace _         -> [] -- this is how the xslt sheet handles all spaces
   EBinary c x y    -> [showBinary c x y]
   EUnder x (ESymbol Accent [c]) | isBarChar c ->
                       [mnode "bar" [ mnode "barPr" $
                                        mnodeA "pos" "bot" ()
                                    , mnode "e" $ showExp x ]]
   EOver x (ESymbol Accent [c]) | isBarChar c ->
                       [mnode "bar" [ mnode "barPr" $
                                        mnodeA "pos" "top" ()
                                    , mnode "e" $ showExp x ]]
   EOver x (ESymbol Accent y) ->
                       [mnode "acc" [ mnode "accPr" $
                                        mnodeA "chr" y ()
                                    , mnode "e" $ showExp x ]]
   ESub x y         -> [mnode "sSub" [ mnode "e" $ showExp x
                                     , mnode "sub" $ showExp y]]
   ESuper x y       -> [mnode "sSup" [ mnode "e" $ showExp x
                                     , mnode "sup" $ showExp y]]
   ESubsup x y z    -> [mnode "sSubSup" [ mnode "e" $ showExp x
                                        , mnode "sub" $ showExp y
                                        , mnode "sup" $ showExp z]]
   EUnder x y       -> [mnode "limLow" [ mnode "e" $ showExp x
                                       , mnode "lim" $ showExp y]]
   EOver x y        -> [mnode "limUpp" [ mnode "e" $ showExp x
                                       , mnode "lim" $ showExp y]]
   EUnderover x y z -> showExp (EUnder x (EOver y z))
   EUnary "\\sqrt" x  -> [mnode "rad" [ mnode "radPr" $ mnodeA "degHide" "on" ()
                                      , mnode "deg" ()
                                      , mnode "e" $ showExp x]]
   EUnary "\\surd" x  -> showExp $ EUnary "\\sqrt" x
   EScaled _ x      -> showExp x   -- no support for scaler?
   EArray as ls     -> [makeArray as ls]
   EText a s        -> [makeText a s]
   x                -> error $ "showExp encountered " ++ show x
   -- note: EUp, EDown, EDownup should be removed by handleDownup

isBarChar :: Char -> Bool
isBarChar c = c == '\x203E' || c == '\x00AF'

isNary :: Exp -> Bool
isNary (ESymbol Op _) = True
isNary _ = False

makeNary :: String -> String -> Exp -> Exp -> Exp -> Element
makeNary t s y z w =
  mnode "nary" [ mnode "naryPr"
                 [ mnodeA "chr" s ()
                 , mnodeA "limLoc" t ()
                 , mnodeA "supHide"
                    (if y == EGrouped [] then "on" else "off") ()
                 , mnodeA "supHide"
                    (if y == EGrouped [] then "on" else "off") ()
                 ]
               , mnode "e" $ showExp w
               , mnode "sub" $ showExp y
               , mnode "sup" $ showExp z ]

texmath-0.6.5.2/Text/TeXMath/Pandoc.hs0000644000000000000000000001007512236473702015531 0ustar0000000000000000{-
Copyright (C) 2010-2013 John MacFarlane 

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-}

{- | Functions for writing a parsed formula as a list of Pandoc
     Inlines.
-}

module Text.TeXMath.Pandoc (toPandoc)
where
import Text.Pandoc.Definition
import Text.TeXMath.Types

-- | Converts a formula to a list of 'Pandoc' inlines.
-- Defaults to raw formula between @$@ characters if entire formula
-- can't be converted.
toPandoc :: DisplayType
         -> [Exp]
         -> Maybe [Inline]
toPandoc _ exps = expsToInlines exps

expsToInlines :: [Exp] -> Maybe [Inline]
expsToInlines xs = do
  res <- mapM expToInlines xs
  return (concat res)

expToInlines :: Exp -> Maybe [Inline]
expToInlines (ENumber s) = Just [Str s]
expToInlines (EIdentifier s) = Just [Emph [Str s]]
expToInlines (EMathOperator s) = Just [Str s]
expToInlines (ESymbol t s) = Just $ addSpace t (Str s)
  where addSpace Op x = [x, thinspace]
        addSpace Bin x = [medspace, x, medspace]
        addSpace Rel x = [widespace, x, widespace]
        addSpace Pun x = [x, thinspace]
        addSpace _ x = [x]
        thinspace = Str "\x2006"
        medspace  = Str "\x2005"
        widespace = Str "\x2004"
expToInlines (EStretchy x) = expToInlines x
expToInlines (EDelimited start end xs) = do
  xs' <- mapM expToInlines xs
  return $ [Str start] ++ concat xs' ++ [Str end]
expToInlines (EGrouped xs) = expsToInlines xs
expToInlines (ESpace "0.167em") = Just [Str "\x2009"]
expToInlines (ESpace "0.222em") = Just [Str "\x2005"]
expToInlines (ESpace "0.278em") = Just [Str "\x2004"]
expToInlines (ESpace "0.333em") = Just [Str "\x2004"]
expToInlines (ESpace "1em")     = Just [Str "\x2001"]
expToInlines (ESpace "2em")     = Just [Str "\x2001\x2001"]
expToInlines (ESpace _)         = Just [Str " "]
expToInlines (EBinary _ _ _) = Nothing
expToInlines (ESub x y) = do
  x' <- expToInlines x
  y' <- expToInlines y
  return $ x' ++ [Subscript y']
expToInlines (ESuper x y) = do
  x' <- expToInlines x
  y' <- expToInlines y
  return $ x' ++ [Superscript y']
expToInlines (ESubsup x y z) = do
  x' <- expToInlines x
  y' <- expToInlines y
  z' <- expToInlines z
  return $ x' ++ [Subscript y'] ++ [Superscript z']
expToInlines (EDown x y) = expToInlines (ESub x y)
expToInlines (EUp x y) = expToInlines (ESuper x y)
expToInlines (EDownup x y z) = expToInlines (ESubsup x y z)
expToInlines (EText TextNormal x) = Just [Str x]
expToInlines (EText TextBold x) = Just [Strong [Str x]]
expToInlines (EText TextMonospace x) = Just [Code nullAttr x]
expToInlines (EText TextItalic x) = Just [Emph [Str x]]
expToInlines (EText _ x) = Just [Str x]
expToInlines (EOver (EGrouped [EIdentifier [c]]) (ESymbol Accent [accent])) =
    case accent of
         '\x203E' -> Just [Emph [Str [c,'\x0304']]]  -- bar
         '\x00B4' -> Just [Emph [Str [c,'\x0301']]]  -- acute
         '\x0060' -> Just [Emph [Str [c,'\x0300']]]  -- grave
         '\x02D8' -> Just [Emph [Str [c,'\x0306']]]  -- breve
         '\x02C7' -> Just [Emph [Str [c,'\x030C']]]  -- check
         '.'      -> Just [Emph [Str [c,'\x0307']]]  -- dot
         '\x00B0' -> Just [Emph [Str [c,'\x030A']]]  -- ring
         '\x20D7' -> Just [Emph [Str [c,'\x20D7']]]  -- arrow right
         '\x20D6' -> Just [Emph [Str [c,'\x20D6']]]  -- arrow left
         '\x005E' -> Just [Emph [Str [c,'\x0302']]]  -- hat
         '\x0302' -> Just [Emph [Str [c,'\x0302']]]  -- hat
         '~'      -> Just [Emph [Str [c,'\x0303']]]  -- tilde
         _        -> Nothing
expToInlines _ = Nothing
texmath-0.6.5.2/Text/TeXMath/Parser.hs0000644000000000000000000007125112236473702015564 0ustar0000000000000000{-
Copyright (C) 2009 John MacFarlane 

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-}

{- | Functions for parsing a LaTeX formula to a Haskell representation.
-}

module Text.TeXMath.Parser (parseFormula)
where

import Control.Monad
import Data.Char (isDigit, isAscii)
import qualified Data.Map as M
import Text.ParserCombinators.Parsec
import qualified Text.ParserCombinators.Parsec.Token as P
import Text.ParserCombinators.Parsec.Language
import Text.TeXMath.Types
import Control.Applicative ((<*), (*>), (<$>))

type TP = GenParser Char ()

texMathDef :: LanguageDef st
texMathDef = LanguageDef
   { commentStart   = "\\label{"
   , commentEnd     = "}"
   , commentLine    = "%"
   , nestedComments = False
   , identStart     = letter
   , identLetter    = letter
   , opStart        = opLetter texMathDef
   , opLetter       = oneOf ":_+*/=^-(),;.?'~[]<>!"
   , reservedOpNames= []
   , reservedNames  = []
   , caseSensitive  = True
   }

-- The parser

expr1 :: TP Exp
expr1 =  choice [
    inbraces
  , variable
  , number
  , texSymbol
  , text
  , root
  , unary
  , binary
  , enclosure
  , bareSubSup
  , environment
  , diacritical
  , escaped
  , unicode
  , ensuremath
  ]

-- | Parse a formula, returning a list of 'Exp'.
parseFormula :: String -> Either String [Exp]
parseFormula inp =
  either (Left . show) (Right . id) $ parse formula "formula" inp

formula :: TP [Exp]
formula = do
  whiteSpace
  f <- many expr
  whiteSpace
  eof
  return f

expr :: TP Exp
expr = do
  optional (try $ symbol "\\displaystyle")
  a <- expr1
  limits <- limitsIndicator
  subSup limits a <|> superOrSubscripted limits a <|> return a

bareSubSup :: TP Exp
bareSubSup = subSup Nothing (EIdentifier "")
  <|> superOrSubscripted Nothing (EIdentifier "")

limitsIndicator :: TP (Maybe Bool)
limitsIndicator =
   try (symbol "\\limits" >> return (Just True))
  <|> try (symbol "\\nolimits" >> return (Just False))
  <|> return Nothing

inbraces :: TP Exp
inbraces = liftM EGrouped (braces $ many $ notFollowedBy (char '}') >> expr)

texToken :: TP Exp
texToken = texSymbol <|> inbraces <|> inbrackets <|>
             do c <- anyChar
                spaces
                return $ if isDigit c
                            then (ENumber [c])
                            else (EIdentifier [c])

inbrackets :: TP Exp
inbrackets = liftM EGrouped (brackets $ many $ notFollowedBy (char ']') >> expr)

number :: TP Exp
number = lexeme $ liftM ENumber $ many1 digit

enclosure :: TP Exp
enclosure = basicEnclosure <|> left <|> right <|> scaledEnclosure

basicEnclosure :: TP Exp
basicEnclosure = choice $ map (\(s, v) -> try (symbol s) >> return v) enclosures

left :: TP Exp
left = try $ do
  symbol "\\left"
  enc <- basicEnclosure <|> (try (symbol ".") >> return (ESymbol Open "\xFEFF"))
  case enc of
    (ESymbol Open _) -> tilRight enc <|> return (EStretchy enc)
    _ -> pzero

right :: TP Exp
right = try $ do
  symbol "\\right"
  enc <- basicEnclosure <|> (try (symbol ".") >> return (ESymbol Close "\xFEFF"))
  case enc of
    (ESymbol Close x) -> return (EStretchy $ ESymbol Open x)
    _ -> pzero

-- We want stuff between \left( and \right) to be in an mrow,
-- so that the scaling is based just on this unit, and not the
-- whole containing formula.
tilRight :: Exp -> TP Exp
tilRight start = try $ do
  contents <- manyTill expr
               (try $ symbol "\\right" >> lookAhead basicEnclosure)
  end <- basicEnclosure
  let startChar = case start of
                     ESymbol _ c -> c
                     _           -> ""
  let endChar   = case end of
                     ESymbol _ c -> c
                     _           -> ""
  return $ EDelimited startChar endChar contents

scaledEnclosure :: TP Exp
scaledEnclosure = try $ do
  cmd <- command
  case M.lookup cmd scalers of
       Just  r -> liftM (EScaled r . EStretchy) basicEnclosure
       Nothing -> pzero

endLine :: TP Char
endLine = try $ do
  symbol "\\\\"
  optional inbrackets  -- can contain e.g. [1.0in] for a line height, not yet supported
  return '\n'

arrayLine :: TP ArrayLine
arrayLine = notFollowedBy (try $ symbol "\\end" >> return '\n') >>
  sepBy1 (many (notFollowedBy endLine >> expr)) (symbol "&")

arrayAlignments :: TP [Alignment]
arrayAlignments = try $ do
  as <- braces (many letter)
  let letterToAlignment 'l' = AlignLeft
      letterToAlignment 'c' = AlignCenter
      letterToAlignment 'r' = AlignRight
      letterToAlignment _   = AlignDefault
  return $ map letterToAlignment as

environment :: TP Exp
environment = try $ do
  symbol "\\begin"
  name <- char '{' *> manyTill anyChar (char '}')
  spaces
  let name' = filter (/='*') name
  case M.lookup name' environments of
        Just env -> env <* spaces <* symbol "\\end"
                        <* braces (string name) <* spaces
        Nothing  -> mzero

environments :: M.Map String (TP Exp)
environments = M.fromList
  [ ("array", stdarray)
  , ("eqnarray", eqnarray)
  , ("align", align)
  , ("aligned", align)
  , ("alignat", inbraces *> spaces *> align)
  , ("alignedat", inbraces *> spaces *> align)
  , ("flalign", flalign)
  , ("flaligned", flalign)
  , ("cases", cases)
  , ("pmatrix", matrixWith "(" ")")
  , ("bmatrix", matrixWith "[" "]")
  , ("Bmatrix", matrixWith "{" "}")
  , ("vmatrix", matrixWith "\x2223" "\x2223")
  , ("Vmatrix", matrixWith "\x2225" "\x2225")
  , ("split", align)
  , ("multiline", gather)
  , ("gather", gather)
  , ("gathered", gather)
  ]

matrixWith :: String -> String -> TP Exp
matrixWith opendelim closedelim = do
  aligns <- option [] arrayAlignments
  lines' <- sepEndBy1 arrayLine endLine
  return $ EDelimited opendelim closedelim [EArray aligns lines']

stdarray :: TP Exp
stdarray = do
  aligns <- option [] arrayAlignments
  (EArray aligns) <$> sepEndBy1 arrayLine endLine

gather :: TP Exp
gather = (EArray []) <$> sepEndBy arrayLine endLine

eqnarray :: TP Exp
eqnarray = (EArray [AlignRight, AlignCenter, AlignLeft]) <$>
  sepEndBy1 arrayLine endLine

align :: TP Exp
align = (EArray [AlignRight, AlignLeft]) <$>
  sepEndBy1 arrayLine endLine

flalign :: TP Exp
flalign = (EArray [AlignLeft, AlignRight]) <$>
  sepEndBy1 arrayLine endLine

cases :: TP Exp
cases = do
  rs <- sepEndBy1 arrayLine endLine
  return $ EDelimited "{" "" [EArray [] rs]

variable :: TP Exp
variable = do
  v <- letter
  spaces
  return $ EIdentifier [v]

isConvertible :: Exp -> Bool
isConvertible (EMathOperator x) = x `elem` convertibleOps
  where convertibleOps = [ "lim","liminf","limsup","inf","sup"
                         , "min","max","Pr","det","gcd"
                         ]
isConvertible (ESymbol Rel _) = True
isConvertible (ESymbol Bin _) = True
isConvertible (ESymbol Op x) = x `elem` convertibleSyms
  where convertibleSyms = ["\x2211","\x220F","\x22C2",
           "\x22C3","\x22C0","\x22C1","\x2A05","\x2A06",
           "\x2210","\x2A01","\x2A02","\x2A00","\x2A04"]
isConvertible _ = False

-- check if sub/superscripts should always be under and over the expression
isUnderover :: Exp -> Bool
isUnderover (EOver _ (ESymbol Accent "\xFE37")) = True   -- \overbrace
isUnderover (EOver _ (ESymbol Accent "\x23B4")) = True   -- \overbracket
isUnderover (EUnder _ (ESymbol Accent "\xFE38")) = True  -- \underbrace
isUnderover (EUnder _ (ESymbol Accent "\x23B5")) = True  -- \underbracket
isUnderover _ = False

subSup :: Maybe Bool -> Exp -> TP Exp
subSup limits a = try $ do
  let sub1 = symbol "_" >> expr1
  let sup1 = symbol "^" >> expr1
  (b,c) <- try (do {m <- sub1; n <- sup1; return (m,n)})
       <|> (do {n <- sup1; m <- sub1; return (m,n)})
  return $ case limits of
            Just True  -> EUnderover a b c
            Nothing | isConvertible a -> EDownup a b c
                    | isUnderover a -> EUnderover a b c
            _          -> ESubsup a b c

superOrSubscripted :: Maybe Bool -> Exp -> TP Exp
superOrSubscripted limits a = try $ do
  c <- oneOf "^_"
  spaces
  b <- expr
  case c of
       '^' -> return $ case limits of
                        Just True  -> EOver a b
                        Nothing | isConvertible a -> EUp a b
                                | isUnderover a -> EOver a b
                        _          -> ESuper a b
       '_' -> return $ case limits of
                        Just True  -> EUnder a b
                        Nothing | isConvertible a -> EDown a b
                                | isUnderover a -> EUnder a b
                        _          -> ESub a b
       _   -> pzero

escaped :: TP Exp
escaped = lexeme $ try $
          char '\\' >>
          liftM (ESymbol Ord . (:[])) (satisfy isEscapable)
   where isEscapable '{' = True
         isEscapable '}' = True
         isEscapable '$' = True
         isEscapable '%' = True
         isEscapable '&' = True
         isEscapable '_' = True
         isEscapable '#' = True
         isEscapable '^' = True  -- actually only if followed by {}
         isEscapable ' ' = True
         isEscapable _   = False

unicode :: TP Exp
unicode = lexeme $ liftM (ESymbol Ord . (:[])) $ satisfy (not . isAscii)

ensuremath :: TP Exp
ensuremath = try $ lexeme (string "\\ensuremath") >> inbraces

command :: TP String
command = try $ char '\\' >> liftM ('\\':) (identifier <|> lexeme (count 1 anyChar))

unaryOps :: [String]
unaryOps = ["\\sqrt", "\\surd"]

-- Note: cal and scr are treated the same way, as unicode is lacking such two different sets for those.
textOps :: M.Map String (String -> Exp)
textOps = M.fromList
          [ ("\\textrm",     EText TextNormal . parseText)
          , ("\\mathrm",     EText TextNormal)
          , ("\\mathup",     EText TextNormal)
          , ("\\text",       EText TextNormal . parseText)
          , ("\\mbox",       EText TextNormal)
          , ("\\mathbf",     EText TextBold)
          , ("\\mathbfup",   EText TextBold)
          , ("\\textbf",     EText TextBold . parseText)
          , ("\\mathit",     EText TextItalic)
          , ("\\textit",     EText TextItalic . parseText)
          , ("\\mathtt",     EText TextMonospace)
          , ("\\texttt",     EText TextMonospace)
          , ("\\mathsf",     EText TextSansSerif)
          , ("\\mathsfup",   EText TextSansSerif)
          , ("\\mathbb",     EText TextDoubleStruck)
          , ("\\mathcal",    EText TextScript)
          , ("\\mathscr",    EText TextScript)
          , ("\\mathfrak",   EText TextFraktur)
          , ("\\mathbfit",   EText TextBoldItalic)
          , ("\\mathbfsfup", EText TextBoldSansSerif)
          , ("\\mathbfsfit", EText TextBoldSansSerifItalic)
          , ("\\mathbfscr",  EText TextBoldScript)
          , ("\\mathbffrak", EText TextBoldFraktur)
          , ("\\mathbfcal",  EText TextBoldScript)
          , ("\\mathsfit",   EText TextSansSerifItalic)
          ]

parseText :: String -> String
parseText ('`':'`':xs) = '\x201C' : parseText xs
parseText ('\'':'\'':xs) = '\x201D' : parseText xs
parseText ('\'':xs) = '\x2019' : parseText xs
parseText ('-':'-':'-':xs) = '\x2014' : parseText xs
parseText ('-':'-':xs) = '\x2013' : parseText xs
parseText ('\\':'l':'d':'o':'t':'s':xs) = '\x2026' : parseText xs
parseText ('~':xs) = '\xA0' : parseText xs
parseText (x:xs) = x : parseText xs
parseText [] = []

diacritical :: TP Exp
diacritical = try $ do
  c <- command
  case M.lookup c diacriticals of
       Just r  -> liftM r texToken
       Nothing -> pzero

diacriticals :: M.Map String (Exp -> Exp)
diacriticals = M.fromList
               [ ("\\acute", \e -> EOver e (ESymbol Accent "\x00B4"))
               , ("\\grave", \e -> EOver e (ESymbol Accent "\x0060"))
               , ("\\breve", \e -> EOver e (ESymbol Accent "\x02D8"))
               , ("\\check", \e -> EOver e (ESymbol Accent "\x02C7"))
               , ("\\dot", \e -> EOver e (ESymbol Accent "\x307"))
               , ("\\ddot", \e -> EOver e (ESymbol Accent "\x308"))
               , ("\\mathring", \e -> EOver e (ESymbol Accent "\x00B0"))
               , ("\\vec", \e -> EOver e (ESymbol Accent "\x20D7"))
               , ("\\overrightarrow", \e -> EOver e (ESymbol Accent "\x20D7"))
               , ("\\overleftarrow", \e -> EOver e (ESymbol Accent "\x20D6"))
               , ("\\hat", \e -> EOver e (ESymbol Accent "\x005E"))
               , ("\\widehat", \e -> EOver e (ESymbol Accent "\x0302"))
               , ("\\tilde", \e -> EOver e (ESymbol Accent "~"))
               , ("\\widetilde", \e -> EOver e (ESymbol Accent "\x02DC"))
               , ("\\bar", \e -> EOver e (ESymbol Accent "\x203E"))
               , ("\\overbrace", \e -> EOver e (ESymbol Accent "\xFE37"))
               , ("\\overbracket", \e -> EOver e (ESymbol Accent "\x23B4"))
               , ("\\overline", \e -> EOver e (ESymbol Accent "\x00AF"))
               , ("\\underbrace", \e -> EUnder e (ESymbol Accent "\xFE38"))
               , ("\\underbracket", \e -> EUnder e (ESymbol Accent "\x23B5"))
               , ("\\underline", \e -> EUnder e (ESymbol Accent "\x00AF"))
               ]

unary :: TP Exp
unary = try $ do
  c <- command
  unless (c `elem` unaryOps) pzero
  a <- texToken
  return $ EUnary c a

text :: TP Exp
text = try $ do
  c <- command
  case M.lookup c textOps of
       Just f   -> liftM f $ braces (many (noneOf "}" <|> (char '\\' >> char '}')))
       Nothing  -> pzero

-- note: sqrt can be unary, \sqrt{2}, or binary, \sqrt[3]{2}
root :: TP Exp
root = try $ do
  try (symbol "\\sqrt") <|> symbol "\\surd"
  a <- inbrackets
  b <- texToken
  return $ EBinary "\\sqrt" b a

binary :: TP Exp
binary = try $ do
  c <- command
  unless (c `elem` binaryOps) pzero
  a <- texToken
  b <- texToken
  return $ EBinary c a b

texSymbol :: TP Exp
texSymbol = try $ do
  negated <- (try (symbol "\\not") >> return True) <|> return False
  sym <- operator <|> command
  case M.lookup sym symbols of
       Just s   -> if negated then neg s else return s
       Nothing  -> pzero

neg :: Exp -> TP Exp
neg (ESymbol Rel x) = ESymbol Rel `fmap`
  case x of
       "\x2282" -> return "\x2284"
       "\x2283" -> return "\x2285"
       "\x2286" -> return "\x2288"
       "\x2287" -> return "\x2289"
       "\x2208" -> return "\x2209"
       _        -> pzero
neg _ = pzero

-- The lexer
lexer :: P.TokenParser st
lexer = P.makeTokenParser texMathDef

lexeme :: CharParser st a -> CharParser st a
lexeme = P.lexeme lexer

whiteSpace :: CharParser st ()
whiteSpace = P.whiteSpace lexer

identifier :: CharParser st String
identifier = lexeme (P.identifier lexer)

operator :: CharParser st String
operator = lexeme $ many1 (char '\'')
                 <|> liftM (:[]) (opLetter texMathDef)

symbol :: String -> CharParser st String
symbol = lexeme . P.symbol lexer

braces :: CharParser st a -> CharParser st a
braces = lexeme . P.braces lexer

brackets :: CharParser st a -> CharParser st a
brackets = lexeme . P.brackets lexer

binaryOps :: [String]
binaryOps = ["\\frac", "\\tfrac", "\\dfrac", "\\stackrel", "\\overset", "\\underset", "\\binom"]

scalers :: M.Map String String
scalers = M.fromList
          [ ("\\bigg", "2.2")
          , ("\\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)]
enclosures = [ ("(", ESymbol Open "(")
             , (")", ESymbol Close ")")
             , ("[", ESymbol Open "[")
             , ("]", ESymbol Close "]")
             , ("\\{", ESymbol Open "{")
             , ("\\}", ESymbol Close "}")
             , ("\\lbrack", ESymbol Open "[")
             , ("\\lbrace", ESymbol Open "{")
             , ("\\rbrack", ESymbol Close "]")
             , ("\\rbrace", ESymbol Close "}")
             , ("\\llbracket", ESymbol Open "\x27E6")
             , ("\\rrbracket", ESymbol Close "\x27E7")
             , ("\\langle", ESymbol Open "\x27E8")
             , ("\\rangle", ESymbol Close "\x27E9")
             , ("\\lfloor", ESymbol Open "\x230A")
             , ("\\rfloor", ESymbol Close "\x230B")
             , ("\\lceil", ESymbol Open "\x2308")
             , ("\\rceil", ESymbol Close "\x2309")
             , ("|", ESymbol Open "\x2223")
             , ("|", ESymbol Close "\x2223")
             , ("\\|", ESymbol Open "\x2225")
             , ("\\|", ESymbol Close "\x2225")
             , ("\\lvert", ESymbol Open "\x7C")
             , ("\\rvert", ESymbol Close "\x7C")
             , ("\\vert", ESymbol Close "\x7C")
             , ("\\lVert", ESymbol Open "\x2225")
             , ("\\rVert", ESymbol Close "\x2225")
             , ("\\Vert", ESymbol Close "\x2016")
             , ("\\ulcorner", ESymbol Open "\x231C")
             , ("\\urcorner", ESymbol Close "\x231D")
             ]

symbols :: M.Map String Exp
symbols = M.fromList [
             ("+", ESymbol Bin "+")
           , ("-", ESymbol Bin "\x2212")
           , ("*", ESymbol Bin "*")
           , (",", ESymbol Pun ",")
           , (".", ESymbol Pun ".")
           , (";", ESymbol Pun ";")
           , (":", ESymbol Pun ":")
           , ("?", ESymbol Pun "?")
           , (">", ESymbol Rel ">")
           , ("<", ESymbol Rel "<")
           , ("!", ESymbol Ord "!")
           , ("'", ESymbol Ord "\x02B9")
           , ("''", ESymbol Ord "\x02BA")
           , ("'''", ESymbol Ord "\x2034")
           , ("''''", ESymbol Ord "\x2057")
           , ("=", ESymbol Rel "=")
           , (":=", ESymbol Rel ":=")
           , ("\\mid", ESymbol Bin "\x2223")
           , ("\\parallel", ESymbol Rel "\x2225")
           , ("\\backslash", ESymbol Bin "\x2216")
           , ("/", ESymbol Bin "/")
           , ("\\setminus",	ESymbol Bin "\\")
           , ("\\times", ESymbol Bin "\x00D7")
           , ("\\alpha", EIdentifier "\x03B1")
           , ("\\beta", EIdentifier "\x03B2")
           , ("\\chi", EIdentifier "\x03C7")
           , ("\\delta", EIdentifier "\x03B4")
           , ("\\Delta", ESymbol Op "\x0394")
           , ("\\epsilon", EIdentifier "\x03B5")
           , ("\\varepsilon", EIdentifier "\x025B")
           , ("\\eta", EIdentifier "\x03B7")
           , ("\\gamma", EIdentifier "\x03B3")
           , ("\\Gamma", ESymbol Op "\x0393")
           , ("\\iota", EIdentifier "\x03B9")
           , ("\\kappa", EIdentifier "\x03BA")
           , ("\\lambda", EIdentifier "\x03BB")
           , ("\\Lambda", ESymbol Op "\x039B")
           , ("\\mu", EIdentifier "\x03BC")
           , ("\\nu", EIdentifier "\x03BD")
           , ("\\omega", EIdentifier "\x03C9")
           , ("\\Omega", ESymbol Op "\x03A9")
           , ("\\phi", EIdentifier "\x03D5")
           , ("\\varphi", EIdentifier "\x03C6")
           , ("\\Phi", ESymbol Op "\x03A6")
           , ("\\pi", EIdentifier "\x03C0")
           , ("\\Pi", ESymbol Op "\x03A0")
           , ("\\psi", EIdentifier "\x03C8")
           , ("\\Psi", ESymbol Ord "\x03A8")
           , ("\\rho", EIdentifier "\x03C1")
           , ("\\sigma", EIdentifier "\x03C3")
           , ("\\Sigma", ESymbol Op "\x03A3")
           , ("\\tau", EIdentifier "\x03C4")
           , ("\\theta", EIdentifier "\x03B8")
           , ("\\vartheta", EIdentifier "\x03D1")
           , ("\\Theta", ESymbol Op "\x0398")
           , ("\\upsilon", EIdentifier "\x03C5")
           , ("\\Upsilon", EIdentifier "\x03A5")
           , ("\\xi", EIdentifier "\x03BE")
           , ("\\Xi", ESymbol Op "\x039E")
           , ("\\zeta", EIdentifier "\x03B6")
           , ("\\pm", ESymbol Bin "\x00B1")
           , ("\\mp", ESymbol Bin "\x2213")
           , ("\\triangleleft", ESymbol Bin "\x22B2")
           , ("\\triangleright", ESymbol Bin "\x22B3")
           , ("\\cdot", ESymbol Bin "\x22C5")
           , ("\\star", ESymbol Bin "\x22C6")
           , ("\\ast", ESymbol Bin "\x002A")
           , ("\\times", ESymbol Bin "\x00D7")
           , ("\\div", ESymbol Bin "\x00F7")
           , ("\\circ", ESymbol Bin "\x2218")
           , ("\\bullet", ESymbol Bin "\x2022")
           , ("\\oplus", ESymbol Bin "\x2295")
           , ("\\ominus", ESymbol Bin "\x2296")
           , ("\\otimes", ESymbol Bin "\x2297")
           , ("\\bigcirc", ESymbol Bin "\x25CB")
           , ("\\oslash", ESymbol Bin "\x2298")
           , ("\\odot", ESymbol Bin "\x2299")
           , ("\\land", ESymbol Bin "\x2227")
           , ("\\wedge", ESymbol Bin "\x2227")
           , ("\\lor", ESymbol Bin "\x2228")
           , ("\\vee", ESymbol Bin "\x2228")
           , ("\\cap", ESymbol Bin "\x2229")
           , ("\\cup", ESymbol Bin "\x222A")
           , ("\\sqcap", ESymbol Bin "\x2293")
           , ("\\sqcup", ESymbol Bin "\x2294")
           , ("\\uplus", ESymbol Bin "\x228E")
           , ("\\amalg", ESymbol Bin "\x2210")
           , ("\\bigtriangleup", ESymbol Bin "\x25B3")
           , ("\\bigtriangledown", ESymbol Bin "\x25BD")
           , ("\\dag", ESymbol Bin "\x2020")
           , ("\\dagger", ESymbol Bin "\x2020")
           , ("\\ddag", ESymbol Bin "\x2021")
           , ("\\ddagger", ESymbol Bin "\x2021")
           , ("\\lhd", ESymbol Bin "\x22B2")
           , ("\\rhd", ESymbol Bin "\x22B3")
           , ("\\unlhd", ESymbol Bin "\x22B4")
           , ("\\unrhd", ESymbol Bin "\x22B5")
           , ("\\lt", ESymbol Rel "<")
           , ("\\gt", ESymbol Rel ">")
           , ("\\ne", ESymbol Rel "\x2260")
           , ("\\neq", ESymbol Rel "\x2260")
           , ("\\le", ESymbol Rel "\x2264")
           , ("\\leq", ESymbol Rel "\x2264")
           , ("\\leqslant", ESymbol Rel "\x2264")
           , ("\\ge", ESymbol Rel "\x2265")
           , ("\\geq", ESymbol Rel "\x2265")
           , ("\\geqslant", ESymbol Rel "\x2265")
           , ("\\equiv", ESymbol Rel "\x2261")
           , ("\\ll", ESymbol Rel "\x226A")
           , ("\\gg", ESymbol Rel "\x226B")
           , ("\\doteq", ESymbol Rel "\x2250")
           , ("\\prec", ESymbol Rel "\x227A")
           , ("\\succ", ESymbol Rel "\x227B")
           , ("\\preceq", ESymbol Rel "\x227C")
           , ("\\succeq", ESymbol Rel "\x227D")
           , ("\\subset", ESymbol Rel "\x2282")
           , ("\\supset", ESymbol Rel "\x2283")
           , ("\\subseteq", ESymbol Rel "\x2286")
           , ("\\supseteq", ESymbol Rel "\x2287")
           , ("\\nsubset", ESymbol Rel "\x2284")
           , ("\\nsupset", ESymbol Rel "\x2285")
           , ("\\nsubseteq", ESymbol Rel "\x2288")
           , ("\\nsupseteq", ESymbol Rel "\x2289")
           , ("\\sqsubset", ESymbol Rel "\x228F")
           , ("\\sqsupset", ESymbol Rel "\x2290")
           , ("\\sqsubseteq", ESymbol Rel "\x2291")
           , ("\\sqsupseteq", ESymbol Rel "\x2292")
           , ("\\sim", ESymbol Rel "\x223C")
           , ("\\simeq", ESymbol Rel "\x2243")
           , ("\\approx", ESymbol Rel "\x2248")
           , ("\\cong", ESymbol Rel "\x2245")
           , ("\\Join", ESymbol Rel "\x22C8")
           , ("\\bowtie", ESymbol Rel "\x22C8")
           , ("\\in", ESymbol Rel "\x2208")
           , ("\\ni", ESymbol Rel "\x220B")
           , ("\\owns", ESymbol Rel "\x220B")
           , ("\\propto", ESymbol Rel "\x221D")
           , ("\\vdash", ESymbol Rel "\x22A2")
           , ("\\dashv", ESymbol Rel "\x22A3")
           , ("\\models", ESymbol Rel "\x22A8")
           , ("\\perp", ESymbol Rel "\x22A5")
           , ("\\smile", ESymbol Rel "\x2323")
           , ("\\frown", ESymbol Rel "\x2322")
           , ("\\asymp", ESymbol Rel "\x224D")
           , ("\\notin", ESymbol Rel "\x2209")
           , ("\\gets", ESymbol Rel "\x2190")
           , ("\\leftarrow", ESymbol Rel "\x2190")
           , ("\\to", ESymbol Rel "\x2192")
           , ("\\rightarrow", ESymbol Rel "\x2192")
           , ("\\leftrightarrow", ESymbol Rel "\x2194")
           , ("\\uparrow", ESymbol Rel "\x2191")
           , ("\\downarrow", ESymbol Rel "\x2193")
           , ("\\updownarrow", ESymbol Rel "\x2195")
           , ("\\Leftarrow", ESymbol Rel "\x21D0")
           , ("\\Rightarrow", ESymbol Rel "\x21D2")
           , ("\\Leftrightarrow", ESymbol Rel "\x21D4")
           , ("\\iff", ESymbol Rel "\x21D4")
           , ("\\Uparrow", ESymbol Rel "\x21D1")
           , ("\\Downarrow", ESymbol Rel "\x21D3")
           , ("\\Updownarrow", ESymbol Rel "\x21D5")
           , ("\\mapsto", ESymbol Rel "\x21A6")
           , ("\\longleftarrow", ESymbol Rel "\x2190")
           , ("\\longrightarrow", ESymbol Rel "\x2192")
           , ("\\longleftrightarrow", ESymbol Rel "\x2194")
           , ("\\Longleftarrow", ESymbol Rel "\x21D0")
           , ("\\Longrightarrow", ESymbol Rel "\x21D2")
           , ("\\Longleftrightarrow", ESymbol Rel "\x21D4")
           , ("\\longmapsto", ESymbol Rel "\x21A6")
           , ("\\sum", ESymbol Op "\x2211")
           , ("\\prod", ESymbol Op "\x220F")
           , ("\\bigcap", ESymbol Op "\x22C2")
           , ("\\bigcup", ESymbol Op "\x22C3")
           , ("\\bigwedge", ESymbol Op "\x22C0")
           , ("\\bigvee", ESymbol Op "\x22C1")
           , ("\\bigsqcap", ESymbol Op "\x2A05")
           , ("\\bigsqcup", ESymbol Op "\x2A06")
           , ("\\coprod", ESymbol Op "\x2210")
           , ("\\bigoplus", ESymbol Op "\x2A01")
           , ("\\bigotimes", ESymbol Op "\x2A02")
           , ("\\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")
           , ("\\ldots", ESymbol Ord "\x2026")
           , ("\\cdots", ESymbol Ord "\x22EF")
           , ("\\vdots", ESymbol Ord "\x22EE")
           , ("\\ddots", ESymbol Ord "\x22F1")
           , ("\\forall", ESymbol Op "\x2200")
           , ("\\exists", ESymbol Op "\x2203")
           , ("\\Re", ESymbol Ord "\x211C")
           , ("\\Im", ESymbol Ord "\x2111")
           , ("\\aleph", ESymbol Ord "\x2135")
           , ("\\hbar", ESymbol Ord "\x210F")
           , ("\\ell", ESymbol Ord "\x2113")
           , ("\\wp", ESymbol Ord "\x2118")
           , ("\\emptyset", ESymbol Ord "\x2205")
           , ("\\infty", ESymbol Ord "\x221E")
           , ("\\partial", ESymbol Ord "\x2202")
           , ("\\nabla", ESymbol Ord "\x2207")
           , ("\\triangle", ESymbol Ord "\x25B3")
           , ("\\therefore", ESymbol Pun "\x2234")
           , ("\\angle", ESymbol Ord "\x2220")
           , ("\\diamond", ESymbol Op "\x22C4")
           , ("\\Diamond", ESymbol Op "\x25C7")
           , ("\\lozenge", ESymbol Op "\x25CA")
           , ("\\neg", ESymbol Op "\x00AC")
           , ("\\lnot", ESymbol Ord "\x00AC")
           , ("\\bot", ESymbol Ord "\x22A5")
           , ("\\top", ESymbol Ord "\x22A4")
           , ("\\square", ESymbol Ord "\x25AB")
           , ("\\Box", ESymbol Op "\x25A1")
           , ("\\wr", ESymbol Ord "\x2240")
           , ("\\!", ESpace "-0.167em")
           , ("\\,", ESpace "0.167em")
           , ("\\>", ESpace "0.222em")
           , ("\\:", ESpace "0.222em")
           , ("\\;", ESpace "0.278em")
           , ("~", ESpace "0.333em")
           , ("\\quad", ESpace "1em")
           , ("\\qquad", ESpace "2em")
           , ("\\arccos", EMathOperator "arccos")
           , ("\\arcsin", EMathOperator "arcsin")
           , ("\\arctan", EMathOperator "arctan")
           , ("\\arg", EMathOperator "arg")
           , ("\\cos", EMathOperator "cos")
           , ("\\cosh", EMathOperator "cosh")
           , ("\\cot", EMathOperator "cot")
           , ("\\coth", EMathOperator "coth")
           , ("\\csc", EMathOperator "csc")
           , ("\\deg", EMathOperator "deg")
           , ("\\det", EMathOperator "det")
           , ("\\dim", EMathOperator "dim")
           , ("\\exp", EMathOperator "exp")
           , ("\\gcd", EMathOperator "gcd")
           , ("\\hom", EMathOperator "hom")
           , ("\\inf", EMathOperator "inf")
           , ("\\ker", EMathOperator "ker")
           , ("\\lg", EMathOperator "lg")
           , ("\\lim", EMathOperator "lim")
           , ("\\liminf", EMathOperator "liminf")
           , ("\\limsup", EMathOperator "limsup")
           , ("\\ln", EMathOperator "ln")
           , ("\\log", EMathOperator "log")
           , ("\\max", EMathOperator "max")
           , ("\\min", EMathOperator "min")
           , ("\\Pr", EMathOperator "Pr")
           , ("\\sec", EMathOperator "sec")
           , ("\\sin", EMathOperator "sin")
           , ("\\sinh", EMathOperator "sinh")
           , ("\\sup", EMathOperator "sup")
           , ("\\tan", EMathOperator "tan")
           , ("\\tanh", EMathOperator "tanh")
           ]

texmath-0.6.5.2/Text/TeXMath/ToUnicode.hs0000644000000000000000000002342512236473702016221 0ustar0000000000000000{-
Copyright (C) 2009 John MacFarlane 

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-}

{- | Function for replacing strings of characters with their respective mathvariant
-}

module Text.TeXMath.ToUnicode (toUnicode)
where

import Text.TeXMath.Types
import qualified Data.Map as M

-- | Replace all characters in the string A-Z, a-z with their corresponding mathvariant unicode character.
-- | MathML has a mathvariant attribute which is unimplemented in Firefox
-- | (see https://bugzilla.mozilla.org/show_bug.cgi?id=114365)
-- | Therefore, we may want to translate mathscr, etc to unicode symbols directly.
toUnicode :: TextType -> String -> String
toUnicode TextScript s       = map (mapChar mathscr) s
toUnicode TextBoldScript s   = map (mapChar mathbfscr) s
toUnicode TextFraktur s      = map (mapChar mathfrak) s
toUnicode TextBoldFraktur s  = map (mapChar mathbffrak) s
toUnicode TextDoubleStruck s = map (mapChar mathbb) s
toUnicode _ s = s

mapChar :: M.Map Char Char -> Char -> Char
mapChar m c = maybe c id (M.lookup c m)

-- This list is from http://www.w3.org/TR/MathML2/script.html
mathscr :: M.Map Char Char
mathscr = 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')
           ]

-- Bold variant of mathscr, taken from unicode.
mathbfscr :: M.Map Char Char
mathbfscr = M.fromList [
             ('A', '\x1D4D0')
           , ('B', '\x1D4D1')
           , ('C', '\x1D4D2')
           , ('D', '\x1D4D3')
           , ('E', '\x1D4D4')
           , ('F', '\x1D4D5')
           , ('G', '\x1D4D6')
           , ('H', '\x1D4D7')
           , ('I', '\x1D4D8')
           , ('J', '\x1D4D9')
           , ('K', '\x1D4DA')
           , ('L', '\x1D4DB')
           , ('M', '\x1D4DC')
           , ('N', '\x1D4DD')
           , ('O', '\x1D4DE')
           , ('P', '\x1D4DF')
           , ('Q', '\x1D4E0')
           , ('R', '\x1D4E1')
           , ('S', '\x1D4E2')
           , ('T', '\x1D4E3')
           , ('U', '\x1D4E4')
           , ('V', '\x1D4E5')
           , ('W', '\x1D4E6')
           , ('X', '\x1D4E7')
           , ('Y', '\x1D4E8')
           , ('Z', '\x1D4E9')
           , ('a', '\x1D4EA')
           , ('b', '\x1D4EB')
           , ('c', '\x1D4EC')
           , ('d', '\x1D4ED')
           , ('e', '\x1D4EE')
           , ('f', '\x1D4EF')
           , ('g', '\x1D4F0')
           , ('h', '\x1D4F1')
           , ('i', '\x1D4F2')
           , ('j', '\x1D4F3')
           , ('k', '\x1D4F4')
           , ('l', '\x1D4F5')
           , ('m', '\x1D4F6')
           , ('n', '\x1D4F7')
           , ('o', '\x1D4F8')
           , ('p', '\x1D4F9')
           , ('q', '\x1D4FA')
           , ('r', '\x1D4FB')
           , ('s', '\x1D4FC')
           , ('t', '\x1D4FD')
           , ('u', '\x1D4FE')
           , ('v', '\x1D4FF')
           , ('w', '\x1D500')
           , ('x', '\x1D501')
           , ('y', '\x1D502')
           , ('z', '\x1D503')
           ]

-- Similar to mathscr above, we translate manually.
-- This list is from http://www.w3.org/TR/MathML2/double-struck.html
mathbb :: M.Map Char Char
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')
           ]

-- Fraktur fonts, taken from unicode.
mathfrak :: M.Map Char Char
mathfrak = M.fromList [
          ('A','\x1D504')
        , ('B','\x1D505')
        , ('C','\x0212D')
        , ('D','\x1D507')
        , ('E','\x1D508')
        , ('F','\x1D509')
        , ('G','\x1D50A')
        , ('H','\x0210C')
        , ('I','\x02111')
        , ('J','\x1D50D')
        , ('K','\x1D50E')
        , ('L','\x1D50F')
        , ('M','\x1D510')
        , ('N','\x1D511')
        , ('O','\x1D512')
        , ('P','\x1D513')
        , ('Q','\x1D514')
        , ('R','\x0211C')
        , ('S','\x1D516')
        , ('T','\x1D517')
        , ('U','\x1D518')
        , ('V','\x1D519')
        , ('W','\x1D51A')
        , ('X','\x1D51B')
        , ('Y','\x1D51C')
        , ('Z','\x02128')
        , ('a','\x1D51E')
        , ('b','\x1D51F')
        , ('c','\x1D520')
        , ('d','\x1D521')
        , ('e','\x1D522')
        , ('f','\x1D523')
        , ('g','\x1D524')
        , ('h','\x1D525')
        , ('i','\x1D526')
        , ('j','\x1D527')
        , ('k','\x1D528')
        , ('l','\x1D529')
        , ('m','\x1D52A')
        , ('n','\x1D52B')
        , ('o','\x1D52C')
        , ('p','\x1D52D')
        , ('q','\x1D52E')
        , ('r','\x1D52F')
        , ('s','\x1D530')
        , ('t','\x1D531')
        , ('u','\x1D532')
        , ('v','\x1D533')
        , ('w','\x1D534')
        , ('x','\x1D535')
        , ('y','\x1D536')
        , ('z','\x1D537')
        ]

-- Bold fraktur fonts, taken from unicode.
mathbffrak :: M.Map Char Char
mathbffrak = M.fromList [
          ('A','\x1D56C')
        , ('B','\x1D56D')
        , ('C','\x1D56E')
        , ('D','\x1D57F')
        , ('E','\x1D570')
        , ('F','\x1D571')
        , ('G','\x1D572')
        , ('H','\x1D573')
        , ('I','\x1D574')
        , ('J','\x1D575')
        , ('K','\x1D576')
        , ('L','\x1D577')
        , ('M','\x1D578')
        , ('N','\x1D579')
        , ('O','\x1D57A')
        , ('P','\x1D57B')
        , ('Q','\x1D57C')
        , ('R','\x1D57D')
        , ('S','\x1D57E')
        , ('T','\x1D57F')
        , ('U','\x1D580')
        , ('V','\x1D581')
        , ('W','\x1D582')
        , ('X','\x1D583')
        , ('Y','\x1D584')
        , ('Z','\x1D585')
        , ('a','\x1D586')
        , ('b','\x1D587')
        , ('c','\x1D588')
        , ('d','\x1D589')
        , ('e','\x1D58A')
        , ('f','\x1D58B')
        , ('g','\x1D58C')
        , ('h','\x1D58D')
        , ('i','\x1D58E')
        , ('j','\x1D58F')
        , ('k','\x1D590')
        , ('l','\x1D591')
        , ('m','\x1D592')
        , ('n','\x1D593')
        , ('o','\x1D594')
        , ('p','\x1D595')
        , ('q','\x1D596')
        , ('r','\x1D597')
        , ('s','\x1D598')
        , ('t','\x1D599')
        , ('u','\x1D59A')
        , ('v','\x1D59B')
        , ('w','\x1D59C')
        , ('x','\x1D59D')
        , ('y','\x1D59E')
        , ('z','\x1D59F')
        ]

texmath-0.6.5.2/Text/TeXMath/Types.hs0000644000000000000000000000460012236473702015426 0ustar0000000000000000{-# LANGUAGE DeriveDataTypeable #-}
{-
Copyright (C) 2009 John MacFarlane 

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-}

{- | Types for representing a structured formula.
-}

module Text.TeXMath.Types (Exp(..), TeXSymbolType(..), ArrayLine,
                           TextType(..), Alignment(..), DisplayType(..))
where

import Data.Generics

data TeXSymbolType = Ord | Op | Bin | Rel | Open | Close | Pun | Accent
                     deriving (Show, Read, Eq, Data, Typeable)

data Alignment = AlignLeft | AlignCenter | AlignRight | AlignDefault
                 deriving (Show, Read, Eq, Data, Typeable)

type ArrayLine = [[Exp]]

data Exp =
    ENumber String
  | EGrouped [Exp]
  | EDelimited String String [Exp]
  | EIdentifier String
  | EMathOperator String
  | ESymbol TeXSymbolType String
  | ESpace String
  | EBinary String Exp Exp
  | ESub Exp Exp
  | ESuper Exp Exp
  | ESubsup Exp Exp Exp
  | EOver Exp Exp
  | EUnder Exp Exp
  | EUnderover Exp Exp Exp
  | EUp Exp Exp
  | EDown Exp Exp
  | EDownup Exp Exp Exp
  | EUnary String Exp
  | EScaled String Exp
  | EStretchy Exp
  | EArray [Alignment] [ArrayLine]
  | EText TextType String
  deriving (Show, Read, Eq, Data, Typeable)

data DisplayType = DisplayBlock
                 | DisplayInline
                 deriving Show

data TextType = TextNormal
              | TextBold
              | TextItalic
              | TextMonospace
              | TextSansSerif
              | TextDoubleStruck
              | TextScript
              | TextFraktur
              | TextBoldItalic
              | TextBoldSansSerif
              | TextBoldSansSerifItalic
              | TextBoldScript
              | TextBoldFraktur
              | TextSansSerifItalic
              deriving (Show, Read, Eq, Data, Typeable)