texmath 0.3.1.3 → 0.3.1.4
raw patch · 4 files changed
+48/−39 lines, 4 filesnew-component:exe:texmathPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- testTeXMathML.hs +0/−33
- tests/runtests.sh +2/−2
- texmath.cabal +13/−4
- texmath.hs +33/−0
− testTeXMathML.hs
@@ -1,33 +0,0 @@-module Main where--import Text.TeXMath-import Text.XML.Light-import Text.TeXMath.Macros-import Text.ParserCombinators.Parsec-import System.IO--inHtml :: Element -> Element-inHtml x =- 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 ]--stripMacroDefs :: Parser ([Macro], String)-stripMacroDefs = do- macros <- many (try $ pSkipSpaceComments >> pMacroDefinition)- rest <- getInput- return (macros, rest)--main :: IO ()-main = do- inp <- getContents- case parse stripMacroDefs "stdin" inp of- Left err -> error $ show err- Right (ms, rest)->- case (texMathToMathML DisplayBlock $! applyMacros ms rest) of- Left err -> hPutStrLn stderr err- Right v -> putStr . ppTopElement . inHtml $ v
tests/runtests.sh view
@@ -2,9 +2,9 @@ # Note: this should be run from within the tests directory # Make sure you've set the 'test' flag using Cabal: # cabal install -ftest-# Otherwise the test program won't be built.+# Otherwise the test program 'texmath' won't be built. # Exit status is number of failed tests.-TESTPROG=../dist/build/testTeXMathML/testTeXMathML+TESTPROG=../dist/build/texmath/texmath failures=0 if [ -f $TESTPROG ]; then for t in *.tex; do
texmath.cabal view
@@ -1,11 +1,20 @@ Name: texmath-Version: 0.3.1.3+Version: 0.3.1.4 Cabal-version: >= 1.2 Build-type: Custom Synopsis: Conversion of LaTeX math formulas to MathML. Description: The texmathml library provides functions to convert LaTeX math formulas to presentation MathML. It supports- basic LaTeX and AMS extensions, but not macros.+ 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@@ -74,8 +83,8 @@ Ghc-Options: -Wall Ghc-Prof-Options: -auto-all -caf-all -Executable testTeXMathML- Main-is: testTeXMathML.hs+Executable texmath+ Main-is: texmath.hs if impl(ghc >= 6.12) Ghc-Options: -Wall -fno-warn-unused-do-bind else
+ texmath.hs view
@@ -0,0 +1,33 @@+module Main where++import Text.TeXMath+import Text.XML.Light+import Text.TeXMath.Macros+import Text.ParserCombinators.Parsec+import System.IO++inHtml :: Element -> Element+inHtml x =+ 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 ]++stripMacroDefs :: Parser ([Macro], String)+stripMacroDefs = do+ macros <- many (try $ pSkipSpaceComments >> pMacroDefinition)+ rest <- getInput+ return (macros, rest)++main :: IO ()+main = do+ inp <- getContents+ case parse stripMacroDefs "stdin" inp of+ Left err -> error $ show err+ Right (ms, rest)->+ case (texMathToMathML DisplayBlock $! applyMacros ms rest) of+ Left err -> hPutStrLn stderr err+ Right v -> putStr . ppTopElement . inHtml $ v