Debian Codegraph @

tests/data/asciimath-xhtml11.html

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
7 <meta name="generator" content="AsciiDoc test" />
8 <title>ASCIIMath Formulae</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
11
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
15 }
16
17 /* Title font. */
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
21 #toctitle,
22 #author, #revnumber, #revdate, #revremark,
23 #footer {
24 font-family: Arial,Helvetica,sans-serif;
25 }
26
27 body {
28 margin: 1em 5% 1em 5%;
29 }
30
31 a {
32 color: blue;
33 text-decoration: underline;
34 }
35 a:visited {
36 color: fuchsia;
37 }
38
39 em {
40 font-style: italic;
41 color: navy;
42 }
43
44 strong {
45 font-weight: bold;
46 color: #083194;
47 }
48
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
54 }
55
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
58 }
59 h2 {
60 padding-top: 0.5em;
61 }
62 h3 {
63 float: left;
64 }
65 h3 + * {
66 clear: left;
67 }
68 h5 {
69 font-size: 1.0em;
70 }
71
72 div.sectionbody {
73 margin-left: 0;
74 }
75
76 hr {
77 border: 1px solid silver;
78 }
79
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
83 }
84
85 ul, ol, li > p {
86 margin-top: 0;
87 }
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
90
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
97 }
98 pre {
99 white-space: pre-wrap;
100 }
101
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
106 }
107 #email {
108 }
109 #revnumber, #revdate, #revremark {
110 }
111
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
117 }
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
121 }
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
125 }
126
127 #preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
130 }
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
136 }
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
142 }
143
144 div.content { /* Block element content. */
145 padding: 0;
146 }
147
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
155 }
156 div.title + * {
157 margin-top: 0;
158 }
159
160 td div.title:first-child {
161 margin-top: 0.0em;
162 }
163 div.content div.title:first-child {
164 margin-top: 0.0em;
165 }
166 div.content + div.title {
167 margin-top: 0.0em;
168 }
169
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
175 }
176
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
182 }
183
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
190 }
191
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
195 }
196
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
200 }
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
204 }
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
208 }
209
210 div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
217 }
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
221 }
222
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
226 }
227
228 div.imageblock div.content { padding-left: 0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
231
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
235 }
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
241 }
242 dd > *:first-child {
243 margin-top: 0.1em;
244 }
245
246 ul, ol {
247 list-style-position: outside;
248 }
249 ol.arabic {
250 list-style-type: decimal;
251 }
252 ol.loweralpha {
253 list-style-type: lower-alpha;
254 }
255 ol.upperalpha {
256 list-style-type: upper-alpha;
257 }
258 ol.lowerroman {
259 list-style-type: lower-roman;
260 }
261 ol.upperroman {
262 list-style-type: upper-roman;
263 }
264
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
270 }
271
272 tfoot {
273 font-weight: bold;
274 }
275 td > div.verse {
276 white-space: pre;
277 }
278
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
282 }
283 div.hdlist tr {
284 padding-bottom: 15px;
285 }
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
288 }
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
294 }
295 td.hdlist2 {
296 vertical-align: top;
297 }
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
301 }
302
303 .comment {
304 background: yellow;
305 }
306
307 .footnote, .footnoteref {
308 font-size: 0.8em;
309 }
310
311 span.footnote, span.footnoteref {
312 vertical-align: super;
313 }
314
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
318 }
319
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
322 }
323
324 #footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
332 }
333
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
338 }
339 div.colist td img {
340 margin-top: 0.3em;
341 }
342
343 @media print {
344 #footer-badges { display: none; }
345 }
346
347 #toc {
348 margin-bottom: 2.5em;
349 }
350
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
357 }
358
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
362 }
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
366 }
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
370 }
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
374 }
375
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
392
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
409
410 span.big { font-size: 2em; }
411 span.small { font-size: 0.6em; }
412
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
416
417 div.unbreakable { page-break-inside: avoid; }
418
419
420 /*
421 * xhtml11 specific
422 *
423 * */
424
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
428 }
429 div.tableblock > table {
430 border: 3px solid #527bbd;
431 }
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
435 }
436 p.table {
437 margin-top: 0;
438 }
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
442 }
443 div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
446 }
447 div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
450 }
451
452
453 /*
454 * html5 specific
455 *
456 * */
457
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
461 }
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
465 }
466 p.tableblock {
467 margin-top: 0;
468 }
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
475 }
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
481 }
482
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
486 }
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
490 }
491 table.tableblock.frame-none {
492 border-style: hidden;
493 }
494
495 th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
497 }
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
500 }
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
503 }
504
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
507 }
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
510 }
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
513 }
514
515
516 /*
517 * manpage specific
518 *
519 * */
520
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
526 }
527 body.manpage h2 {
528 border-style: none;
529 }
530 body.manpage div.sectionbody {
531 margin-left: 3em;
532 }
533
534 @media print {
535 body.manpage div#toc { display: none; }
536 }
537
538
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
542 var asciidoc = { // Namespace.
543
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
547
548 /* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
550 *
551 * Table Of Content generator
552 * Version: 0.4
553 *
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
556 */
557
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
560
561 // toclevels = 1..4.
562 toc: function (toclevels) {
563
564 function getText(el) {
565 var text = "";
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
568 text += i.data;
569 else if (i.firstChild != null)
570 text += getText(i);
571 }
572 return text;
573 }
574
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
579 }
580
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
586 // browsers).
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
593 }
594 iterate(i);
595 }
596 }
597 }
598 iterate(el);
599 return result;
600 }
601
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
605 }
606
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
610 for (i = 0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute("class")
614 && entry.getAttribute("class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
616 }
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
619 }
620
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById("content"), toclevels);
623 for (var i = 0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id == "")
626 entry.element.id = "_toc_" + i;
627 var a = document.createElement("a");
628 a.href = "#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement("div");
631 div.appendChild(a);
632 div.className = "toclevel" + entry.toclevel;
633 toc.appendChild(div);
634 }
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
637 },
638
639
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
643
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
646 */
647
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
654 }
655 var entriesToRemove = [];
656 for (i = 0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
659 entriesToRemove.push(entry);
660 }
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
663 }
664
665 // Rebuild footnote entries.
666 var cont = document.getElementById("content");
667 var spans = cont.getElementsByTagName("span");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
673 var note = spans[i].getAttribute("data-note");
674 if (!note) {
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
678 spans[i].innerHTML =
679 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n + "</a>]";
681 spans[i].setAttribute("data-note", note);
682 }
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n + "'>" +
685 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
686 n + "</a>. " + note + "</div>";
687 var id =spans[i].getAttribute("id");
688 if (id != null) refs["#"+id] = n;
689 }
690 }
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
694 // Process footnoterefs.
695 for (i=0; i<spans.length; i++) {
696 if (spans[i].className == "footnoteref") {
697 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
698 href = href.match(/#.*/)[0]; // Because IE return full URL.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
703 }
704 }
705 }
706 },
707
708 install: function(toclevels) {
709 var timerId;
710
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
715 }
716 }
717
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
721 }
722
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
728 }
729
730 }
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 <script type="text/javascript">
735 /*<![CDATA[*/
736 /*
737 ASCIIMathML.js
738 ==============
739 This file contains JavaScript functions to convert ASCII math notation
740 to Presentation MathML. The conversion is done while the (X)HTML page
741 loads, and should work with Firefox/Mozilla/Netscape 7+ and Internet
742 Explorer 6+MathPlayer (http://www.dessci.com/en/products/mathplayer/).
743 Just add the next line to your (X)HTML page with this file in the same folder:
744 This is a convenient and inexpensive solution for authoring MathML.
745
746 Version 1.4.7 Dec 15, 2005, (c) Peter Jipsen http://www.chapman.edu/~jipsen
747 Latest version at http://www.chapman.edu/~jipsen/mathml/ASCIIMathML.js
748 For changes see http://www.chapman.edu/~jipsen/mathml/asciimathchanges.txt
749 If you use it on a webpage, please send the URL to [email protected]
750
751 This program is free software; you can redistribute it and/or modify
752 it under the terms of the GNU General Public License as published by
753 the Free Software Foundation; either version 2 of the License, or (at
754 your option) any later version.
755
756 This program is distributed in the hope that it will be useful,
757 but WITHOUT ANY WARRANTY; without even the implied warranty of
758 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
759 General Public License (at http://www.gnu.org/copyleft/gpl.html)
760 for more details.
761 */
762
763 var checkForMathML = true; // check if browser can display MathML
764 var notifyIfNoMathML = true; // display note if no MathML capability
765 var alertIfNoMathML = false; // show alert box if no MathML capability
766 var mathcolor = ""; // change it to "" (to inherit) or any other color
767 var mathfontfamily = "serif"; // change to "" to inherit (works in IE)
768 // or another family (e.g. "arial")
769 var displaystyle = true; // puts limits above and below large operators
770 var showasciiformulaonhover = true; // helps students learn ASCIIMath
771 var decimalsign = "."; // change to "," if you like, beware of `(1,2)`!
772 var AMdelimiter1 = "`", AMescape1 = "\\\\`"; // can use other characters
773 var AMdelimiter2 = "$", AMescape2 = "\\\\\\$", AMdelimiter2regexp = "\\$";
774 var doubleblankmathdelimiter = false; // if true, x+1 is equal to `x+1`
775 // for IE this works only in <!-- -->
776 //var separatetokens;// has been removed (email me if this is a problem)
777 var isIE = document.createElementNS==null;
778
779 if (document.getElementById==null)
780 alert("This webpage requires a recent browser such as\
781 \nMozilla/Netscape 7+ or Internet Explorer 6+MathPlayer")
782
783 // all further global variables start with "AM"
784
785 function AMcreateElementXHTML(t) {
786 if (isIE) return document.createElement(t);
787 else return document.createElementNS("http://www.w3.org/1999/xhtml",t);
788 }
789
790 function AMnoMathMLNote() {
791 var nd = AMcreateElementXHTML("h3");
792 nd.setAttribute("align","center")
793 nd.appendChild(AMcreateElementXHTML("p"));
794 nd.appendChild(document.createTextNode("To view the "));
795 var an = AMcreateElementXHTML("a");
796 an.appendChild(document.createTextNode("ASCIIMathML"));
797 an.setAttribute("href","http://www.chapman.edu/~jipsen/asciimath.html");
798 nd.appendChild(an);
799 nd.appendChild(document.createTextNode(" notation use Internet Explorer 6+"));
800 an = AMcreateElementXHTML("a");
801 an.appendChild(document.createTextNode("MathPlayer"));
802 an.setAttribute("href","http://www.dessci.com/en/products/mathplayer/download.htm");
803 nd.appendChild(an);
804 nd.appendChild(document.createTextNode(" or Netscape/Mozilla/Firefox"));
805 nd.appendChild(AMcreateElementXHTML("p"));
806 return nd;
807 }
808
809 function AMisMathMLavailable() {
810 if (navigator.appName.slice(0,8)=="Netscape")
811 if (navigator.appVersion.slice(0,1)>="5") return null;
812 else return AMnoMathMLNote();
813 else if (navigator.appName.slice(0,9)=="Microsoft")
814 try {
815 var ActiveX = new ActiveXObject("MathPlayer.Factory.1");
816 return null;
817 } catch (e) {
818 return AMnoMathMLNote();
819 }
820 else return AMnoMathMLNote();
821 }
822
823 // character lists for Mozilla/Netscape fonts
824 var AMcal = [0xEF35,0x212C,0xEF36,0xEF37,0x2130,0x2131,0xEF38,0x210B,0x2110,0xEF39,0xEF3A,0x2112,0x2133,0xEF3B,0xEF3C,0xEF3D,0xEF3E,0x211B,0xEF3F,0xEF40,0xEF41,0xEF42,0xEF43,0xEF44,0xEF45,0xEF46];
825 var AMfrk = [0xEF5D,0xEF5E,0x212D,0xEF5F,0xEF60,0xEF61,0xEF62,0x210C,0x2111,0xEF63,0xEF64,0xEF65,0xEF66,0xEF67,0xEF68,0xEF69,0xEF6A,0x211C,0xEF6B,0xEF6C,0xEF6D,0xEF6E,0xEF6F,0xEF70,0xEF71,0x2128];
826 var AMbbb = [0xEF8C,0xEF8D,0x2102,0xEF8E,0xEF8F,0xEF90,0xEF91,0x210D,0xEF92,0xEF93,0xEF94,0xEF95,0xEF96,0x2115,0xEF97,0x2119,0x211A,0x211D,0xEF98,0xEF99,0xEF9A,0xEF9B,0xEF9C,0xEF9D,0xEF9E,0x2124];
827
828 var CONST = 0, UNARY = 1, BINARY = 2, INFIX = 3, LEFTBRACKET = 4,
829 RIGHTBRACKET = 5, SPACE = 6, UNDEROVER = 7, DEFINITION = 8,
830 LEFTRIGHT = 9, TEXT = 10; // token types
831
832 var AMsqrt = {input:"sqrt", tag:"msqrt", output:"sqrt", tex:null, ttype:UNARY},
833 AMroot = {input:"root", tag:"mroot", output:"root", tex:null, ttype:BINARY},
834 AMfrac = {input:"frac", tag:"mfrac", output:"/", tex:null, ttype:BINARY},
835 AMdiv = {input:"/", tag:"mfrac", output:"/", tex:null, ttype:INFIX},
836 AMover = {input:"stackrel", tag:"mover", output:"stackrel", tex:null, ttype:BINARY},
837 AMsub = {input:"_", tag:"msub", output:"_", tex:null, ttype:INFIX},
838 AMsup = {input:"^", tag:"msup", output:"^", tex:null, ttype:INFIX},
839 AMtext = {input:"text", tag:"mtext", output:"text", tex:null, ttype:TEXT},
840 AMmbox = {input:"mbox", tag:"mtext", output:"mbox", tex:null, ttype:TEXT},
841 AMquote = {input:"\"", tag:"mtext", output:"mbox", tex:null, ttype:TEXT};
842
843 var AMsymbols = [
844 //some greek symbols
845 {input:"alpha", tag:"mi", output:"\u03B1", tex:null, ttype:CONST},
846 {input:"beta", tag:"mi", output:"\u03B2", tex:null, ttype:CONST},
847 {input:"chi", tag:"mi", output:"\u03C7", tex:null, ttype:CONST},
848 {input:"delta", tag:"mi", output:"\u03B4", tex:null, ttype:CONST},
849 {input:"Delta", tag:"mo", output:"\u0394", tex:null, ttype:CONST},
850 {input:"epsi", tag:"mi", output:"\u03B5", tex:"epsilon", ttype:CONST},
851 {input:"varepsilon", tag:"mi", output:"\u025B", tex:null, ttype:CONST},
852 {input:"eta", tag:"mi", output:"\u03B7", tex:null, ttype:CONST},
853 {input:"gamma", tag:"mi", output:"\u03B3", tex:null, ttype:CONST},
854 {input:"Gamma", tag:"mo", output:"\u0393", tex:null, ttype:CONST},
855 {input:"iota", tag:"mi", output:"\u03B9", tex:null, ttype:CONST},
856 {input:"kappa", tag:"mi", output:"\u03BA", tex:null, ttype:CONST},
857 {input:"lambda", tag:"mi", output:"\u03BB", tex:null, ttype:CONST},
858 {input:"Lambda", tag:"mo", output:"\u039B", tex:null, ttype:CONST},
859 {input:"mu", tag:"mi", output:"\u03BC", tex:null, ttype:CONST},
860 {input:"nu", tag:"mi", output:"\u03BD", tex:null, ttype:CONST},
861 {input:"omega", tag:"mi", output:"\u03C9", tex:null, ttype:CONST},
862 {input:"Omega", tag:"mo", output:"\u03A9", tex:null, ttype:CONST},
863 {input:"phi", tag:"mi", output:"\u03C6", tex:null, ttype:CONST},
864 {input:"varphi", tag:"mi", output:"\u03D5", tex:null, ttype:CONST},
865 {input:"Phi", tag:"mo", output:"\u03A6", tex:null, ttype:CONST},
866 {input:"pi", tag:"mi", output:"\u03C0", tex:null, ttype:CONST},
867 {input:"Pi", tag:"mo", output:"\u03A0", tex:null, ttype:CONST},
868 {input:"psi", tag:"mi", output:"\u03C8", tex:null, ttype:CONST},
869 {input:"Psi", tag:"mi", output:"\u03A8", tex:null, ttype:CONST},
870 {input:"rho", tag:"mi", output:"\u03C1", tex:null, ttype:CONST},
871 {input:"sigma", tag:"mi", output:"\u03C3", tex:null, ttype:CONST},
872 {input:"Sigma", tag:"mo", output:"\u03A3", tex:null, ttype:CONST},
873 {input:"tau", tag:"mi", output:"\u03C4", tex:null, ttype:CONST},
874 {input:"theta", tag:"mi", output:"\u03B8", tex:null, ttype:CONST},
875 {input:"vartheta", tag:"mi", output:"\u03D1", tex:null, ttype:CONST},
876 {input:"Theta", tag:"mo", output:"\u0398", tex:null, ttype:CONST},
877 {input:"upsilon", tag:"mi", output:"\u03C5", tex:null, ttype:CONST},
878 {input:"xi", tag:"mi", output:"\u03BE", tex:null, ttype:CONST},
879 {input:"Xi", tag:"mo", output:"\u039E", tex:null, ttype:CONST},
880 {input:"zeta", tag:"mi", output:"\u03B6", tex:null, ttype:CONST},
881
882 //binary operation symbols
883 {input:"*", tag:"mo", output:"\u22C5", tex:"cdot", ttype:CONST},
884 {input:"**", tag:"mo", output:"\u22C6", tex:"star", ttype:CONST},
885 {input:"//", tag:"mo", output:"/", tex:null, ttype:CONST},
886 {input:"\\\\", tag:"mo", output:"\\", tex:"backslash", ttype:CONST},
887 {input:"setminus", tag:"mo", output:"\\", tex:null, ttype:CONST},
888 {input:"xx", tag:"mo", output:"\u00D7", tex:"times", ttype:CONST},
889 {input:"-:", tag:"mo", output:"\u00F7", tex:"divide", ttype:CONST},
890 {input:"@", tag:"mo", output:"\u2218", tex:"circ", ttype:CONST},
891 {input:"o+", tag:"mo", output:"\u2295", tex:"oplus", ttype:CONST},
892 {input:"ox", tag:"mo", output:"\u2297", tex:"otimes", ttype:CONST},
893 {input:"o.", tag:"mo", output:"\u2299", tex:"odot", ttype:CONST},
894 {input:"sum", tag:"mo", output:"\u2211", tex:null, ttype:UNDEROVER},
895 {input:"prod", tag:"mo", output:"\u220F", tex:null, ttype:UNDEROVER},
896 {input:"^^", tag:"mo", output:"\u2227", tex:"wedge", ttype:CONST},
897 {input:"^^^", tag:"mo", output:"\u22C0", tex:"bigwedge", ttype:UNDEROVER},
898 {input:"vv", tag:"mo", output:"\u2228", tex:"vee", ttype:CONST},
899 {input:"vvv", tag:"mo", output:"\u22C1", tex:"bigvee", ttype:UNDEROVER},
900 {input:"nn", tag:"mo", output:"\u2229", tex:"cap", ttype:CONST},
901 {input:"nnn", tag:"mo", output:"\u22C2", tex:"bigcap", ttype:UNDEROVER},
902 {input:"uu", tag:"mo", output:"\u222A", tex:"cup", ttype:CONST},
903 {input:"uuu", tag:"mo", output:"\u22C3", tex:"bigcup", ttype:UNDEROVER},
904
905 //binary relation symbols
906 {input:"!=", tag:"mo", output:"\u2260", tex:"ne", ttype:CONST},
907 {input:":=", tag:"mo", output:":=", tex:null, ttype:CONST},
908 {input:"lt", tag:"mo", output:"<", tex:null, ttype:CONST},
909 {input:"<=", tag:"mo", output:"\u2264", tex:"le", ttype:CONST},
910 {input:"lt=", tag:"mo", output:"\u2264", tex:"leq", ttype:CONST},
911 {input:">=", tag:"mo", output:"\u2265", tex:"ge", ttype:CONST},
912 {input:"geq", tag:"mo", output:"\u2265", tex:null, ttype:CONST},
913 {input:"-<", tag:"mo", output:"\u227A", tex:"prec", ttype:CONST},
914 {input:"-lt", tag:"mo", output:"\u227A", tex:null, ttype:CONST},
915 {input:">-", tag:"mo", output:"\u227B", tex:"succ", ttype:CONST},
916 {input:"-<=", tag:"mo", output:"\u2AAF", tex:"preceq", ttype:CONST},
917 {input:">-=", tag:"mo", output:"\u2AB0", tex:"succeq", ttype:CONST},
918 {input:"in", tag:"mo", output:"\u2208", tex:null, ttype:CONST},
919 {input:"!in", tag:"mo", output:"\u2209", tex:"notin", ttype:CONST},
920 {input:"sub", tag:"mo", output:"\u2282", tex:"subset", ttype:CONST},
921 {input:"sup", tag:"mo", output:"\u2283", tex:"supset", ttype:CONST},
922 {input:"sube", tag:"mo", output:"\u2286", tex:"subseteq", ttype:CONST},
923 {input:"supe", tag:"mo", output:"\u2287", tex:"supseteq", ttype:CONST},
924 {input:"-=", tag:"mo", output:"\u2261", tex:"equiv", ttype:CONST},
925 {input:"~=", tag:"mo", output:"\u2245", tex:"cong", ttype:CONST},
926 {input:"~~", tag:"mo", output:"\u2248", tex:"approx", ttype:CONST},
927 {input:"prop", tag:"mo", output:"\u221D", tex:"propto", ttype:CONST},
928
929 //logical symbols
930 {input:"and", tag:"mtext", output:"and", tex:null, ttype:SPACE},
931 {input:"or", tag:"mtext", output:"or", tex:null, ttype:SPACE},
932 {input:"not", tag:"mo", output:"\u00AC", tex:"neg", ttype:CONST},
933 {input:"=>", tag:"mo", output:"\u21D2", tex:"implies", ttype:CONST},
934 {input:"if", tag:"mo", output:"if", tex:null, ttype:SPACE},
935 {input:"<=>", tag:"mo", output:"\u21D4", tex:"iff", ttype:CONST},
936 {input:"AA", tag:"mo", output:"\u2200", tex:"forall", ttype:CONST},
937 {input:"EE", tag:"mo", output:"\u2203", tex:"exists", ttype:CONST},
938 {input:"_|_", tag:"mo", output:"\u22A5", tex:"bot", ttype:CONST},
939 {input:"TT", tag:"mo", output:"\u22A4", tex:"top", ttype:CONST},
940 {input:"|--", tag:"mo", output:"\u22A2", tex:"vdash", ttype:CONST},
941 {input:"|==", tag:"mo", output:"\u22A8", tex:"models", ttype:CONST},
942
943 //grouping brackets
944 {input:"(", tag:"mo", output:"(", tex:null, ttype:LEFTBRACKET},
945 {input:")", tag:"mo", output:")", tex:null, ttype:RIGHTBRACKET},
946 {input:"[", tag:"mo", output:"[", tex:null, ttype:LEFTBRACKET},
947 {input:"]", tag:"mo", output:"]", tex:null, ttype:RIGHTBRACKET},
948 {input:"{", tag:"mo", output:"{", tex:null, ttype:LEFTBRACKET},
949 {input:"}", tag:"mo", output:"}", tex:null, ttype:RIGHTBRACKET},
950 {input:"|", tag:"mo", output:"|", tex:null, ttype:LEFTRIGHT},
951 //{input:"||", tag:"mo", output:"||", tex:null, ttype:LEFTRIGHT},
952 {input:"(:", tag:"mo", output:"\u2329", tex:"langle", ttype:LEFTBRACKET},
953 {input:":)", tag:"mo", output:"\u232A", tex:"rangle", ttype:RIGHTBRACKET},
954 {input:"<<", tag:"mo", output:"\u2329", tex:null, ttype:LEFTBRACKET},
955 {input:">>", tag:"mo", output:"\u232A", tex:null, ttype:RIGHTBRACKET},
956 {input:"{:", tag:"mo", output:"{:", tex:null, ttype:LEFTBRACKET, invisible:true},
957 {input:":}", tag:"mo", output:":}", tex:null, ttype:RIGHTBRACKET, invisible:true},
958
959 //miscellaneous symbols
960 {input:"int", tag:"mo", output:"\u222B", tex:null, ttype:CONST},
961 {input:"dx", tag:"mi", output:"{:d x:}", tex:null, ttype:DEFINITION},
962 {input:"dy", tag:"mi", output:"{:d y:}", tex:null, ttype:DEFINITION},
963 {input:"dz", tag:"mi", output:"{:d z:}", tex:null, ttype:DEFINITION},
964 {input:"dt", tag:"mi", output:"{:d t:}", tex:null, ttype:DEFINITION},
965 {input:"oint", tag:"mo", output:"\u222E", tex:null, ttype:CONST},
966 {input:"del", tag:"mo", output:"\u2202", tex:"partial", ttype:CONST},
967 {input:"grad", tag:"mo", output:"\u2207", tex:"nabla", ttype:CONST},
968 {input:"+-", tag:"mo", output:"\u00B1", tex:"pm", ttype:CONST},
969 {input:"O/", tag:"mo", output:"\u2205", tex:"emptyset", ttype:CONST},
970 {input:"oo", tag:"mo", output:"\u221E", tex:"infty", ttype:CONST},
971 {input:"aleph", tag:"mo", output:"\u2135", tex:null, ttype:CONST},
972 {input:"...", tag:"mo", output:"...", tex:"ldots", ttype:CONST},
973 {input:":.", tag:"mo", output:"\u2234", tex:"therefore", ttype:CONST},
974 {input:"/_", tag:"mo", output:"\u2220", tex:"angle", ttype:CONST},
975 {input:"\\ ", tag:"mo", output:"\u00A0", tex:null, ttype:CONST},
976 {input:"quad", tag:"mo", output:"\u00A0\u00A0", tex:null, ttype:CONST},
977 {input:"qquad", tag:"mo", output:"\u00A0\u00A0\u00A0\u00A0", tex:null, ttype:CONST},
978 {input:"cdots", tag:"mo", output:"\u22EF", tex:null, ttype:CONST},
979 {input:"vdots", tag:"mo", output:"\u22EE", tex:null, ttype:CONST},
980 {input:"ddots", tag:"mo", output:"\u22F1", tex:null, ttype:CONST},
981 {input:"diamond", tag:"mo", output:"\u22C4", tex:null, ttype:CONST},
982 {input:"square", tag:"mo", output:"\u25A1", tex:null, ttype:CONST},
983 {input:"|__", tag:"mo", output:"\u230A", tex:"lfloor", ttype:CONST},
984 {input:"__|", tag:"mo", output:"\u230B", tex:"rfloor", ttype:CONST},
985 {input:"|~", tag:"mo", output:"\u2308", tex:"lceiling", ttype:CONST},
986 {input:"~|", tag:"mo", output:"\u2309", tex:"rceiling", ttype:CONST},
987 {input:"CC", tag:"mo", output:"\u2102", tex:null, ttype:CONST},
988 {input:"NN", tag:"mo", output:"\u2115", tex:null, ttype:CONST},
989 {input:"QQ", tag:"mo", output:"\u211A", tex:null, ttype:CONST},
990 {input:"RR", tag:"mo", output:"\u211D", tex:null, ttype:CONST},
991 {input:"ZZ", tag:"mo", output:"\u2124", tex:null, ttype:CONST},
992 {input:"f", tag:"mi", output:"f", tex:null, ttype:UNARY, func:true},
993 {input:"g", tag:"mi", output:"g", tex:null, ttype:UNARY, func:true},
994
995 //standard functions
996 {input:"lim", tag:"mo", output:"lim", tex:null, ttype:UNDEROVER},
997 {input:"Lim", tag:"mo", output:"Lim", tex:null, ttype:UNDEROVER},
998 {input:"sin", tag:"mo", output:"sin", tex:null, ttype:UNARY, func:true},
999 {input:"cos", tag:"mo", output:"cos", tex:null, ttype:UNARY, func:true},
1000 {input:"tan", tag:"mo", output:"tan", tex:null, ttype:UNARY, func:true},
1001 {input:"sinh", tag:"mo", output:"sinh", tex:null, ttype:UNARY, func:true},
1002 {input:"cosh", tag:"mo", output:"cosh", tex:null, ttype:UNARY, func:true},
1003 {input:"tanh", tag:"mo", output:"tanh", tex:null, ttype:UNARY, func:true},
1004 {input:"cot", tag:"mo", output:"cot", tex:null, ttype:UNARY, func:true},
1005 {input:"sec", tag:"mo", output:"sec", tex:null, ttype:UNARY, func:true},
1006 {input:"csc", tag:"mo", output:"csc", tex:null, ttype:UNARY, func:true},
1007 {input:"log", tag:"mo", output:"log", tex:null, ttype:UNARY, func:true},
1008 {input:"ln", tag:"mo", output:"ln", tex:null, ttype:UNARY, func:true},
1009 {input:"det", tag:"mo", output:"det", tex:null, ttype:UNARY, func:true},
1010 {input:"dim", tag:"mo", output:"dim", tex:null, ttype:CONST},
1011 {input:"mod", tag:"mo", output:"mod", tex:null, ttype:CONST},
1012 {input:"gcd", tag:"mo", output:"gcd", tex:null, ttype:UNARY, func:true},
1013 {input:"lcm", tag:"mo", output:"lcm", tex:null, ttype:UNARY, func:true},
1014 {input:"lub", tag:"mo", output:"lub", tex:null, ttype:CONST},
1015 {input:"glb", tag:"mo", output:"glb", tex:null, ttype:CONST},
1016 {input:"min", tag:"mo", output:"min", tex:null, ttype:UNDEROVER},
1017 {input:"max", tag:"mo", output:"max", tex:null, ttype:UNDEROVER},
1018
1019 //arrows
1020 {input:"uarr", tag:"mo", output:"\u2191", tex:"uparrow", ttype:CONST},
1021 {input:"darr", tag:"mo", output:"\u2193", tex:"downarrow", ttype:CONST},
1022 {input:"rarr", tag:"mo", output:"\u2192", tex:"rightarrow", ttype:CONST},
1023 {input:"->", tag:"mo", output:"\u2192", tex:"to", ttype:CONST},
1024 {input:"|->", tag:"mo", output:"\u21A6", tex:"mapsto", ttype:CONST},
1025 {input:"larr", tag:"mo", output:"\u2190", tex:"leftarrow", ttype:CONST},
1026 {input:"harr", tag:"mo", output:"\u2194", tex:"leftrightarrow", ttype:CONST},
1027 {input:"rArr", tag:"mo", output:"\u21D2", tex:"Rightarrow", ttype:CONST},
1028 {input:"lArr", tag:"mo", output:"\u21D0", tex:"Leftarrow", ttype:CONST},
1029 {input:"hArr", tag:"mo", output:"\u21D4", tex:"Leftrightarrow", ttype:CONST},
1030
1031 //commands with argument
1032 AMsqrt, AMroot, AMfrac, AMdiv, AMover, AMsub, AMsup,
1033 {input:"hat", tag:"mover", output:"\u005E", tex:null, ttype:UNARY, acc:true},
1034 {input:"bar", tag:"mover", output:"\u00AF", tex:"overline", ttype:UNARY, acc:true},
1035 {input:"vec", tag:"mover", output:"\u2192", tex:null, ttype:UNARY, acc:true},
1036 {input:"dot", tag:"mover", output:".", tex:null, ttype:UNARY, acc:true},
1037 {input:"ddot", tag:"mover", output:"..", tex:null, ttype:UNARY, acc:true},
1038 {input:"ul", tag:"munder", output:"\u0332", tex:"underline", ttype:UNARY, acc:true},
1039 AMtext, AMmbox, AMquote,
1040 {input:"bb", tag:"mstyle", atname:"fontweight", atval:"bold", output:"bb", tex:null, ttype:UNARY},
1041 {input:"mathbf", tag:"mstyle", atname:"fontweight", atval:"bold", output:"mathbf", tex:null, ttype:UNARY},
1042 {input:"sf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"sf", tex:null, ttype:UNARY},
1043 {input:"mathsf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"mathsf", tex:null, ttype:UNARY},
1044 {input:"bbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"bbb", tex:null, ttype:UNARY, codes:AMbbb},
1045 {input:"mathbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"mathbb", tex:null, ttype:UNARY, codes:AMbbb},
1046 {input:"cc", tag:"mstyle", atname:"mathvariant", atval:"script", output:"cc", tex:null, ttype:UNARY, codes:AMcal},
1047 {input:"mathcal", tag:"mstyle", atname:"mathvariant", atval:"script", output:"mathcal", tex:null, ttype:UNARY, codes:AMcal},
1048 {input:"tt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"tt", tex:null, ttype:UNARY},
1049 {input:"mathtt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"mathtt", tex:null, ttype:UNARY},
1050 {input:"fr", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"fr", tex:null, ttype:UNARY, codes:AMfrk},
1051 {input:"mathfrak", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"mathfrak", tex:null, ttype:UNARY, codes:AMfrk}
1052 ];
1053
1054 function compareNames(s1,s2) {
1055 if (s1.input > s2.input) return 1
1056 else return -1;
1057 }
1058
1059 var AMnames = []; //list of input symbols
1060
1061 function AMinitSymbols() {
1062 var texsymbols = [], i;
1063 for (i=0; i<AMsymbols.length; i++)
1064 if (AMsymbols[i].tex)
1065 texsymbols[texsymbols.length] = {input:AMsymbols[i].tex,
1066 tag:AMsymbols[i].tag, output:AMsymbols[i].output, ttype:AMsymbols[i].ttype};
1067 AMsymbols = AMsymbols.concat(texsymbols);
1068 AMsymbols.sort(compareNames);
1069 for (i=0; i<AMsymbols.length; i++) AMnames[i] = AMsymbols[i].input;
1070 }
1071
1072 var AMmathml = "http://www.w3.org/1998/Math/MathML";
1073
1074 function AMcreateElementMathML(t) {
1075 if (isIE) return document.createElement("m:"+t);
1076 else return document.createElementNS(AMmathml,t);
1077 }
1078
1079 function AMcreateMmlNode(t,frag) {
1080 // var node = AMcreateElementMathML(name);
1081 if (isIE) var node = document.createElement("m:"+t);
1082 else var node = document.createElementNS(AMmathml,t);
1083 node.appendChild(frag);
1084 return node;
1085 }
1086
1087 function newcommand(oldstr,newstr) {
1088 AMsymbols = AMsymbols.concat([{input:oldstr, tag:"mo", output:newstr,
1089 tex:null, ttype:DEFINITION}]);
1090 }
1091
1092 function AMremoveCharsAndBlanks(str,n) {
1093 //remove n characters and any following blanks
1094 var st;
1095 if (str.charAt(n)=="\\" && str.charAt(n+1)!="\\" && str.charAt(n+1)!=" ")
1096 st = str.slice(n+1);
1097 else st = str.slice(n);
1098 for (var i=0; i<st.length && st.charCodeAt(i)<=32; i=i+1);
1099 return st.slice(i);
1100 }
1101
1102 function AMposition(arr, str, n) {
1103 // return position >=n where str appears or would be inserted
1104 // assumes arr is sorted
1105 if (n==0) {
1106 var h,m;
1107 n = -1;
1108 h = arr.length;
1109 while (n+1<h) {
1110 m = (n+h) >> 1;
1111 if (arr[m]<str) n = m; else h = m;
1112 }
1113 return h;
1114 } else
1115 for (var i=n; i<arr.length && arr[i]<str; i++);
1116 return i; // i=arr.length || arr[i]>=str
1117 }
1118
1119 function AMgetSymbol(str) {
1120 //return maximal initial substring of str that appears in names
1121 //return null if there is none
1122 var k = 0; //new pos
1123 var j = 0; //old pos
1124 var mk; //match pos
1125 var st;
1126 var tagst;
1127 var match = "";
1128 var more = true;
1129 for (var i=1; i<=str.length && more; i++) {
1130 st = str.slice(0,i); //initial substring of length i
1131 j = k;
1132 k = AMposition(AMnames, st, j);
1133 if (k<AMnames.length && str.slice(0,AMnames[k].length)==AMnames[k]){
1134 match = AMnames[k];
1135 mk = k;
1136 i = match.length;
1137 }
1138 more = k<AMnames.length && str.slice(0,AMnames[k].length)>=AMnames[k];
1139 }
1140 AMpreviousSymbol=AMcurrentSymbol;
1141 if (match!=""){
1142 AMcurrentSymbol=AMsymbols[mk].ttype;
1143 return AMsymbols[mk];
1144 }
1145 // if str[0] is a digit or - return maxsubstring of digits.digits
1146 AMcurrentSymbol=CONST;
1147 k = 1;
1148 st = str.slice(0,1);
1149 var integ = true;
1150 while ("0"<=st && st<="9" && k<=str.length) {
1151 st = str.slice(k,k+1);
1152 k++;
1153 }
1154 if (st == decimalsign) {
1155 st = str.slice(k,k+1);
1156 if ("0"<=st && st<="9") {
1157 integ = false;
1158 k++;
1159 while ("0"<=st && st<="9" && k<=str.length) {
1160 st = str.slice(k,k+1);
1161 k++;
1162 }
1163 }
1164 }
1165 if ((integ && k>1) || k>2) {
1166 st = str.slice(0,k-1);
1167 tagst = "mn";
1168 } else {
1169 k = 2;
1170 st = str.slice(0,1); //take 1 character
1171 tagst = (("A">st || st>"Z") && ("a">st || st>"z")?"mo":"mi");
1172 }
1173 if (st=="-" && AMpreviousSymbol==INFIX) {
1174 AMcurrentSymbol = INFIX; //trick "/" into recognizing "-" on second parse
1175 return {input:st, tag:tagst, output:st, ttype:UNARY, func:true};
1176 }
1177 return {input:st, tag:tagst, output:st, ttype:CONST};
1178 }
1179
1180 function AMremoveBrackets(node) {
1181 var st;
1182 if (node.nodeName=="mrow") {
1183 st = node.firstChild.firstChild.nodeValue;
1184 if (st=="(" || st=="[" || st=="{") node.removeChild(node.firstChild);
1185 }
1186 if (node.nodeName=="mrow") {
1187 st = node.lastChild.firstChild.nodeValue;
1188 if (st==")" || st=="]" || st=="}") node.removeChild(node.lastChild);
1189 }
1190 }
1191
1192 /*Parsing ASCII math expressions with the following grammar
1193 v ::= [A-Za-z] | greek letters | numbers | other constant symbols
1194 u ::= sqrt | text | bb | other unary symbols for font commands
1195 b ::= frac | root | stackrel binary symbols
1196 l ::= ( | [ | { | (: | {: left brackets
1197 r ::= ) | ] | } | :) | :} right brackets
1198 S ::= v | lEr | uS | bSS Simple expression
1199 I ::= S_S | S^S | S_S^S | S Intermediate expression
1200 E ::= IE | I/I Expression
1201 Each terminal symbol is translated into a corresponding mathml node.*/
1202
1203 var AMnestingDepth,AMpreviousSymbol,AMcurrentSymbol;
1204
1205 function AMparseSexpr(str) { //parses str and returns [node,tailstr]
1206 var symbol, node, result, i, st,// rightvert = false,
1207 newFrag = document.createDocumentFragment();
1208 str = AMremoveCharsAndBlanks(str,0);
1209 symbol = AMgetSymbol(str); //either a token or a bracket or empty
1210 if (symbol == null || symbol.ttype == RIGHTBRACKET && AMnestingDepth > 0) {
1211 return [null,str];
1212 }
1213 if (symbol.ttype == DEFINITION) {
1214 str = symbol.output+AMremoveCharsAndBlanks(str,symbol.input.length);
1215 symbol = AMgetSymbol(str);
1216 }
1217 switch (symbol.ttype) {
1218 case UNDEROVER:
1219 case CONST:
1220 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1221 return [AMcreateMmlNode(symbol.tag, //its a constant
1222 document.createTextNode(symbol.output)),str];
1223 case LEFTBRACKET: //read (expr+)
1224 AMnestingDepth++;
1225 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1226 result = AMparseExpr(str,true);
1227 AMnestingDepth--;
1228 if (typeof symbol.invisible == "boolean" && symbol.invisible)
1229 node = AMcreateMmlNode("mrow",result[0]);
1230 else {
1231 node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
1232 node = AMcreateMmlNode("mrow",node);
1233 node.appendChild(result[0]);
1234 }
1235 return [node,result[1]];
1236 case TEXT:
1237 if (symbol!=AMquote) str = AMremoveCharsAndBlanks(str,symbol.input.length);
1238 if (str.charAt(0)=="{") i=str.indexOf("}");
1239 else if (str.charAt(0)=="(") i=str.indexOf(")");
1240 else if (str.charAt(0)=="[") i=str.indexOf("]");
1241 else if (symbol==AMquote) i=str.slice(1).indexOf("\"")+1;
1242 else i = 0;
1243 if (i==-1) i = str.length;
1244 st = str.slice(1,i);
1245 if (st.charAt(0) == " ") {
1246 node = AMcreateElementMathML("mspace");
1247 node.setAttribute("width","1ex");
1248 newFrag.appendChild(node);
1249 }
1250 newFrag.appendChild(
1251 AMcreateMmlNode(symbol.tag,document.createTextNode(st)));
1252 if (st.charAt(st.length-1) == " ") {
1253 node = AMcreateElementMathML("mspace");
1254 node.setAttribute("width","1ex");
1255 newFrag.appendChild(node);
1256 }
1257 str = AMremoveCharsAndBlanks(str,i+1);
1258 return [AMcreateMmlNode("mrow",newFrag),str];
1259 case UNARY:
1260 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1261 result = AMparseSexpr(str);
1262 if (result[0]==null) return [AMcreateMmlNode(symbol.tag,
1263 document.createTextNode(symbol.output)),str];
1264 if (typeof symbol.func == "boolean" && symbol.func) { // functions hack
1265 st = str.charAt(0);
1266 if (st=="^" || st=="_" || st=="/" || st=="|" || st==",") {
1267 return [AMcreateMmlNode(symbol.tag,
1268 document.createTextNode(symbol.output)),str];
1269 } else {
1270 node = AMcreateMmlNode("mrow",
1271 AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
1272 node.appendChild(result[0]);
1273 return [node,result[1]];
1274 }
1275 }
1276 AMremoveBrackets(result[0]);
1277 if (symbol.input == "sqrt") { // sqrt
1278 return [AMcreateMmlNode(symbol.tag,result[0]),result[1]];
1279 } else if (typeof symbol.acc == "boolean" && symbol.acc) { // accent
1280 node = AMcreateMmlNode(symbol.tag,result[0]);
1281 node.appendChild(AMcreateMmlNode("mo",document.createTextNode(symbol.output)));
1282 return [node,result[1]];
1283 } else { // font change command
1284 if (!isIE && typeof symbol.codes != "undefined") {
1285 for (i=0; i<result[0].childNodes.length; i++)
1286 if (result[0].childNodes[i].nodeName=="mi" || result[0].nodeName=="mi") {
1287 st = (result[0].nodeName=="mi"?result[0].firstChild.nodeValue:
1288 result[0].childNodes[i].firstChild.nodeValue);
1289 var newst = [];
1290 for (var j=0; j<st.length; j++)
1291 if (st.charCodeAt(j)>64 && st.charCodeAt(j)<91) newst = newst +
1292 String.fromCharCode(symbol.codes[st.charCodeAt(j)-65]);
1293 else newst = newst + st.charAt(j);
1294 if (result[0].nodeName=="mi")
1295 result[0]=AMcreateElementMathML("mo").
1296 appendChild(document.createTextNode(newst));
1297 else result[0].replaceChild(AMcreateElementMathML("mo").
1298 appendChild(document.createTextNode(newst)),result[0].childNodes[i]);
1299 }
1300 }
1301 node = AMcreateMmlNode(symbol.tag,result[0]);
1302 node.setAttribute(symbol.atname,symbol.atval);
1303 return [node,result[1]];
1304 }
1305 case BINARY:
1306 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1307 result = AMparseSexpr(str);
1308 if (result[0]==null) return [AMcreateMmlNode("mo",
1309 document.createTextNode(symbol.input)),str];
1310 AMremoveBrackets(result[0]);
1311 var result2 = AMparseSexpr(result[1]);
1312 if (result2[0]==null) return [AMcreateMmlNode("mo",
1313 document.createTextNode(symbol.input)),str];
1314 AMremoveBrackets(result2[0]);
1315 if (symbol.input=="root" || symbol.input=="stackrel")
1316 newFrag.appendChild(result2[0]);
1317 newFrag.appendChild(result[0]);
1318 if (symbol.input=="frac") newFrag.appendChild(result2[0]);
1319 return [AMcreateMmlNode(symbol.tag,newFrag),result2[1]];
1320 case INFIX:
1321 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1322 return [AMcreateMmlNode("mo",document.createTextNode(symbol.output)),str];
1323 case SPACE:
1324 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1325 node = AMcreateElementMathML("mspace");
1326 node.setAttribute("width","1ex");
1327 newFrag.appendChild(node);
1328 newFrag.appendChild(
1329 AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
1330 node = AMcreateElementMathML("mspace");
1331 node.setAttribute("width","1ex");
1332 newFrag.appendChild(node);
1333 return [AMcreateMmlNode("mrow",newFrag),str];
1334 case LEFTRIGHT:
1335 // if (rightvert) return [null,str]; else rightvert = true;
1336 AMnestingDepth++;
1337 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1338 result = AMparseExpr(str,false);
1339 AMnestingDepth--;
1340 var st = "";
1341 if (result[0].lastChild!=null)
1342 st = result[0].lastChild.firstChild.nodeValue;
1343 if (st == "|") { // its an absolute value subterm
1344 node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
1345 node = AMcreateMmlNode("mrow",node);
1346 node.appendChild(result[0]);
1347 return [node,result[1]];
1348 } else { // the "|" is a \mid
1349 node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
1350 node = AMcreateMmlNode("mrow",node);
1351 return [node,str];
1352 }
1353 default:
1354 //alert("default");
1355 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1356 return [AMcreateMmlNode(symbol.tag, //its a constant
1357 document.createTextNode(symbol.output)),str];
1358 }
1359 }
1360
1361 function AMparseIexpr(str) {
1362 var symbol, sym1, sym2, node, result, underover;
1363 str = AMremoveCharsAndBlanks(str,0);
1364 sym1 = AMgetSymbol(str);
1365 result = AMparseSexpr(str);
1366 node = result[0];
1367 str = result[1];
1368 symbol = AMgetSymbol(str);
1369 if (symbol.ttype == INFIX && symbol.input != "/") {
1370 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1371 // if (symbol.input == "/") result = AMparseIexpr(str); else ...
1372 result = AMparseSexpr(str);
1373 if (result[0] == null) // show box in place of missing argument
1374 result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
1375 else AMremoveBrackets(result[0]);
1376 str = result[1];
1377 // if (symbol.input == "/") AMremoveBrackets(node);
1378 if (symbol.input == "_") {
1379 sym2 = AMgetSymbol(str);
1380 underover = (sym1.ttype == UNDEROVER);
1381 if (sym2.input == "^") {
1382 str = AMremoveCharsAndBlanks(str,sym2.input.length);
1383 var res2 = AMparseSexpr(str);
1384 AMremoveBrackets(res2[0]);
1385 str = res2[1];
1386 node = AMcreateMmlNode((underover?"munderover":"msubsup"),node);
1387 node.appendChild(result[0]);
1388 node.appendChild(res2[0]);
1389 node = AMcreateMmlNode("mrow",node); // so sum does not stretch
1390 } else {
1391 node = AMcreateMmlNode((underover?"munder":"msub"),node);
1392 node.appendChild(result[0]);
1393 }
1394 } else {
1395 node = AMcreateMmlNode(symbol.tag,node);
1396 node.appendChild(result[0]);
1397 }
1398 }
1399 return [node,str];
1400 }
1401
1402 function AMparseExpr(str,rightbracket) {
1403 var symbol, node, result, i, nodeList = [],
1404 newFrag = document.createDocumentFragment();
1405 do {
1406 str = AMremoveCharsAndBlanks(str,0);
1407 result = AMparseIexpr(str);
1408 node = result[0];
1409 str = result[1];
1410 symbol = AMgetSymbol(str);
1411 if (symbol.ttype == INFIX && symbol.input == "/") {
1412 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1413 result = AMparseIexpr(str);
1414 if (result[0] == null) // show box in place of missing argument
1415 result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
1416 else AMremoveBrackets(result[0]);
1417 str = result[1];
1418 AMremoveBrackets(node);
1419 node = AMcreateMmlNode(symbol.tag,node);
1420 node.appendChild(result[0]);
1421 newFrag.appendChild(node);
1422 symbol = AMgetSymbol(str);
1423 }
1424 else if (node!=undefined) newFrag.appendChild(node);
1425 } while ((symbol.ttype != RIGHTBRACKET &&
1426 (symbol.ttype != LEFTRIGHT || rightbracket)
1427 || AMnestingDepth == 0) && symbol!=null && symbol.output!="");
1428 if (symbol.ttype == RIGHTBRACKET || symbol.ttype == LEFTRIGHT) {
1429 // if (AMnestingDepth > 0) AMnestingDepth--;
1430 var len = newFrag.childNodes.length;
1431 if (len>0 && newFrag.childNodes[len-1].nodeName == "mrow" && len>1 &&
1432 newFrag.childNodes[len-2].nodeName == "mo" &&
1433 newFrag.childNodes[len-2].firstChild.nodeValue == ",") { //matrix
1434 var right = newFrag.childNodes[len-1].lastChild.firstChild.nodeValue;
1435 if (right==")" || right=="]") {
1436 var left = newFrag.childNodes[len-1].firstChild.firstChild.nodeValue;
1437 if (left=="(" && right==")" && symbol.output != "}" ||
1438 left=="[" && right=="]") {
1439 var pos = []; // positions of commas
1440 var matrix = true;
1441 var m = newFrag.childNodes.length;
1442 for (i=0; matrix && i<m; i=i+2) {
1443 pos[i] = [];
1444 node = newFrag.childNodes[i];
1445 if (matrix) matrix = node.nodeName=="mrow" &&
1446 (i==m-1 || node.nextSibling.nodeName=="mo" &&
1447 node.nextSibling.firstChild.nodeValue==",")&&
1448 node.firstChild.firstChild.nodeValue==left &&
1449 node.lastChild.firstChild.nodeValue==right;
1450 if (matrix)
1451 for (var j=0; j<node.childNodes.length; j++)
1452 if (node.childNodes[j].firstChild.nodeValue==",")
1453 pos[i][pos[i].length]=j;
1454 if (matrix && i>1) matrix = pos[i].length == pos[i-2].length;
1455 }
1456 if (matrix) {
1457 var row, frag, n, k, table = document.createDocumentFragment();
1458 for (i=0; i<m; i=i+2) {
1459 row = document.createDocumentFragment();
1460 frag = document.createDocumentFragment();
1461 node = newFrag.firstChild; // <mrow>(-,-,...,-,-)</mrow>
1462 n = node.childNodes.length;
1463 k = 0;
1464 node.removeChild(node.firstChild); //remove (
1465 for (j=1; j<n-1; j++) {
1466 if (typeof pos[i][k] != "undefined" && j==pos[i][k]){
1467 node.removeChild(node.firstChild); //remove ,
1468 row.appendChild(AMcreateMmlNode("mtd",frag));
1469 k++;
1470 } else frag.appendChild(node.firstChild);
1471 }
1472 row.appendChild(AMcreateMmlNode("mtd",frag));
1473 if (newFrag.childNodes.length>2) {
1474 newFrag.removeChild(newFrag.firstChild); //remove <mrow>)</mrow>
1475 newFrag.removeChild(newFrag.firstChild); //remove <mo>,</mo>
1476 }
1477 table.appendChild(AMcreateMmlNode("mtr",row));
1478 }
1479 node = AMcreateMmlNode("mtable",table);
1480 if (typeof symbol.invisible == "boolean" && symbol.invisible) node.setAttribute("columnalign","left");
1481 newFrag.replaceChild(node,newFrag.firstChild);
1482 }
1483 }
1484 }
1485 }
1486 str = AMremoveCharsAndBlanks(str,symbol.input.length);
1487 if (typeof symbol.invisible != "boolean" || !symbol.invisible) {
1488 node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
1489 newFrag.appendChild(node);
1490 }
1491 }
1492 return [newFrag,str];
1493 }
1494
1495 function AMparseMath(str) {
1496 var result, node = AMcreateElementMathML("mstyle");
1497 if (mathcolor != "") node.setAttribute("mathcolor",mathcolor);
1498 if (displaystyle) node.setAttribute("displaystyle","true");
1499 if (mathfontfamily != "") node.setAttribute("fontfamily",mathfontfamily);
1500 AMnestingDepth = 0;
1501 node.appendChild(AMparseExpr(str.replace(/^\s+/g,""),false)[0]);
1502 node = AMcreateMmlNode("math",node);
1503 if (showasciiformulaonhover) //fixed by djhsu so newline
1504 node.setAttribute("title",str.replace(/\s+/g," "));//does not show in Gecko
1505 if (mathfontfamily != "" && (isIE || mathfontfamily != "serif")) {
1506 var fnode = AMcreateElementXHTML("font");
1507 fnode.setAttribute("face",mathfontfamily);
1508 fnode.appendChild(node);
1509 return fnode;
1510 }
1511 return node;
1512 }
1513
1514 function AMstrarr2docFrag(arr, linebreaks) {
1515 var newFrag=document.createDocumentFragment();
1516 var expr = false;
1517 for (var i=0; i<arr.length; i++) {
1518 if (expr) newFrag.appendChild(AMparseMath(arr[i]));
1519 else {
1520 var arri = (linebreaks ? arr[i].split("\n\n") : [arr[i]]);
1521 newFrag.appendChild(AMcreateElementXHTML("span").
1522 appendChild(document.createTextNode(arri[0])));
1523 for (var j=1; j<arri.length; j++) {
1524 newFrag.appendChild(AMcreateElementXHTML("p"));
1525 newFrag.appendChild(AMcreateElementXHTML("span").
1526 appendChild(document.createTextNode(arri[j])));
1527 }
1528 }
1529 expr = !expr;
1530 }
1531 return newFrag;
1532 }
1533
1534 function AMprocessNodeR(n, linebreaks) {
1535 var mtch, str, arr, frg, i;
1536 if (n.childNodes.length == 0) {
1537 if ((n.nodeType!=8 || linebreaks) &&
1538 n.parentNode.nodeName!="form" && n.parentNode.nodeName!="FORM" &&
1539 n.parentNode.nodeName!="textarea" && n.parentNode.nodeName!="TEXTAREA" &&
1540 n.parentNode.nodeName!="pre" && n.parentNode.nodeName!="PRE") {
1541 str = n.nodeValue;
1542 if (!(str == null)) {
1543 str = str.replace(/\r\n\r\n/g,"\n\n");
1544 if (doubleblankmathdelimiter) {
1545 str = str.replace(/\x20\x20\./g," "+AMdelimiter1+".");
1546 str = str.replace(/\x20\x20,/g," "+AMdelimiter1+",");
1547 str = str.replace(/\x20\x20/g," "+AMdelimiter1+" ");
1548 }
1549 str = str.replace(/\x20+/g," ");
1550 str = str.replace(/\s*\r\n/g," ");
1551 mtch = false;
1552 str = str.replace(new RegExp(AMescape2, "g"),
1553 function(st){mtch=true;return "AMescape2"});
1554 str = str.replace(new RegExp(AMescape1, "g"),
1555 function(st){mtch=true;return "AMescape1"});
1556 str = str.replace(new RegExp(AMdelimiter2regexp, "g"),AMdelimiter1);
1557 arr = str.split(AMdelimiter1);
1558 for (i=0; i<arr.length; i++)
1559 arr[i]=arr[i].replace(/AMescape2/g,AMdelimiter2).
1560 replace(/AMescape1/g,AMdelimiter1);
1561 if (arr.length>1 || mtch) {
1562 if (checkForMathML) {
1563 checkForMathML = false;
1564 var nd = AMisMathMLavailable();
1565 AMnoMathML = nd != null;
1566 if (AMnoMathML && notifyIfNoMathML)
1567 if (alertIfNoMathML)
1568 alert("To view the ASCIIMathML notation use Internet Explorer 6 +\nMathPlayer (free from www.dessci.com)\n\
1569 or Firefox/Mozilla/Netscape");
1570 else AMbody.insertBefore(nd,AMbody.childNodes[0]);
1571 }
1572 if (!AMnoMathML) {
1573 frg = AMstrarr2docFrag(arr,n.nodeType==8);
1574 var len = frg.childNodes.length;
1575 n.parentNode.replaceChild(frg,n);
1576 return len-1;
1577 } else return 0;
1578 }
1579 }
1580 } else return 0;
1581 } else if (n.nodeName!="math") {
1582 for (i=0; i<n.childNodes.length; i++)
1583 i += AMprocessNodeR(n.childNodes[i], linebreaks);
1584 }
1585 return 0;
1586 }
1587
1588 function AMprocessNode(n, linebreaks, spanclassAM) {
1589 var frag,st;
1590 if (spanclassAM!=null) {
1591 frag = document.getElementsByTagName("span")
1592 for (var i=0;i<frag.length;i++)
1593 if (frag[i].className == "AM")
1594 AMprocessNodeR(frag[i],linebreaks);
1595 } else {
1596 try {
1597 st = n.innerHTML;
1598 } catch(err) {}
1599 if (st==null ||
1600 st.indexOf(AMdelimiter1)!=-1 || st.indexOf(AMdelimiter2)!=-1)
1601 AMprocessNodeR(n,linebreaks);
1602 }
1603 if (isIE) { //needed to match size and font of formula to surrounding text
1604 frag = document.getElementsByTagName('math');
1605 for (var i=0;i<frag.length;i++) frag[i].update()
1606 }
1607 }
1608
1609 var AMbody;
1610 var AMnoMathML = false, AMtranslated = false;
1611
1612 function translate(spanclassAM) {
1613 if (!AMtranslated) { // run this only once
1614 AMtranslated = true;
1615 AMinitSymbols();
1616 AMbody = document.getElementsByTagName("body")[0];
1617 AMprocessNode(AMbody, false, spanclassAM);
1618 }
1619 }
1620
1621 if (isIE) { // avoid adding MathPlayer info explicitly to each webpage
1622 document.write("<object id=\"mathplayer\"\
1623 classid=\"clsid:32F66A20-7614-11D4-BD11-00104BD3F987\"></object>");
1624 document.write("<?import namespace=\"m\" implementation=\"#mathplayer\"?>");
1625 }
1626
1627 // GO1.1 Generic onload by Brothercake
1628 // http://www.brothercake.com/
1629 //onload function (replaces the onload="translate()" in the <body> tag)
1630 function generic()
1631 {
1632 translate();
1633 };
1634 //setup onload function
1635 if(typeof window.addEventListener != 'undefined')
1636 {
1637 //.. gecko, safari, konqueror and standard
1638 window.addEventListener('load', generic, false);
1639 }
1640 else if(typeof document.addEventListener != 'undefined')
1641 {
1642 //.. opera 7
1643 document.addEventListener('load', generic, false);
1644 }
1645 else if(typeof window.attachEvent != 'undefined')
1646 {
1647 //.. win/ie
1648 window.attachEvent('onload', generic);
1649 }
1650 //** remove this condition to degrade older browsers
1651 else
1652 {
1653 //.. mac/ie5 and anything else that gets this far
1654 //if there's an existing onload function
1655 if(typeof window.onload == 'function')
1656 {
1657 //store it
1658 var existing = onload;
1659 //add new onload handler
1660 window.onload = function()
1661 {
1662 //call existing onload function
1663 existing();
1664 //call generic onload function
1665 generic();
1666 };
1667 }
1668 else
1669 {
1670 //setup onload function
1671 window.onload = generic;
1672 }
1673 }
1674 /*]]>*/
1675 </script>
1676 </head>
1677 <body class="article">
1678 <div id="header">
1679 <h1>ASCIIMath Formulae</h1>
1680 </div>
1681 <div id="content">
1682 <div id="preamble">
1683 <div class="sectionbody">
1684 <div class="paragraph"><p><a href="http://asciimath.org/">ASCIIMath</a> is a clever JavaScript written by
1685 Peter Jipsen that dynamically transforms mathematical formulae
1686 written in a wiki-like plain text markup to
1687 <a href="https://www.w3.org/Math/">MathML</a> markup which is displayed as
1688 standard mathematical notation by the Web Browser. See <em>Appendix E</em>
1689 in the AsciiDoc User Guide for more details.</p></div>
1690 <div class="paragraph"><p>The AsciiDoc <code>xhtml11</code> backend supports ASCIIMath&#8201;&#8212;&#8201;it links the
1691 ASCIIMath script and escapes ASCIIMath delimiters and special
1692 characters to yield valid XHTML. To use ASCIIMath:</p></div>
1693 <div class="olist arabic"><ol class="arabic">
1694 <li>
1695 <p>
1696 Include the <code>-a asciimath</code> command-line option when you run
1697 <code>asciidoc(1)</code>.
1698 </p>
1699 </li>
1700 <li>
1701 <p>
1702 Enclose ASCIIMath formulas inside math or double-dollar
1703 passthroughs or in math passthrough blocks.
1704 </p>
1705 </li>
1706 </ol></div>
1707 <div class="paragraph"><p>Here&#8217;s the <a href="asciimath.txt">AsciiDoc source</a> that generated this
1708 page.</p></div>
1709 <div class="ulist"><div class="title">NOTE</div><ul>
1710 <li>
1711 <p>
1712 When you use the <code>asciimath:[]</code> inline macro you need to escape <code>]</code>
1713 characters in the formulas with a backslash, escaping is unnecessary
1714 if you use the double-dollar macro (for examples see the second
1715 formula below).
1716 </p>
1717 </li>
1718 <li>
1719 <p>
1720 See the <a href="http://asciimath.org">ASCIIMath</a> website for ASCIIMath
1721 documentation and the latest version.
1722 </p>
1723 </li>
1724 <li>
1725 <p>
1726 If the formulas don&#8217;t appear to be correct you probably need to
1727 install the correct math fonts (see the
1728 <a href="http://asciimath.org">ASCIIMath</a> website for details).
1729 </p>
1730 </li>
1731 <li>
1732 <p>
1733 See the <a href="latexmathml.html">LaTeXMathML page</a> if you prefer to use
1734 LaTeX math formulas.
1735 </p>
1736 </li>
1737 </ul></div>
1738 <div class="paragraph"><p>A list of example formulas:</p></div>
1739 <div class="ulist"><ul>
1740 <li>
1741 <p>
1742 `[[a,b],[c,d]]((n),(k))`
1743 </p>
1744 </li>
1745 <li>
1746 <p>
1747 `x/x={(1,if x!=0),(text{undefined},if x=0):}`
1748 </p>
1749 </li>
1750 <li>
1751 <p>
1752 `d/dxf(x)=lim_(h-&gt;0)(f(x+h)-f(x))/h`
1753 </p>
1754 </li>
1755 <li>
1756 <p>
1757 `sum_(i=1)\^n i=(n(n+1))/2`$ and <strong>bold
1758 `int_0\^(pi/2) sinx\ dx=1`</strong>
1759 </p>
1760 </li>
1761 <li>
1762 <p>
1763 `(a,b]={x in RR : a &lt; x &lt;= b}`
1764 </p>
1765 </li>
1766 <li>
1767 <p>
1768 `x^2+y_1+z_12^34`
1769 </p>
1770 </li>
1771 </ul></div>
1772 <div class="sidebarblock">
1773 <div class="content">
1774 <div class="paragraph"><p>The first three terms factor to give
1775 `(x+b/(2a))^2=(b^2)/(4a^2)-c/a`.</p></div>
1776 <div class="paragraph"><p>`x+b/(2a)=+-sqrt((b^2)/(4a^2)-c/a)`.</p></div>
1777 <div class="paragraph"><p>Now we take square roots on both sides and get
1778 `x+b/(2a)=+-sqrt((b^2)/(4a^2)-c/a)`.
1779 Finally we move the `b/(2a)` to the right and simplify to
1780 get the two solutions:
1781 <strong>`x_(1,2)=(-b+-sqrt(b^2-4ac))/(2a)`</strong>.</p></div>
1782 </div></div>
1783 </div>
1784 </div>
1785 </div>
1786 <div id="footnotes"><hr /></div>
1787 <div id="footer">
1788 <div id="footer-text">
1789 Last updated
1790 2002-11-25 00:37:42 UTC
1791 </div>
1792 </div>
1793 </body>
1794 </html>