Skip to content

Commit

Permalink
Merge pull request #12 from rekka/master
Browse files Browse the repository at this point in the history
Treat \ commands as tex tokens in arguments
  • Loading branch information
jgm committed May 19, 2012
2 parents 8145486 + 81a88a5 commit bd79b26
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Text/TeXMath/Parser.hs
Expand Up @@ -97,7 +97,7 @@ inbraces :: TP Exp
inbraces = liftM EGrouped (braces $ many $ notFollowedBy (char '}') >> expr) inbraces = liftM EGrouped (braces $ many $ notFollowedBy (char '}') >> expr)


texToken :: TP Exp texToken :: TP Exp
texToken = inbraces <|> inbrackets <|> texToken = texSymbol <|> inbraces <|> inbrackets <|>
do c <- anyChar do c <- anyChar
spaces spaces
return $ if isDigit c return $ if isDigit c
Expand Down
110 changes: 110 additions & 0 deletions tests/tokens.omml
@@ -0,0 +1,110 @@
<?xml version='1.0' ?>
<m:oMathPara>
<m:oMathParaPr>
<m:jc m:val="center" />
</m:oMathParaPr>
<m:oMath>
<m:acc>
<m:accPr>
<m:chr m:val="~" />
</m:accPr>
<m:e>
<m:r>
<m:rPr />
<m:t>ϕ</m:t>
</m:r>
</m:e>
</m:acc>
<m:rad>
<m:radPr>
<m:degHide m:val="on" />
</m:radPr>
<m:deg />
<m:e>
<m:r>
<m:rPr />
<m:t>ϕ</m:t>
</m:r>
</m:e>
</m:rad>
<m:f>
<m:fPr>
<m:type m:val="bar" />
</m:fPr>
<m:num>
<m:r>
<m:rPr />
<m:t>ϕ</m:t>
</m:r>
</m:num>
<m:den>
<m:r>
<m:rPr />
<m:t>ξ</m:t>
</m:r>
</m:den>
</m:f>
<m:f>
<m:fPr>
<m:type m:val="bar" />
</m:fPr>
<m:num>
<m:r>
<m:rPr />
<m:t>ϕ</m:t>
</m:r>
</m:num>
<m:den>
<m:r>
<m:rPr />
<m:t>ξ</m:t>
</m:r>
</m:den>
</m:f>
<m:f>
<m:fPr>
<m:type m:val="bar" />
</m:fPr>
<m:num>
<m:r>
<m:rPr />
<m:t>ϕ</m:t>
</m:r>
</m:num>
<m:den>
<m:r>
<m:rPr />
<m:t>ξ</m:t>
</m:r>
</m:den>
</m:f>
<m:r>
<m:rPr />
<m:t>(</m:t>
</m:r>
<m:r>
<m:rPr />
<m:t>ϕ</m:t>
</m:r>
<m:r>
<m:rPr />
<m:t>)</m:t>
</m:r>
<m:r>
<m:rPr />
<m:t>(</m:t>
</m:r>
<m:r>
<m:rPr />
<m:t>ϕ</m:t>
</m:r>
<m:r>
<m:rPr />
<m:t>)</m:t>
</m:r>
<m:r>
<m:rPr />
<m:t>ξ</m:t>
</m:r>
</m:oMath>
</m:oMathPara>
17 changes: 17 additions & 0 deletions tests/tokens.tex
@@ -0,0 +1,17 @@
\newcommand{\my}[1]{(#1)}


% diacritics
\tilde\phi

% unary operators
\sqrt\phi

% binary operators
\frac\phi\xi
\frac \phi {\xi}
\frac {\phi} \xi

% custom
\my\phi
\my{\phi}\xi
38 changes: 38 additions & 0 deletions tests/tokens.xhtml
@@ -0,0 +1,38 @@
<?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>
<mover>
<mi>ϕ</mi>
<mo accent="true">~</mo>
</mover>
<msqrt>
<mi>ϕ</mi>
</msqrt>
<mfrac>
<mi>ϕ</mi>
<mi>ξ</mi>
</mfrac>
<mfrac>
<mi>ϕ</mi>
<mi>ξ</mi>
</mfrac>
<mfrac>
<mi>ϕ</mi>
<mi>ξ</mi>
</mfrac>
<mo stretchy="false">(</mo>
<mi>ϕ</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">(</mo>
<mi>ϕ</mi>
<mo stretchy="false">)</mo>
<mi>ξ</mi>
</mrow>
</math>
</body>
</html>

0 comments on commit bd79b26

Please sign in to comment.