Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
18 Text/TeXMath/Parser.hs
@@ -246,18 +246,25 @@ variable = do
isConvertible :: Exp -> Bool
isConvertible (EMathOperator x) = x `elem` convertibleOps
- where convertibleOps = ["lim","liminf","limsup","inf","sup"]
+ where convertibleOps = [ "lim","liminf","limsup","inf","sup"
+ , "min","max","Pr","det","gcd"
+ ]
isConvertible (ESymbol Rel _) = True
isConvertible (ESymbol Bin _) = True
-isConvertible (EUnder _ _) = True
-isConvertible (EOver _ _) = True
-isConvertible (EUnderover _ _ _) = 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
@@ -267,6 +274,7 @@ subSup limits a = try $ do
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
@@ -278,10 +286,12 @@ superOrSubscripted limits a = try $ do
'^' -> 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
View
311 tests/subsup.omml
@@ -0,0 +1,311 @@
+<?xml version='1.0' ?>
+<m:oMathPara>
+ <m:oMathParaPr>
+ <m:jc m:val="center" />
+ </m:oMathParaPr>
+ <m:oMath>
+ <m:sSubSup>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>x</m:t>
+ </m:r>
+ </m:e>
+ <m:sub>
+ <m:r>
+ <m:rPr />
+ <m:t>b</m:t>
+ </m:r>
+ </m:sub>
+ <m:sup>
+ <m:r>
+ <m:rPr />
+ <m:t>a</m:t>
+ </m:r>
+ </m:sup>
+ </m:sSubSup>
+ <m:sSubSup>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>x</m:t>
+ </m:r>
+ </m:e>
+ <m:sub>
+ <m:r>
+ <m:rPr />
+ <m:t>b</m:t>
+ </m:r>
+ </m:sub>
+ <m:sup>
+ <m:r>
+ <m:rPr />
+ <m:t>a</m:t>
+ </m:r>
+ </m:sup>
+ </m:sSubSup>
+ <m:limLow>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>min</m:t>
+ </m:r>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>A</m:t>
+ </m:r>
+ </m:lim>
+ </m:limLow>
+ <m:limLow>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>max</m:t>
+ </m:r>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>B</m:t>
+ </m:r>
+ </m:lim>
+ </m:limLow>
+ <m:limLow>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>det</m:t>
+ </m:r>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>C</m:t>
+ </m:r>
+ </m:lim>
+ </m:limLow>
+ <m:limLow>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>Pr</m:t>
+ </m:r>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>A</m:t>
+ </m:r>
+ </m:lim>
+ </m:limLow>
+ <m:limLow>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>gcd</m:t>
+ </m:r>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>A</m:t>
+ </m:r>
+ </m:lim>
+ </m:limLow>
+ <m:sSup>
+ <m:e>
+ <m:acc>
+ <m:accPr>
+ <m:chr m:val="." />
+ </m:accPr>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>u</m:t>
+ </m:r>
+ </m:e>
+ </m:acc>
+ </m:e>
+ <m:sup>
+ <m:r>
+ <m:rPr />
+ <m:t>2</m:t>
+ </m:r>
+ </m:sup>
+ </m:sSup>
+ <m:sSub>
+ <m:e>
+ <m:bar>
+ <m:barPr>
+ <m:pos m:val="top" />
+ </m:barPr>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>u</m:t>
+ </m:r>
+ </m:e>
+ </m:bar>
+ </m:e>
+ <m:sub>
+ <m:r>
+ <m:rPr />
+ <m:t>ɛ</m:t>
+ </m:r>
+ </m:sub>
+ </m:sSub>
+ <m:sSubSup>
+ <m:e>
+ <m:bar>
+ <m:barPr>
+ <m:pos m:val="bot" />
+ </m:barPr>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>u</m:t>
+ </m:r>
+ </m:e>
+ </m:bar>
+ </m:e>
+ <m:sub>
+ <m:r>
+ <m:rPr />
+ <m:t>b</m:t>
+ </m:r>
+ </m:sub>
+ <m:sup>
+ <m:r>
+ <m:rPr />
+ <m:t>a</m:t>
+ </m:r>
+ </m:sup>
+ </m:sSubSup>
+ <m:limUpp>
+ <m:e>
+ <m:acc>
+ <m:accPr>
+ <m:chr m:val="︷" />
+ </m:accPr>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>a</m:t>
+ </m:r>
+ <m:r>
+ <m:rPr />
+ <m:t>+</m:t>
+ </m:r>
+ <m:r>
+ <m:rPr />
+ <m:t>b</m:t>
+ </m:r>
+ </m:e>
+ </m:acc>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr>
+ <m:sty m:val="p" />
+ </m:rPr>
+ <m:t>term</m:t>
+ </m:r>
+ </m:lim>
+ </m:limUpp>
+ <m:limUpp>
+ <m:e>
+ <m:acc>
+ <m:accPr>
+ <m:chr m:val="⎴" />
+ </m:accPr>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>a</m:t>
+ </m:r>
+ <m:r>
+ <m:rPr />
+ <m:t>+</m:t>
+ </m:r>
+ <m:r>
+ <m:rPr />
+ <m:t>b</m:t>
+ </m:r>
+ </m:e>
+ </m:acc>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>c</m:t>
+ </m:r>
+ </m:lim>
+ </m:limUpp>
+ <m:limLow>
+ <m:e>
+ <m:limLow>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>a</m:t>
+ </m:r>
+ <m:r>
+ <m:rPr />
+ <m:t>+</m:t>
+ </m:r>
+ <m:r>
+ <m:rPr />
+ <m:t>b</m:t>
+ </m:r>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>︸</m:t>
+ </m:r>
+ </m:lim>
+ </m:limLow>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>c</m:t>
+ </m:r>
+ </m:lim>
+ </m:limLow>
+ <m:limLow>
+ <m:e>
+ <m:limLow>
+ <m:e>
+ <m:r>
+ <m:rPr />
+ <m:t>a</m:t>
+ </m:r>
+ <m:r>
+ <m:rPr />
+ <m:t>+</m:t>
+ </m:r>
+ <m:r>
+ <m:rPr />
+ <m:t>b</m:t>
+ </m:r>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>⎵</m:t>
+ </m:r>
+ </m:lim>
+ </m:limLow>
+ </m:e>
+ <m:lim>
+ <m:r>
+ <m:rPr />
+ <m:t>c</m:t>
+ </m:r>
+ </m:lim>
+ </m:limLow>
+ </m:oMath>
+</m:oMathPara>
View
4 tests/subsup.tex
@@ -0,0 +1,4 @@
+ x^a_b x_b^a \min_A \max_B \det_C \Pr_A \gcd_A
+ \dot{u}^2 \overline{u}_\varepsilon \underline{u}^a_b
+ \overbrace{a+b}^{\text{term}} \overbracket{a+b}^{c}
+ \underbrace{a+b}_{c} \underbracket{a+b}_{c}
View
108 tests/subsup.xhtml
@@ -0,0 +1,108 @@
+<?xml version='1.0' ?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta content="application/xhtml+xml; charset=UTF-8" http-equiv="Content-Type" />
+ </head>
+ <body>
+ <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
+ <mrow>
+ <msubsup>
+ <mi>x</mi>
+ <mi>b</mi>
+ <mi>a</mi>
+ </msubsup>
+ <msubsup>
+ <mi>x</mi>
+ <mi>b</mi>
+ <mi>a</mi>
+ </msubsup>
+ <munder>
+ <mi>min</mi>
+ <mi>A</mi>
+ </munder>
+ <munder>
+ <mi>max</mi>
+ <mi>B</mi>
+ </munder>
+ <munder>
+ <mi>det</mi>
+ <mi>C</mi>
+ </munder>
+ <munder>
+ <mi>Pr</mi>
+ <mi>A</mi>
+ </munder>
+ <munder>
+ <mi>gcd</mi>
+ <mi>A</mi>
+ </munder>
+ <msup>
+ <mover>
+ <mi>u</mi>
+ <mo accent="true">.</mo>
+ </mover>
+ <mn>2</mn>
+ </msup>
+ <msub>
+ <mover>
+ <mi>u</mi>
+ <mo accent="true">¯</mo>
+ </mover>
+ <mi>ɛ</mi>
+ </msub>
+ <msubsup>
+ <munder>
+ <mi>u</mi>
+ <mo accent="true">¯</mo>
+ </munder>
+ <mi>b</mi>
+ <mi>a</mi>
+ </msubsup>
+ <mover>
+ <mover>
+ <mrow>
+ <mi>a</mi>
+ <mo>+</mo>
+ <mi>b</mi>
+ </mrow>
+ <mo accent="true">︷</mo>
+ </mover>
+ <mtext mathvariant="normal">term</mtext>
+ </mover>
+ <mover>
+ <mover>
+ <mrow>
+ <mi>a</mi>
+ <mo>+</mo>
+ <mi>b</mi>
+ </mrow>
+ <mo accent="true">⎴</mo>
+ </mover>
+ <mi>c</mi>
+ </mover>
+ <munder>
+ <munder>
+ <mrow>
+ <mi>a</mi>
+ <mo>+</mo>
+ <mi>b</mi>
+ </mrow>
+ <mo accent="true">︸</mo>
+ </munder>
+ <mi>c</mi>
+ </munder>
+ <munder>
+ <munder>
+ <mrow>
+ <mi>a</mi>
+ <mo>+</mo>
+ <mi>b</mi>
+ </mrow>
+ <mo accent="true">⎵</mo>
+ </munder>
+ <mi>c</mi>
+ </munder>
+ </mrow>
+ </math>
+ </body>
+</html>

No commit comments for this range

Something went wrong with that request. Please try again.