packages feed

texmath 0.12.8.12 → 0.12.8.13

raw patch · 8 files changed

+194/−34 lines, 8 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

changelog view
@@ -1,3 +1,16 @@+texmath (0.12.8.13)++  * Remove special override for `\perp` in Text.TeXMath.Readers.TeX.Commands+    (#247). This caused `\perp` to be read as U+22A5 instead of U+27C2.  This+    addresses the mismatch with the TeX writer (which associates `\bot` with+    U+22A5 and `\perp` with U+27C2).++  * Typst writer:++    + Fix several issues with accents and attachments (#245).+    + Fix handling of some EOver with combining accents (#245).+    + Escape backslash in text context (#245).+ texmath (0.12.8.12)    * TeX writer: render prime and superscripted prime as `'` (#246).
src/Text/TeXMath/Readers/TeX/Commands.hs view
@@ -272,7 +272,6 @@   , ("\\overbar",ESymbol Accent "\175")   , ("\\overline",ESymbol TOver "\175")   , ("\\overrightarrow",ESymbol Accent "\8407")-  , ("\\perp",ESymbol Rel "\8869")   , ("\\phi",EIdentifier "\981")   , ("\\pi",EIdentifier "\960")   , ("\\preceq",ESymbol Rel "\8828")
src/Text/TeXMath/Writers/Typst.hs view
@@ -84,18 +84,22 @@  escInQuotes :: Text -> Text escInQuotes t =-  if T.any (== '"') t+  if T.any needsEscape t     then T.concatMap escapeChar t     else t   where     escapeChar c-      | c == '"' = "\\" <> T.singleton c+      | needsEscape c = "\\" <> T.singleton c       | otherwise = T.singleton c+    needsEscape c = c == '\\' || c == '"'  writeExpS :: Exp -> Text-writeExpS (EGrouped es) = "(" <> writeExps es <> ")" writeExpS e =   case writeExp e of+    "" -> "()"+    t | Just (c,_) <- T.uncons t+      , c >= '\8988' && c <= '\8991'+      -> "\\" <> t -- see #245     t | T.all (\c -> isDigit c || c == '.') t -> t       | T.all (\c -> isAlpha c || c == '.') t -> t       | otherwise -> "(" <> t <> ")"@@ -142,29 +146,16 @@   "overbrace(" <> writeExp b <> ", " <> writeExp e1 <> ")" writeExp (EOver _ (EOver _ b (ESymbol TOver "\9140")) e1) =   "overbracket(" <> writeExp b <> ", " <> writeExp e1 <> ")"+writeExp (EOver _convertible b (ESymbol Accent ac))+  = case getAccentCommand ac of+     Just accCommand+       | not (isGrouped b) -> accCommand <> inParens (writeExp b)+     _ -> "accent" <> inParens (writeExp b <> ", " <> ac) writeExp (EOver _convertible b e1) =   case e1 of-    ESymbol Accent "`" -> "grave" <> inParens (writeExp b)-    ESymbol Accent "\768" -> "grave" <> inParens (writeExp b)-    ESymbol Accent "\xb4" -> "acute" <> inParens (writeExp b)-    ESymbol Accent "^" -> "hat" <> inParens (writeExp b)-    ESymbol Accent "\770" -> "hat" <> inParens (writeExp b)-    ESymbol Accent "~" -> "tilde" <> inParens (writeExp b)-    ESymbol Accent "\771" -> "tilde" <> inParens (writeExp b)-    ESymbol Accent "\xaf" -> "macron" <> inParens (writeExp b)-    ESymbol Accent "\x2d8" -> "breve" <> inParens (writeExp b)-    ESymbol Accent "." -> "dot" <> inParens (writeExp b)-    ESymbol Accent "\775" -> "dot" <> inParens (writeExp b)-    ESymbol Accent "\xa8" -> "diaer" <> inParens (writeExp b)-    ESymbol Accent "\x2218" -> "circle" <> inParens (writeExp b)-    ESymbol Accent "\x2dd" -> "acute.double" <> inParens (writeExp b)-    ESymbol Accent "\x2c7" -> "caron" <> inParens (writeExp b)-    ESymbol Accent "\x2192" -> "->" <> inParens (writeExp b)-    ESymbol Accent "\x2190" -> "<-" <> inParens (writeExp b)-    ESymbol Accent "\8407" -> "arrow" <> inParens (writeExp b)-    ESymbol TOver "\9182" -> "overbrace(" <> writeExp b <> ")"-    ESymbol TOver "\9140" -> "overbracket(" <> writeExp b <> ")"-    ESymbol TOver "\175" -> "overline(" <> writeExp b <> ")"+    ESymbol TOver "\9182" -> "overbrace" <> inParens (writeExp b)+    ESymbol TOver "\9140" -> "overbracket" <> inParens (writeExp b)+    ESymbol TOver "\175" -> "overline" <> inParens (writeExp b)     _ -> writeExpB b <> "^" <> writeExpS e1 writeExp (EUnder _ (EUnder _ b (ESymbol TUnder "\9183")) e1) =   "underbrace(" <> writeExp b <> ", " <> writeExp e1 <> ")"@@ -173,6 +164,7 @@ writeExp (EUnder _convertible b e1) =   case e1 of     ESymbol TUnder "_" -> "underline(" <> writeExp b <> ")"+    ESymbol TUnder "\817" -> "underline(" <> writeExp b <> ")"     ESymbol TUnder "\9183" -> "underbrace(" <> writeExp b <> ")"     ESymbol TUnder "\9140" -> "underbracket(" <> writeExp b <> ")"     _ -> writeExpB b <> "_" <> writeExpS e1@@ -306,3 +298,45 @@ typstSymbolMap = M.fromList $   ("\776", "dot.double") -- see #231   : [(s,name) | (name, _, s) <- typstSymbols]++getAccentCommand :: Text -> Maybe Text+getAccentCommand ac = do+  case ac of+    "`" -> Just "grave"+    "\180" -> Just "acute"+    "^" -> Just "hat"+    "~" -> Just "tilde"+    "." -> Just "dot"+    "\168" -> Just "diaer"+    "\175" -> Just "macron"+    "\711" -> Just "caron"+    "\728" -> Just "breve"+    "\733" -> Just "acute.double"+    "\768" -> Just "grave"+    "\769" -> Just "acute"+    "\770" -> Just "hat"+    "\771" -> Just "tilde"+    "\772" -> Just "macron"+    "\773" -> Just "overline"+    "\774" -> Just "breve"+    "\775" -> Just "dot"+    "\776" -> Just "dot.double"+    "\777" -> Just "harpoon"+    "\778" -> Just "circle"+    "\779" -> Just "acute.double"+    "\780" -> Just "caron"+    "\781" -> Just "overline"+    "\x2218" -> Just "circle"+    "\x2192" -> Just "->"+    "\x2190" -> Just "<-"+    "\8254" -> Just "macron"+    "\8400" -> Just "harpoon.lt"+    "\8401" -> Just "harpoon"+    "\8406" -> Just "arrow.l"+    "\8407" -> Just "arrow"+    "\8417" -> Just "arrow.l.r"+    _ -> Nothing++isGrouped :: Exp -> Bool+isGrouped (EGrouped _) = True+isGrouped _ = False
+ test/regression/245a.test view
@@ -0,0 +1,4 @@+<<< native+[ EText TextNormal "\\tau" ]+>>> typst+upright("\\tau")
+ test/regression/245b.test view
@@ -0,0 +1,110 @@+<<< tex+\begin{array}{c}+\text{Accents above:}\\+\text{\textbackslash grave} \grave{x}\\+\text{\textbackslash acute} \acute{x}\\+\text{\textbackslash hat} \hat{x}\\+\text{\textbackslash widehat} \widehat{x}\\+\text{\textbackslash tilde} \tilde{x}\\+\text{\textbackslash bar} \bar{x}\\+\text{\textbackslash overbar} \overbar{x}\\+\text{\textbackslash overline} \overline{x}\\+\text{\textbackslash breve} \breve{x}\\+\text{\textbackslash dot} \dot{x}\\+\text{\textbackslash ddot} \ddot{x}\\+\text{\textbackslash ovhook} \ovhook{x}\\+\text{\textbackslash ocirc} \ocirc{x}\\+\text{\textbackslash check} \check{x}\\+\text{\textbackslash candra} \candra{x}\\+\text{\textbackslash oturnedcomma} \oturnedcomma{x}\\+\text{\textbackslash ocommatopright} \ocommatopright{x}\\+\text{\textbackslash droang} \droang{x}\\+\text{\textbackslash leftharpoonaccent} \leftharpoonaccent{x}\\+\text{\textbackslash rightharpoonaccent} \rightharpoonaccent{x}\\+\text{\textbackslash overleftarrow} \overleftarrow{x}\\+\text{\textbackslash vec} \vec{x}\\+\text{\textbackslash dddot} \dddot{x}\\+\text{\textbackslash ddddot} \ddddot{x}\\+\text{\textbackslash overleftrightarrow} \overleftrightarrow{x}\\+\text{\textbackslash annuity} \annuity{x}\\+\text{\textbackslash widebridgeabove} \widebridgeabove{x}\\+\text{\textbackslash asteraccent} \asteraccent{x}\\+\text{Accents below:}\\+\text{\textbackslash wideutilde} \wideutilde{x}\\+\text{\textbackslash underbar} \underbar{x}\\+\text{\textbackslash underline} \underline{x}\\+\text{\textbackslash threeunderdot} \threeunderdot{x}\\+\text{\textbackslash underrightharpoondown} \underrightharpoondown{x}\\+\text{\textbackslash underleftharpoondown} \underleftharpoondown{x}\\+\text{\textbackslash underleftarrow} \underleftarrow{x}\\+\text{\textbackslash underrightarrow} \underrightarrow{x}\\+\text{\textbackslash underline} \underline{x}\\+\text{Trailing signs:}\\+\text{^\textbackslash prime} x^\prime\\+\text{^\textbackslash dprime} x^\dprime\\+\text{^\textbackslash trprime} x^\trprime\\+\text{^\textbackslash qprime} x^\qprime\\+\text{^\textbackslash backprime} x^\backprime\\+\text{^\textbackslash backdprime} x^\backdprime\\+\text{^\textbackslash backtrprime} x^\backtrprime\\+\text{^\textbackslash hyphenbullet} x^\hyphenbullet\\+\text{^\textbackslash ast} x^\ast\\+\text{^\textbackslash vysmwhtcircle} x^\vysmwhtcircle\\+\text{^\textbackslash vysmblkcircle} x^\vysmblkcircle\\+\text{^\textbackslash llcorner} x^\llcorner\\+\text{^\textbackslash ulcorner} x^\ulcorner\\+\end{array}+>>> typst+upright("Accents above:")\+upright("\\grave") grave(x)\+upright("\\acute") acute(x)\+upright("\\hat") hat(x)\+upright("\\widehat") hat(x)\+upright("\\tilde") tilde(x)\+upright("\\bar") macron(x)\+upright("\\overbar") macron(x)\+upright("\\overline") overline(x)\+upright("\\breve") breve(x)\+upright("\\dot") dot(x)\+upright("\\ddot") dot.double(x)\+upright("\\ovhook") harpoon(x)\+upright("\\ocirc") circle(x)\+upright("\\check") caron(x)\+upright("\\candra") accent(x, ̐)\+upright("\\oturnedcomma") accent(x, ̒)\+upright("\\ocommatopright") accent(x, ̕)\+upright("\\droang") accent(x, ̚)\+upright("\\leftharpoonaccent") harpoon.lt(x)\+upright("\\rightharpoonaccent") harpoon(x)\+upright("\\overleftarrow") arrow.l(x)\+upright("\\vec") arrow(x)\+upright("\\dddot") accent(x, ⃛)\+upright("\\ddddot") accent(x, ⃜)\+upright("\\overleftrightarrow") arrow.l.r(x)\+upright("\\annuity") accent(x, ⃧)\+upright("\\widebridgeabove") accent(x, ⃩)\+upright("\\asteraccent") accent(x, ⃰)\+upright("Accents below:")\+upright("\\wideutilde") accent(x, ̰)\+upright("\\underbar") underline(x)\+upright("\\underline") underline(x)\+upright("\\threeunderdot") accent(x, ⃨)\+upright("\\underrightharpoondown") accent(x, ⃬)\+upright("\\underleftharpoondown") accent(x, ⃭)\+upright("\\underleftarrow") accent(x, ⃮)\+upright("\\underrightarrow") accent(x, ⃯)\+upright("\\underline") underline(x)\+upright("Trailing signs:")\+upright("^\\prime") x^(')\+upright("^\\dprime") x^('')\+upright("^\\trprime") x^(''')\+upright("^\\qprime") x^('''')\+upright("^\\backprime") x^prime.rev\+upright("^\\backdprime") x^prime.double.rev\+upright("^\\backtrprime") x^prime.triple.rev\+upright("^\\hyphenbullet") x^(⁃)\+upright("^\\ast") x^(\*)\+upright("^\\vysmwhtcircle") x^circle.stroked.tiny\+upright("^\\vysmblkcircle") x^circle.filled.small\+upright("^\\llcorner") x^\⌞\+upright("^\\ulcorner") x^\⌜\
test/writer/typst/08.test view
@@ -30,4 +30,4 @@ , EDelimited "(" ")" [ Right (EIdentifier "z") ] ] >>> typst-lr(|z^(‾)|) = lr(|z|) \, lr(|(z^(‾))^n|) = lr(|z|)^n \, arg (z^n) = n arg (z)+lr(|macron(z)|) = lr(|z|) \, lr(|(macron(z))^n|) = lr(|z|)^n \, arg (z^n) = n arg (z)
test/writer/typst/complex1.test view
@@ -606,13 +606,13 @@ upright("Cauchy Formula") & f \( z \) thin dot.c "Ind"_gamma^() \( z \) = frac(1, 2 pi i) integral.cont_gamma^() frac(f \( xi \), xi - z) thin d xi\ upright("Cross Product") & V_1^() times V_2^() = mat(delim: "|", i, j, k; frac(partial X, partial u), frac(partial Y, partial u), 0; frac(partial X, partial v), frac(partial Y, partial v), 0)\ upright("Vandermonde Determinant") & mat(delim: "|", 1, 1, dots.h.c, 1; v_1^(), v_2^(), dots.h.c, v_n^(); v_1^2, v_2^2, dots.h.c, v_n^2; dots.v, dots.v, dots.down, dots.v; v_1^(n - 1), v_2^(n - 1), dots.h.c, v_n^(n - 1)) = product_(1 lt.eq i < j lt.eq n)^() \( v_j^() - v_i^() \)\-upright("Lorenz Equations") & x^(˙)_() & = & sigma \( y - x \)\-y^(˙)_() & = & rho x - y - x z\-z^(˙)_() & = & - beta z + x y\-upright("Maxwell's Equations") & {nabla zws times B^harpoon.lt_() - thin 1 / c thin frac(partial zws E^harpoon.lt_(), partial zws t) & = & frac(4 pi, c) thin j^harpoon.lt_()\-nabla zws dot.c E^harpoon.lt_() & = & 4 pi rho\-nabla zws times E^harpoon.lt_() thin + thin 1 / c thin frac(partial zws B^harpoon.lt_(), partial zws t) & = & 0^harpoon.lt_()\-nabla zws dot.c B^harpoon.lt_() & = & 0\+upright("Lorenz Equations") & accent(x, ˙)_() & = & sigma \( y - x \)\+accent(y, ˙)_() & = & rho x - y - x z\+accent(z, ˙)_() & = & - beta z + x y\+upright("Maxwell's Equations") & {nabla zws times accent(B, ↼)_() - thin 1 / c thin frac(partial zws accent(E, ↼)_(), partial zws t) & = & frac(4 pi, c) thin accent(j, ↼)_()\+nabla zws dot.c accent(E, ↼)_() & = & 4 pi rho\+nabla zws times accent(E, ↼)_() thin + thin 1 / c thin frac(partial zws accent(B, ↼)_(), partial zws t) & = & accent(0, ↼)_()\+nabla zws dot.c accent(B, ↼)_() & = & 0\ upright("Einstein Field Equations") & R_(mu nu)^() - 1 / 2 thin g_(mu nu)^() thin R = frac(8 pi G, c_()^4) thin T_(mu nu)^()\ upright("Ramanujan Identity") & frac(1, \( sqrt(phi sqrt(5)) - phi \) e_()^(25 / pi)) = 1 + frac(e_()^(- 2 pi), 1 + frac(e_()^(- 4 pi), 1 + frac(e_()^(- 6 pi), 1 + frac(e_()^(- 8 pi), 1 + dots.h))))\ upright("Another Ramanujan identity") & sum_(k = 1)^oo 1 / 2_()^(floor.l k dot.c zws phi floor.r) = frac(1, 2_()^0 + frac(1, 2_()^1 + dots.h.c))\
texmath.cabal view
@@ -1,5 +1,5 @@ Name:                texmath-Version:             0.12.8.12+Version:             0.12.8.13 Cabal-Version:       >= 1.10 Build-type:          Simple Synopsis:            Conversion between math formats.