packages feed

TeX-my-math 0.202.0.0 → 0.202.1.0

raw patch · 10 files changed

+125/−32 lines, 10 filesdep ~HaTeXdep ~basedep ~dumb-cas

Dependency ranges changed: HaTeX, base, dumb-cas

Files

CAS/Dumb/LaTeX/Symbols.hs view
@@ -3,7 +3,7 @@ -- Copyright   : (c) Justus Sagemüller 2017 -- License     : GPL v3 -- --- Maintainer  : (@) jsagemue $ uni-koeln.de+-- Maintainer  : (@) jsag $ hvl.no -- Stability   : experimental -- Portability : portable -- @@ -197,8 +197,24 @@  instance ASCIISymbols LaTeX where   fromASCIISymbol c-   | isAlpha c  = fromString [c]-  toASCIISymbols (TeXRaw s) = Txt.unpack s+   | Just lc <- Map.lookup c mappingFromASCII  = lc+   | otherwise  = error $ "ASCII symbol '"++[c]++"' not supported in LaTeX expressions."+  toASCIISymbols lc+   | Just c <- Map.lookup lc mappingToASCII    = [c]+   | lc==mempty  = ""+   | Just s' <- matchShowMagic lc  = Txt.unpack s'+   | otherwise   = "《"++Txt.unpack(render lc)++"》"++mappingFromASCII :: Map.HashMap Char LaTeX+mappingToASCII :: Map.HashMap LaTeX Char+InvertibleMap mappingFromASCII mappingToASCII+   = mapToLaTeXWith id     ['a'..'z']+                           ['a'..'z']+ <|> mapToLaTeXWith id     ['A'..'Z']+                           ['A'..'Z']+ <|> fromAssocList (zip+           ['+', '-', '*']+           ["+", "-", raw"{\\cdot}"])  instance UnicodeSymbols LaTeX where   fromUnicodeSymbol c
Math/LaTeX/Internal/Display.hs view
@@ -3,7 +3,7 @@ -- Copyright   : (c) Justus Sagemüller 2017 -- License     : GPL v3 -- --- Maintainer  : (@) jsagemue $ uni-koeln.de+-- Maintainer  : (@) jsag $ hvl.no -- Stability   : experimental -- Portability : requires GHC>7 extensions -- 
Math/LaTeX/Internal/MathExpr.hs view
@@ -3,7 +3,7 @@ -- Copyright   : (c) Justus Sagemüller 2017 -- License     : GPL v3 -- --- Maintainer  : (@) jsagemue $ uni-koeln.de+-- Maintainer  : (@) jsag $ hvl.no -- Stability   : experimental -- Portability : requires GHC>7 extensions -- @@ -103,6 +103,8 @@ infixl 7 ×, ∘, ⊗, *..* (×), (⊗), (∘), (*..*) :: MathsInfix (×) = opL' 7 LaTeX.times+(∗) = opL' 7 (LaTeX.*:)+(⋆) = opL' 7 LaTeX.star (⊗) = opL' 7 LaTeX.otimes (∘) = opL' 7 LaTeX.circ (*..*) = opL 7 $ raw"{\\cdot\\ldots\\cdot}"@@ -125,10 +127,12 @@ infixr 2 ∪, ⊎ (∪) = opR' 2 LaTeX.cup (⊎) = opR' 2 LaTeX.uplus-infixl 2 -\-, ⧵-{-# DEPRECATED (-\-) "Use (⧵)" #-}+infixl 2 -\-, ⧵, ∖+{-# DEPRECATED (-\-) "Use (∖), i.e. U+2216 SET MINUS" #-} (-\-) = (⧵)-(⧵) = opL' 2 LaTeX.setminus+(⧵) = (⧵)+{-# DEPRECATED (⧵) "Use (∖), i.e. U+2216 SET MINUS. (You used U+29F5 REVERSE SOLIDUS OPERATOR)" #-}+(∖) = opL' 2 LaTeX.setminus  infixr 5 ⸪, -→, ←-, ↪ (⸪), (-→), (←-), (↪) :: MathsInfix
Math/LaTeX/Internal/OperatorGenerator.hs view
@@ -3,7 +3,7 @@ -- Copyright   : (c) Justus Sagemüller 2017 -- License     : GPL v3 -- --- Maintainer  : (@) jsagemue $ uni-koeln.de+-- Maintainer  : (@) jsag $ hvl.no -- Stability   : experimental -- Portability : portable -- 
Math/LaTeX/Prelude.hs view
@@ -3,7 +3,7 @@ -- Copyright   : (c) Justus Sagemüller 2017 -- License     : GPL v3 -- --- Maintainer  : (@) jsagemue $ uni-koeln.de+-- Maintainer  : (@) jsag $ hvl.no -- Stability   : experimental -- Portability : requires GHC>7 extensions -- @@ -30,11 +30,11 @@ #if __GLASGOW_HASKELL__ > 801    , (،..،), (،), (⸪=), (=⸪) #endif-   , (␣), (+..+), (*..*), (×), (⊗), (∘), factorial+   , (␣), (+..+), (*..*), (×), (∗), (⋆), (⊗), (∘), factorial    , (◝), (◝⁀), (◞), (◞◝), (|◞), (|◝), (|◞◝)    , (⩵), (≡), (⩵!), (≠), (⪡), (⪢), (≤), (≥), (≪), (≫), (∝), (⟂), (∥), (₌₌)    , (=→), (←=), (≈), (∼), (≃), (≅)-   , (⊂), (/⊂), (⊆), (⊃), (⊇), (∋), (∌), (∈), (∉), (∩), (∪), (⊎), (-\-), (⧵), (⸪), (⊕)+   , (⊂), (/⊂), (⊆), (⊃), (⊇), (∋), (∌), (∈), (∉), (∩), (∪), (⊎), (∖), (-\-), (⧵), (⸪), (⊕)    , (∀:), (∃:), (∄:)    , (-→), (←-), (↦), (↪), (==>), (<==), (<=>), (∧), (∨)    , (∫), (◞∫), (◞∮), d, (∑), (◞∑), (∏), (◞∏)@@ -56,6 +56,7 @@ import CAS.Dumb.Symbols import Math.LaTeX.Internal.MathExpr import Math.LaTeX.Internal.Display+import Math.LaTeX.StringLiterals  import Text.LaTeX.Base.Class (LaTeXC) import Text.LaTeX.Base (raw, LaTeX)
Math/LaTeX/StringLiterals.hs view
@@ -3,7 +3,7 @@ -- Copyright   : (c) Justus Sagemüller 2017 -- License     : GPL v3 -- --- Maintainer  : (@) jsagemue $ uni-koeln.de+-- Maintainer  : (@) jsag $ hvl.no -- Stability   : experimental -- Portability : requires GHC>7 extensions -- @@ -26,8 +26,11 @@ import CAS.Dumb.Symbols  import Data.String+import Data.Char (isAlpha)   instance (SymbolClass σ, SCConstraint σ LaTeX)      => IsString (CAS' γ (Infix LaTeX) (Encapsulation LaTeX) (SymbolD σ LaTeX)) where-  fromString = Symbol . StringSymbol . LaTeX.mathrm . fromString+  fromString s = Symbol . StringSymbol .+    (if any isAlpha s then LaTeX.mathrm+                      else id) $ fromString s
TeX-my-math.cabal view
@@ -1,5 +1,5 @@ Name:                TeX-my-math-Version:             0.202.0.0+Version:             0.202.1.0 Category:            math Synopsis:            Render general Haskell math to LaTeX. Or: math typesetting with high signal-to-noise–ratio. Description:         For tl;dr: look at <https://github.com/leftaroundabout/Symbolic-math-HaTeX/blob/master/EXAMPLES.md>.@@ -42,9 +42,9 @@  Library   Build-Depends:     base>=4.8 && <4.14-                     , HaTeX>3.22.2.0+                     , HaTeX>3.22.3.0                      , vector-space-                     , dumb-cas >= 0.2 && < 0.3+                     , dumb-cas >= 0.2.1 && < 0.3                      , decimal-literals                      , text                      , void
example/Simple.hs view
@@ -3,7 +3,7 @@ -- Copyright   : (c) Justus Sagemüller 2019 -- License     : GPL v3 -- --- Maintainer  : (@) jsagemue $ uni-koeln.de+-- Maintainer  : (@) jsag $ hvl.no -- Stability   : experimental -- Portability : portable -- 
test/PdfSnippets/LaTeXComparer.hs view
@@ -3,7 +3,7 @@ -- Copyright   : (c) Justus Sagemüller 2017 -- License     : GPL v3 -- --- Maintainer  : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer  : (@) jsag $ hvl.no -- Stability   : experimental -- Portability : portable -- @@ -23,11 +23,10 @@ import Text.LaTeX (LaTeX, Text)  -type Expr = Expression LaTeX type SLaTeX = Text -data TestTree = TestGroup String [TestTree]-              | TestCase Expr String SLaTeX+data TestTree σ = TestGroup String [TestTree σ]+                | TestCase (LaTeXMath σ) String SLaTeX   mkLaTeXSnip :: QuasiQuoter
test/PdfSnippets/MkSnippets.hs view
@@ -3,7 +3,7 @@ -- Copyright   : (c) Justus Sagemüller 2017 -- License     : GPL v3 -- --- Maintainer  : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer  : (@) jsag $ hvl.no -- Stability   : experimental -- Portability : portable -- @@ -19,12 +19,17 @@ import Math.LaTeX.StringLiterals  import Text.LaTeX (LaTeX, raw, Text)+import Text.LaTeX.Base.Math+import Text.LaTeX.Packages.AMSFonts import qualified Text.LaTeX as LaTeX import qualified Data.Text as Txt import qualified Data.Text.IO as Txt import Data.Char  import CAS.Dumb+import CAS.Dumb.Symbols.ASCII hiding (d)+import CAS.Dumb.Symbols.Unicode.MathLatin_RomanGreek__BopomofoGaps+                       (Unicode_MathLatin_RomanGreek__BopomofoGaps)  import System.FilePath import System.Directory@@ -37,16 +42,76 @@  main :: IO () main = do-   examples <- evalTests tests+   examples_U <- evalTests tests_U    Txt.writeFile "EXAMPLES.md"       $ "_This file was generated automatically from [MkSnippets.hs](test/PdfSnippets/MkSnippets.hs). Run `cabal test` to refresh it._\n"-       <> examples+       <> examples_U+   examples_A <- evalTests tests_A+   Txt.writeFile "EXAMPLES_ASCII.md"+      $ "_This file was generated automatically from [MkSnippets.hs](test/PdfSnippets/MkSnippets.hs). Run `cabal test` to refresh it._\n"+       <> examples_A      -tests :: TestTree-tests = testGroup "Tests"+tests_A :: TestTree ASCII+tests_A = testGroup "Tests"   [ testGroup "Simple expressions"+     [ [mkLaTeXSnip|        a + b * c |] "a+b{\\cdot}c"+#if __GLASGOW_HASKELL__ > 801+     , [mkLaTeXSnip|        A * B + C |] "A{\\cdot}B+C"+#endif+     , [mkLaTeXSnip|      (a + b) * c |] "\\left(a+b\\right){\\cdot}c"+     , [mkLaTeXSnip|(a + b) / (x - y) |] "\\frac{a+b}{x-y}"+     , [mkLaTeXSnip| (a + b)**(x - y) |] "\\left(a+b\\right)^{x-y}"+     , [mkLaTeXSnip|         (p/q)**gamma |] "\\left(\\frac{p}{q}\\right)^{\\gamma{}}"+     , [mkLaTeXSnip|      abs(p/q)**xi |] "\\left|\\frac{p}{q}\\right|^{\\xi{}}"+     , [mkLaTeXSnip|          a**b**c |] "a^{b^{c}}"+     , [mkLaTeXSnip|        (a**b)**c |] "\\left(a^{b}\\right)^{c}"+     , [mkLaTeXSnip|      sin (sin x) |] "\\sin{\\left(\\sin{x}\\right)}"+     , [mkLaTeXSnip|   matrix[[ 0,1]+                             ,[-1,0]] |] "\\begin{pmatrix}0&1\\\\ -1&0\\end{pmatrix}"+     ]+  , testGroup "Operators"+     [ testGroup "Arithmetic"+        [ [mkLaTeXSnip| a + b |] "a+b"+        , [mkLaTeXSnip| a - b |] "a-b"+        , [mkLaTeXSnip| a * b |] "a{\\cdot}b"+        , [mkLaTeXSnip| a `times` b |] "a\\times{}b"+        , [mkLaTeXSnip| a +- b |] "a\\pm{}b"+        , [mkLaTeXSnip| a -+ b |] "a\\mp{}b"+        , [mkLaTeXSnip| a `oplus` b |] "a\\oplus{}b"+        , [mkLaTeXSnip| a `otimes` b |] "a\\otimes{}b"+        ]+     , testGroup "Sub/superscripts"+        [ [mkLaTeXSnip|         a!:b |] "{a}_{b}"+        , [mkLaTeXSnip|    a!^(b,c) |] "{a}_{b}^{c}"+        , [mkLaTeXSnip|     psi!:"Foo" |] "{\\psi{}}_{\\mathrm{Foo}}"+        , [mkLaTeXSnip|     psi!:(F<>o<>o) |] "{\\psi{}}_{Foo}"+        ]+     , testGroup "Logical"+        [ [mkLaTeXSnip| p `vee` q |] "p\\vee{}q"+        , [mkLaTeXSnip| p `wedge` q |] "p\\wedge{}q"+        , [mkLaTeXSnip| cases[(1, "Today"), (2, "Else")] |]+                           "\\begin{cases}1&\\text{Today}\\\\2&\\text{Else}\\end{cases}"+        ]+     , testGroup "Relations"+        [ [mkLaTeXSnip| a =: b |] "a=b"+        , [mkLaTeXSnip| a >=: c |] "a\\geq{}c"+        , [mkLaTeXSnip| a <: rho |] "a<\\rho{}"+        , [mkLaTeXSnip| x =: y =: z |] "x=y=z"+        , [mkLaTeXSnip| s `subset` t `subseteq` u |] "s\\subset{}t\\subseteq{}u"+        , [mkLaTeXSnip| h `approx` i `sim` j `simeq` k `cong` l |] "h\\approx{}i\\sim{}j\\simeq{}k\\cong{}l"+        , [mkLaTeXSnip| p `in_` mathbb Q `subset` mathbb R |] +              "p\\in{}\\mathbb{Q}\\subset{}\\mathbb{R}"+        , [mkLaTeXSnip| mathbf u `perp` (vec%$>v) `parallel` (underline%$>w) |]+               "\\mathbf{u}\\perp{}\\vec{v}\\parallel{}\\underline{w}"+        ]+     ]+   ]++tests_U :: TestTree Unicode_MathLatin_RomanGreek__BopomofoGaps+tests_U = testGroup "Tests"+  [ testGroup "Simple expressions"      [ [mkLaTeXSnip|        𝑎 + 𝑏 * 𝑐 |] "a+b{\\cdot}c" #if __GLASGOW_HASKELL__ > 801      , [mkLaTeXSnip|        𝐴 * 𝐵 + 𝐶 |] "A{\\cdot}B+C"@@ -178,14 +243,16 @@          "\\left.\\frac{x}{2}\\right|_{x=0}^{1}"      , TestCase (3 - 1 &~~! [ ㄒ-ㄗ ⩵ -(ㄗ-ㄒ) ])           "3 - 1 &~~! [ ㄒ-ㄗ ⩵ -(ㄗ-ㄒ) ]" "3-1= -\\left(1-3\\right)"+     , [mkLaTeXSnip| 𝑎 ∗ 𝑏 |] "a\\ast{}b"+     , [mkLaTeXSnip| 𝑎 ⋆ 𝑏 |] "a\\star{}b"      ]   ]  -testGroup :: String -> [TestTree] -> TestTree+testGroup :: String -> [TestTree σ] -> TestTree σ testGroup = TestGroup -evalTests :: TestTree -> IO Text+evalTests :: (SymbolClass σ, SCConstraint σ LaTeX) => TestTree σ -> IO Text evalTests = go False 1  where go hasHeader _ (TestCase e ec s)         | s==s'    = do@@ -209,9 +276,9 @@          return . (if hasHeader then id                                 else (("| Haskell | LaTeX | pdf |"                                    <>"\n| ---: | --- | :--- |\n")<>)) $-           "| "<>mconcat["`"-                  <>mkGithubtablesaveCode(Txt.pack (dropWhile (==' ') ecl))-                          <>"` " | ecl<-lines ec]+           "| "<>mconcat[codesnippetify $+                   mkGithubtablesaveCode(Txt.pack (dropWhile (==' ') ecl))+                          | ecl<-lines ec]            <>"| `"<>mkGithubtablesaveCode s            <>"` | ![pdflatex-rendered version of `"<>mkGithubtablesaveCode s                             <>"`]("<>Txt.pack(snipName<.>"png")<>") |\n"@@ -222,6 +289,9 @@               = (Txt.pack (replicate i '#' <> " " <> g <> "\n") <>)                . Txt.concat <$> ((:) <$> go False (i+1) s₀                                      <*> mapM (go True $ i+1) s)+       codesnippetify s+        | '`'`elem`(Txt.unpack s)  = "``"<>s<>"`` "+        | otherwise                =  "`"<>s<>"` "