/usr/share/doc/libjs-asciimathml/asciimathsyntax.html is in libjs-asciimathml 2.0.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ASCIIMathML: Syntax and constants</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="ASCIIMathML.js"></script>
<style type="text/css">
#menu, #title, #subtitle, #author {text-align: center}
body {font-family: Arial; background-color:beige}
p,table {font-family: Times}
</style>
</head>
<body>
<div id="menu">
| <a href="asciimath.html">Home Page</a> |
<a href="asciimathsyntax.html">Syntax</a> |
<a href="asciimathdemo.html">Try it</a> |
<a href="asciimathcalculator.html">Calculator</a> |
<a href="http://mathcs.chapman.edu/~jipsen/mathml/asciimathdownload.html">Download</a> |
<a href="http://mathcs.chapman.edu/~jipsen/math/index.php/ASCIIMathML/ASCIIMathGraphs.html">Graphs</a> |
<a href="http://mathcs.chapman.edu/~jipsen/math/index.php/ASCIIMathML/ASCIIMathFAQ.html">ASCIIMath FAQ</a> |
<a href="http://mathcs.chapman.edu/~jipsen/math/index.php/ASCIIMathML/ASCIIMathMLSandbox.html">Sandbox</a> |
<a href="http://mathcs.chapman.edu/~jipsen/math/index.php/ASCIIMathML/ASCIIMathCommentsAndSuggestions.html">Comments</a> |
</div>
<hr/>
<h2 id="title">
ASCIIMathML.js (ver 2.0): Syntax and List of Constants
</h2>
<h4 id="subtitle">
The main aims of the ASCIIMathML syntax are: -- 1. close to standard
mathematical notation -- 2. easy to read -- 3. easy to type
</h4>
<p>
You can use your favorite editor to write HTML pages that use this
JavaScript program. If the page is viewed by a browser that does not
support MathML or JavaScript, the ASCII formulas are still quite
readable. Most users will not have to read the technicalities on
this page. If you type
</p>
<pre>amath x^2 or a_(m n) or a_{m n} or (x+1)/y or sqrtx endamath</pre>
<p>
you pretty much get what you expect: amath x^2 or a_(m n) or a_{m n} or
(x+1)/y or sqrtx endamath. The a``math ... enda``math tokens are used to
start/stop the <b>new auto-math-recognize mode</b>. Of course one can still use
the \`...\` back-quotes to delimit math formulas explicitly
(\$...\$ should only be used for LaTeX formulas).
The choice of grouping parenthesis is up to you
(they don't have to match either). If the displayed expression can be
parsed uniquely without them, they are omitted. Printing the table of
constant symbols (below) may be helpful (but is not necessary if you
know the LaTeX equivalents).
</p>
<p>
It is hoped that this simple input format for MathML will further
encourage its use on the web. The remainder of this page gives a fairly
detailed specification of the ASCII syntax. <b>The expressions described here
correspond to a wellspecified subset of Presentation MathML and behave
in a predictable way.</b>
</p>
<p>
The syntax is very permissive and does not generate syntax
errors. This allows mathematically incorrect expressions to be
displayed, which is important for teaching purposes. It also causes
less frustration when previewing formulas.
</p>
<p>
The parser uses no operator precedence and only respects the grouping
brackets, subscripts, superscript, fractions and (square) roots. This
is done for reasons of efficiency and generality. The resulting MathML
code can quite easily be processed further to ensure additional syntactic
requirements of any particular application.
</p>
<p>
<b>The grammar:</b> Here is a definition of the grammar used to parse
ASCIIMathML expressions. In the Backus-Naur form given below, the
letter on the left of the ::= represents a category of symbols that
could be one of the possible sequences of symbols listed on the right.
The vertical bar | separates the alternatives.
</p>
<pre>c ::= [A-z] | numbers | greek letters | other constant symbols (see below)
u ::= 'sqrt' | 'text' | 'bb' | other unary symbols for font commands
b ::= 'frac' | 'root' | 'stackrel' binary symbols
l ::= ( | [ | { | (: | {: left brackets
r ::= ) | ] | } | :) | :} right brackets
S ::= c | lEr | uS | bSS | "any" simple expression
E ::= SE | S/S |S_S | S^S | S_S^S expression (fraction, sub-, super-, subsuperscript)
</pre>
<p>
<b>The translation rules:</b> Each terminal symbol is translated into
a corresponding MathML node. The constants are mostly converted to
their respective Unicode symbols. The other expressions are converted
as follows:<br/>
<table>
<tr><td>l`S`r</td><td>`to`</td><td><mrow>l`S`r</mrow>
(note that any pair of brackets can be used to delimit subexpressions,
they don't have to match)</td></tr>
<tr><td>sqrt `S`</td><td>`to`</td><td><msqrt>`S'`</msqrt></td></tr>
<tr><td>text `S`</td><td>`to`</td><td><mtext>`S'`</mtext></td></tr>
<tr><td>"any"</td><td>`to`</td><td><mtext>any</mtext></td></tr>
<tr><td>
frac `S_1` `S_2`</td><td>`to`</td><td><mfrac>`S_1'` `S_2'`</mfrac>
</td></tr>
<tr><td>
root `S_1` `S_2`</td><td>`to`</td><td><mroot>`S_2'` `S_1'`</mroot>
</td></tr>
<tr><td>
stackrel `S_1` `S_2`</td><td>`to`</td><td><mover>`S_2'` `S_1'`</mover>
</td></tr>
<tr><td>
`S_1`/`S_2`</td><td>`to`</td><td><mfrac>`S_1'` `S_2'`</mfrac>
</td></tr>
<tr><td>
`S_1`_`S_2`</td><td>`to`</td><td><msub>`S_1` `S_2'`</msub>
</td></tr>
<tr><td>
`S_1`^`S_2`</td><td>`to`</td><td><msup>`S_1` `S_2'`</msup>
</td></tr>
<tr><td>
`S_1`_`S_2`^`S_3`</td><td>`to`</td>
<td><msubsup>`S_1` `S_2'` `S_3'`</msubsup> or
<munderover>`S_1` `S_2'` `S_3'`</munderover> (in some cases)
</td></tr>
</table>
In the rules above, the expression `S'` is the same as `S`, except that if
`S` has an outer level of brackets, then `S'` is the expression inside
these brackets.
<p>
<b>Matrices:</b> A simple syntax for matrices is also recognized:
<br/>
<tt>l(`S_(11)`,...,`S_(1n)`),(...),(`S_(m1)`,...,`S_(mn)`)r</tt>
    or    
<tt>l[`S_(11)`,...,`S_(1n)`],[...],[`S_(m1)`,...,`S_(mn)`]r</tt>.
<br/>
Here <tt>l</tt> and <tt>r</tt> stand for any of the left and right
brackets (just like in the grammar they do not have to match). Both of
these expressions are translated to
<br/>
<mrow>l<mtable><mtr><mtd>`S_(11)`</mtd>...
<mtd>`S_(1n)`</mtd></mtr>...
<mtr><mtd>`S_(m1)`</mtd>...
<mtd>`S_(mn)`</mtd></mtr></mtable>r</mrow>.
<br/>
For example
<tt>{(S_(11),...,S_(1n)),(vdots,ddots,vdots),(S_(m1),...,S_(mn))]</tt>
displays as `{(S_(11),...,S_(1n)),(vdots,ddots,vdots),(S_(m1),...,S_(mn))]`.
<br/>
Note that each row must have the same number of expressions, and there
should be at least two rows.
<p>
<b>Tokenization:</b> The input formula is broken into tokens using a
"longest matching initial substring search". Suppose the input formula
has been processed from left to right up to a fixed position. The
longest string from the list of constants (given below) that matches
the initial part of the remainder of the formula is the next token. If
there is no matching string, then the first character of the remainder
is the next token. The symbol table at the top of the ASCIIMathML.js
script specifies whether a symbol is a math operator (surrounded by a
<mo> tag) or a math identifier (surrounded by a <mi> tag). For
single character tokens, letters are treated as math identifiers, and
non-alphanumeric characters are treated as math operators. For digits,
see "Numbers" below.
<p>
Spaces are significant when they separate characters and thus prevent
a certain string of characters from matching one of the
constants. Multiple spaces and end-of-line characters are equivalent
to a single space.
</p>
<h4>
Now for a complete list of constants (<a
href="http://math.chapman.edu/cgi-bin/mathxml.pl?Complete_list_of_LaTeX_constants">standard
LaTeX names</a> also work):
</h4>
<p>
Numbers: A string of digits, optionally preceded by a minus sign, and
optionally followed by a decimal point (a period) and another string
of digits, is parsed as a single token and converted to a MathML
number, i.e., enclosed with the <mn> tag. If it is not desirable to
have a preceding minus sign be part of the number, a space should be inserted.
Thus <tt>x-1</tt> is converted to <mi>x</mi><mn>-1</mn>, whereas
<tt>x - 1</tt> is converted to <mi>x</mi><mo>-</mo><mn>1</mn>.
</p>
<p>
Greek letters:
alpha `alpha`
beta `beta`
chi `chi`
delta `delta`
Delta `Delta`
epsilon `epsilon`
varepsilon `varepsilon`
eta `eta`
gamma `gamma`
Gamma `Gamma`
iota `iota`
kappa `kappa`
lambda `lambda`
Lambda `Lambda`
mu `mu`
nu `nu`
omega `omega`
Omega `Omega`
phi `phi`
varphi `varphi`
Phi `Phi`
pi `pi`
Pi `Pi`
psi `psi`
Psi `Psi`
rho `rho`
sigma `sigma`
Sigma `Sigma`
tau `tau`
theta `theta`
vartheta `vartheta`
Theta `Theta`
upsilon `upsilon`
xi `xi`
Xi `Xi`
zeta `zeta`
</p>
<table border="5" cellpadding="10">
<tr valign="top"><td>
Operation symbols
<table border="5" cellpadding="10">
<tr><th>Type</th><th>See</th></tr>
<tr><td>+</td><td>`+`</td></tr>
<tr><td>-</td><td>`-`</td></tr>
<tr><td>*</td><td>`*`</td></tr>
<tr><td>**</td><td>`**`</td></tr>
<tr><td>//</td><td>`//`</td></tr>
<tr><td>\\</td><td>`\\ `</td></tr>
<tr><td>xx</td><td>`xx`</td></tr>
<tr><td>-:</td><td>`-:`</td></tr>
<tr><td>@</td><td>`@`</td></tr>
<tr><td>o+</td><td>`o+`</td></tr>
<tr><td>ox</td><td>`ox`</td></tr>
<tr><td>o.</td><td>`o.`</td></tr>
<tr><td>sum</td><td>`sum`</td></tr>
<tr><td>prod</td><td>`prod`</td></tr>
<tr><td>^^</td><td>`^^`</td></tr>
<tr><td>^^^</td><td>`^^^`</td></tr>
<tr><td>vv</td><td>`vv`</td></tr>
<tr><td>vvv</td><td>`vvv`</td></tr>
<tr><td>nn</td><td>`nn`</td></tr>
<tr><td>nnn</td><td>`nnn`</td></tr>
<tr><td>uu</td><td>`uu`</td></tr>
<tr><td>uuu</td><td>`uuu`</td></tr>
</table>
</td><td>
Relation symbols
<table border="5" cellpadding="10">
<tr><th>Type</th><th>See</th></tr>
<tr><td>=</td><td>`=`</td></tr>
<tr><td>!=</td><td>`!=`</td></tr>
<tr><td>< </td><td>`<`</td></tr>
<tr><td>></td><td>`>`</td></tr>
<tr><td><=</td><td>`<=`</td></tr>
<tr><td>>=</td><td>`>=`</td></tr>
<tr><td>-<</td><td>`-<`</td></tr>
<tr><td>>-</td><td>`>-`</td></tr>
<tr><td>in</td><td>`in`</td></tr>
<tr><td>!in</td><td>`notin`</td></tr>
<tr><td>sub</td><td>`sub`</td></tr>
<tr><td>sup</td><td>`sup`</td></tr>
<tr><td>sube</td><td>`sube`</td></tr>
<tr><td>supe</td><td>`supe`</td></tr>
<tr><td>-=</td><td>`-=`</td></tr>
<tr><td>~=</td><td>`~=`</td></tr>
<tr><td>~~</td><td>`~~`</td></tr>
<tr><td>prop</td><td>`prop`</td></tr>
</table>
</td><td>
Logical symbols
<table border="5" cellpadding="10">
<tr><th>Type</th><th>See</th></tr>
<tr><td>and</td><td>`and`</td></tr>
<tr><td>or</td><td>`or`</td></tr>
<tr><td>not</td><td>`not`</td></tr>
<tr><td>=></td><td>`=>`</td></tr>
<tr><td>if</td><td>`if`</td></tr>
<tr><td>iff</td><td>`iff`</td></tr>
<tr><td>AA</td><td>`AA`</td></tr>
<tr><td>EE</td><td>`EE`</td></tr>
<tr><td>_|_</td><td>`_|_`</td></tr>
<tr><td>TT</td><td>`TT`</td></tr>
<tr><td>|--</td><td>`|--`</td></tr>
<tr><td>|==</td><td>`|==`</td></tr>
</table>
<p>
Grouping brackets
<table border="5" cellpadding="10">
<tr><th>Type</th><th>See</th></tr>
<tr><td>(</td><td>`(`</td></tr>
<tr><td>)</td><td>`)`</td></tr>
<tr><td>[</td><td>`[`</td></tr>
<tr><td>]</td><td>`]`</td></tr>
<tr><td>{</td><td>`{`</td></tr>
<tr><td>}</td><td>`}`</td></tr>
<tr><td>(:</td><td>`(:`</td></tr>
<tr><td>:)</td><td>`:)`</td></tr>
<tr><td>{:</td><td>`{:`</td></tr>
<tr><td>:}</td><td>`{::}`</td></tr>
</table>
</td><td>
Miscellaneous symbols
<table border="5" cellpadding="10">
<tr><th>Type</th><th>See</th></tr>
<tr><td>int</td><td>`int`</td></tr>
<tr><td>oint</td><td>`oint`</td></tr>
<tr><td>del</td><td>`del`</td></tr>
<tr><td>grad</td><td>`grad`</td></tr>
<tr><td>+-</td><td>`+-`</td></tr>
<tr><td>O/</td><td>`O/`</td></tr>
<tr><td>oo</td><td>`oo`</td></tr>
<tr><td>aleph</td><td>`aleph`</td></tr>
<tr><td>/_</td><td>`/_`</td></tr>
<tr><td>:.</td><td>`:.`</td></tr>
<tr><td>|...|</td><td>|`...`|</td></tr>
<tr><td>|cdots|</td><td>|`cdots`|</td></tr>
<tr><td>vdots</td><td>`vdots`</td></tr>
<tr><td>ddots</td><td>`ddots`</td></tr>
<tr><td>|\ |</td><td>|`\ `|</td></tr>
<tr><td>|quad|</td><td>|`quad`|</td></tr>
<tr><td>diamond</td><td>`diamond`</td></tr>
<tr><td>square</td><td>`square`</td></tr>
<tr><td>|__</td><td>`|__`</td></tr>
<tr><td>__|</td><td>`__|`</td></tr>
<tr><td>|~</td><td>`|~`</td></tr>
<tr><td>~|</td><td>`~|`</td></tr>
<tr><td>CC</td><td>`CC`</td></tr>
<tr><td>NN</td><td>`NN`</td></tr>
<tr><td>QQ</td><td>`QQ`</td></tr>
<tr><td>RR</td><td>`RR`</td></tr>
<tr><td>ZZ</td><td>`ZZ`</td></tr>
</table>
</td><td>
Standard functions
<table border="5" cellpadding="10">
<tr><th>Type</th><th>See</th></tr>
<tr><td>sin</td><td>`sin`</td></tr>
<tr><td>cos</td><td>`cos`</td></tr>
<tr><td>tan</td><td>`tan`</td></tr>
<tr><td>csc</td><td>`csc`</td></tr>
<tr><td>sec</td><td>`sec`</td></tr>
<tr><td>cot</td><td>`cot`</td></tr>
<tr><td>sinh</td><td>`sinh`</td></tr>
<tr><td>cosh</td><td>`cosh`</td></tr>
<tr><td>tanh</td><td>`tanh`</td></tr>
<tr><td>log</td><td>`log`</td></tr>
<tr><td>ln</td><td>`ln`</td></tr>
<tr><td>det</td><td>`det`</td></tr>
<tr><td>dim</td><td>`dim`</td></tr>
<tr><td>lim</td><td>`lim`</td></tr>
<tr><td>mod</td><td>`mod`</td></tr>
<tr><td>gcd</td><td>`gcd`</td></tr>
<tr><td>lcm</td><td>`lcm`</td></tr>
<tr><td>min</td><td>`min`</td></tr>
<tr><td>max</td><td>`max`</td></tr>
</table>
<p>
Accents
<table border="5" cellpadding="10">
<tr><th>Type</th><th>See</th></tr>
<tr><td>hat x</td><td>`hat x`</td></tr>
<tr><td>bar x</td><td>`bar x`</td></tr>
<tr><td>ul x</td><td>`ul x`</td></tr>
<tr><td>vec x</td><td>`vec x`</td></tr>
<tr><td>dot x</td><td>`dot x`</td></tr>
<tr><td>ddot x</td><td>`ddot x`</td></tr>
</table>
</td><td>
Arrows
<table border="5" cellpadding="10">
<tr><th>Type</th><th>See</th></tr>
<tr><td>uarr</td><td>`uarr`</td></tr>
<tr><td>darr</td><td>`darr`</td></tr>
<tr><td>rarr</td><td>`rarr`</td></tr>
<tr><td>-></td><td>`->`</td></tr>
<tr><td>|-></td><td>`|->`</td></tr>
<tr><td>larr</td><td>`larr`</td></tr>
<tr><td>harr</td><td>`harr`</td></tr>
<tr><td>rArr</td><td>`rArr`</td></tr>
<tr><td>lArr</td><td>`lArr`</td></tr>
<tr><td>hArr</td><td>`hArr`</td></tr>
</table>
<p>
Font commands
<table border="5" cellpadding="10">
<tr><th>Type</th><th>See</th></tr>
<tr><td>bb A</td><td>`bb A`</td></tr>
<tr><td>bbb A</td><td>`bbb A`</td></tr>
<tr><td>cc A</td><td>`cc A`</td></tr>
<tr><td>tt A</td><td>`tt A`</td></tr>
<tr><td>fr A</td><td>`fr A`</td></tr>
<tr><td>sf A</td><td>`sf A`</td></tr>
</table>
</td></tr>
</table>
<p>
Of course you may want or need other symbols from the thousands of <a
href="http://www.ctan.org/tex-archive/info/symbols/comprehensive/symbols-letter.pdf">LaTeX
symbols</a> or <a
href="http://www.alanwood.net/unicode/#links">unicode
symbols</a>. Fortunately ASCIIMathML.js is very <a
href="asciimathextend.html">easy
to extend</a>, so you can tailor it to your specific needs. (This
could be compared to the LaTeX macro files that many users have
developed over the years.)
</p>
<!--p>
Large files with many formulas can take quite some time to display,
especially on older hardware. To address this problem, there is a
version ASCIIMathMLite.js that has a shorter symbol table (without the
LaTeX symbol names) and slightly simplified parser. Send me an email
at <a href="mailto:jipsen@chapman.edu">jipsen@chapman.edu</a> if you
would like a copy.
</p>
<p>
Another version that also recognizes some <a
href="http://www.latex-project.org/">LaTeX</a> layout commands and
(the fairly standard) <a
href="http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page">Wiki
formatting codes</a> for ASCII text is in the works. This further
simplifies producing mathematical content for the web. However such a
development is less easily justified since there are good free HTML
editors and the HTML syntax is a well-established standard that is
simple enough to be coded by hand.
</p-->
<hr/>
<div id="author">
<a href="http://www.chapman.edu/~jipsen/">Peter Jipsen</a>,
<a href="http://www.chapman.edu/">Chapman University</a>, September 2007
</div>
</body>
</html>
|