├── .gitignore
├── INSTALL.md
├── README.md
├── build.bat
├── build.sh
├── css
├── asciidoc.css
├── docbook-xsl.css
├── pygments.css
├── slidy.css
├── toc2.css
├── uber-custom.css
└── xhtml11-quirks.css
├── includes
├── error-sample.js
├── error-sample.xml
├── full-example.js
├── full-example.xml
├── message-model.xml
├── search-sample.js
├── search-sample.xml
├── uber-query-string.txt
└── uber-request-body.txt
├── js
├── ASCIIMathML.js
├── LaTeXMathML.js
├── asciidoc.js
├── slidy.js
└── toc.js
├── uber-hypermedia.asciidoc
└── uber-hypermedia.html
/.gitignore:
--------------------------------------------------------------------------------
1 | _site/
2 | .sass-cache/
3 |
--------------------------------------------------------------------------------
/INSTALL.md:
--------------------------------------------------------------------------------
1 | ## Installation
2 |
3 | If you want to contribute to the specification document and properly render HTML version from the AsciiDoc, you will need to install and configure following tools.
4 |
5 | ### On Mac / OS-X
6 |
7 | ```bash
8 | > brew install asciidoc
9 | > brew install source-highlight
10 | ```
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | specification
2 | =============
3 |
4 | [](https://gitter.im/uber-hypermedia/specification?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5 |
6 | UBER Hypermedia Specification
7 |
--------------------------------------------------------------------------------
/build.bat:
--------------------------------------------------------------------------------
1 | @REM build.bat
2 | @ECHO off
3 | python %PATH_ASCII%\asciidoc.py -b html5 -n -a data-uri -a icons uber-hypermedia.asciidoc %*
4 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 |
3 | asciidoc -b html5 -n -a data-uri -a icons uber-hypermedia.asciidoc
4 |
--------------------------------------------------------------------------------
/css/asciidoc.css:
--------------------------------------------------------------------------------
1 | /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
2 |
3 | /* Default font. */
4 | body {
5 | font-family: Georgia,serif;
6 | }
7 |
8 | /* Title font. */
9 | h1, h2, h3, h4, h5, h6,
10 | div.title, caption.title,
11 | thead, p.table.header,
12 | #toctitle,
13 | #author, #revnumber, #revdate, #revremark,
14 | #footer {
15 | font-family: Arial,Helvetica,sans-serif;
16 | }
17 |
18 | body {
19 | margin: 1em 5% 1em 5%;
20 | }
21 |
22 | a {
23 | color: blue;
24 | text-decoration: underline;
25 | }
26 | a:visited {
27 | color: fuchsia;
28 | }
29 |
30 | em {
31 | font-style: italic;
32 | color: navy;
33 | }
34 |
35 | strong {
36 | font-weight: bold;
37 | color: #083194;
38 | }
39 |
40 | h1, h2, h3, h4, h5, h6 {
41 | color: #527bbd;
42 | margin-top: 1.2em;
43 | margin-bottom: 0.5em;
44 | line-height: 1.3;
45 | }
46 |
47 | h1, h2, h3 {
48 | border-bottom: 2px solid silver;
49 | }
50 | h2 {
51 | padding-top: 0.5em;
52 | }
53 | h3 {
54 | float: left;
55 | }
56 | h3 + * {
57 | clear: left;
58 | }
59 | h5 {
60 | font-size: 1.0em;
61 | }
62 |
63 | div.sectionbody {
64 | margin-left: 0;
65 | }
66 |
67 | hr {
68 | border: 1px solid silver;
69 | }
70 |
71 | p {
72 | margin-top: 0.5em;
73 | margin-bottom: 0.5em;
74 | }
75 |
76 | ul, ol, li > p {
77 | margin-top: 0;
78 | }
79 | ul > li { color: #aaa; }
80 | ul > li > * { color: black; }
81 |
82 | .monospaced, code, pre {
83 | font-family: "Courier New", Courier, monospace;
84 | font-size: inherit;
85 | color: navy;
86 | padding: 0;
87 | margin: 0;
88 | }
89 | pre {
90 | white-space: pre-wrap;
91 | }
92 |
93 | #author {
94 | color: #527bbd;
95 | font-weight: bold;
96 | font-size: 1.1em;
97 | }
98 | #email {
99 | }
100 | #revnumber, #revdate, #revremark {
101 | }
102 |
103 | #footer {
104 | font-size: small;
105 | border-top: 2px solid silver;
106 | padding-top: 0.5em;
107 | margin-top: 4.0em;
108 | }
109 | #footer-text {
110 | float: left;
111 | padding-bottom: 0.5em;
112 | }
113 | #footer-badges {
114 | float: right;
115 | padding-bottom: 0.5em;
116 | }
117 |
118 | #preamble {
119 | margin-top: 1.5em;
120 | margin-bottom: 1.5em;
121 | }
122 | div.imageblock, div.exampleblock, div.verseblock,
123 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
124 | div.admonitionblock {
125 | margin-top: 1.0em;
126 | margin-bottom: 1.5em;
127 | }
128 | div.admonitionblock {
129 | margin-top: 2.0em;
130 | margin-bottom: 2.0em;
131 | margin-right: 10%;
132 | color: #606060;
133 | }
134 |
135 | div.content { /* Block element content. */
136 | padding: 0;
137 | }
138 |
139 | /* Block element titles. */
140 | div.title, caption.title {
141 | color: #527bbd;
142 | font-weight: bold;
143 | text-align: left;
144 | margin-top: 1.0em;
145 | margin-bottom: 0.5em;
146 | }
147 | div.title + * {
148 | margin-top: 0;
149 | }
150 |
151 | td div.title:first-child {
152 | margin-top: 0.0em;
153 | }
154 | div.content div.title:first-child {
155 | margin-top: 0.0em;
156 | }
157 | div.content + div.title {
158 | margin-top: 0.0em;
159 | }
160 |
161 | div.sidebarblock > div.content {
162 | background: #ffffee;
163 | border: 1px solid #dddddd;
164 | border-left: 4px solid #f0f0f0;
165 | padding: 0.5em;
166 | }
167 |
168 | div.listingblock > div.content {
169 | border: 1px solid #dddddd;
170 | border-left: 5px solid #f0f0f0;
171 | background: #f8f8f8;
172 | padding: 0.5em;
173 | }
174 |
175 | div.quoteblock, div.verseblock {
176 | padding-left: 1.0em;
177 | margin-left: 1.0em;
178 | margin-right: 10%;
179 | border-left: 5px solid #f0f0f0;
180 | color: #888;
181 | }
182 |
183 | div.quoteblock > div.attribution {
184 | padding-top: 0.5em;
185 | text-align: right;
186 | }
187 |
188 | div.verseblock > pre.content {
189 | font-family: inherit;
190 | font-size: inherit;
191 | }
192 | div.verseblock > div.attribution {
193 | padding-top: 0.75em;
194 | text-align: left;
195 | }
196 | /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
197 | div.verseblock + div.attribution {
198 | text-align: left;
199 | }
200 |
201 | div.admonitionblock .icon {
202 | vertical-align: top;
203 | font-size: 1.1em;
204 | font-weight: bold;
205 | text-decoration: underline;
206 | color: #527bbd;
207 | padding-right: 0.5em;
208 | }
209 | div.admonitionblock td.content {
210 | padding-left: 0.5em;
211 | border-left: 3px solid #dddddd;
212 | }
213 |
214 | div.exampleblock > div.content {
215 | border-left: 3px solid #dddddd;
216 | padding-left: 0.5em;
217 | }
218 |
219 | div.imageblock div.content { padding-left: 0; }
220 | span.image img { border-style: none; vertical-align: text-bottom; }
221 | a.image:visited { color: white; }
222 |
223 | dl {
224 | margin-top: 0.8em;
225 | margin-bottom: 0.8em;
226 | }
227 | dt {
228 | margin-top: 0.5em;
229 | margin-bottom: 0;
230 | font-style: normal;
231 | color: navy;
232 | }
233 | dd > *:first-child {
234 | margin-top: 0.1em;
235 | }
236 |
237 | ul, ol {
238 | list-style-position: outside;
239 | }
240 | ol.arabic {
241 | list-style-type: decimal;
242 | }
243 | ol.loweralpha {
244 | list-style-type: lower-alpha;
245 | }
246 | ol.upperalpha {
247 | list-style-type: upper-alpha;
248 | }
249 | ol.lowerroman {
250 | list-style-type: lower-roman;
251 | }
252 | ol.upperroman {
253 | list-style-type: upper-roman;
254 | }
255 |
256 | div.compact ul, div.compact ol,
257 | div.compact p, div.compact p,
258 | div.compact div, div.compact div {
259 | margin-top: 0.1em;
260 | margin-bottom: 0.1em;
261 | }
262 |
263 | tfoot {
264 | font-weight: bold;
265 | }
266 | td > div.verse {
267 | white-space: pre;
268 | }
269 |
270 | div.hdlist {
271 | margin-top: 0.8em;
272 | margin-bottom: 0.8em;
273 | }
274 | div.hdlist tr {
275 | padding-bottom: 15px;
276 | }
277 | dt.hdlist1.strong, td.hdlist1.strong {
278 | font-weight: bold;
279 | }
280 | td.hdlist1 {
281 | vertical-align: top;
282 | font-style: normal;
283 | padding-right: 0.8em;
284 | color: navy;
285 | }
286 | td.hdlist2 {
287 | vertical-align: top;
288 | }
289 | div.hdlist.compact tr {
290 | margin: 0;
291 | padding-bottom: 0;
292 | }
293 |
294 | .comment {
295 | background: yellow;
296 | }
297 |
298 | .footnote, .footnoteref {
299 | font-size: 0.8em;
300 | }
301 |
302 | span.footnote, span.footnoteref {
303 | vertical-align: super;
304 | }
305 |
306 | #footnotes {
307 | margin: 20px 0 20px 0;
308 | padding: 7px 0 0 0;
309 | }
310 |
311 | #footnotes div.footnote {
312 | margin: 0 0 5px 0;
313 | }
314 |
315 | #footnotes hr {
316 | border: none;
317 | border-top: 1px solid silver;
318 | height: 1px;
319 | text-align: left;
320 | margin-left: 0;
321 | width: 20%;
322 | min-width: 100px;
323 | }
324 |
325 | div.colist td {
326 | padding-right: 0.5em;
327 | padding-bottom: 0.3em;
328 | vertical-align: top;
329 | }
330 | div.colist td img {
331 | margin-top: 0.3em;
332 | }
333 |
334 | @media print {
335 | #footer-badges { display: none; }
336 | }
337 |
338 | #toc {
339 | margin-bottom: 2.5em;
340 | }
341 |
342 | #toctitle {
343 | color: #527bbd;
344 | font-size: 1.1em;
345 | font-weight: bold;
346 | margin-top: 1.0em;
347 | margin-bottom: 0.1em;
348 | }
349 |
350 | div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
351 | margin-top: 0;
352 | margin-bottom: 0;
353 | }
354 | div.toclevel2 {
355 | margin-left: 2em;
356 | font-size: 0.9em;
357 | }
358 | div.toclevel3 {
359 | margin-left: 4em;
360 | font-size: 0.9em;
361 | }
362 | div.toclevel4 {
363 | margin-left: 6em;
364 | font-size: 0.9em;
365 | }
366 |
367 | span.aqua { color: aqua; }
368 | span.black { color: black; }
369 | span.blue { color: blue; }
370 | span.fuchsia { color: fuchsia; }
371 | span.gray { color: gray; }
372 | span.green { color: green; }
373 | span.lime { color: lime; }
374 | span.maroon { color: maroon; }
375 | span.navy { color: navy; }
376 | span.olive { color: olive; }
377 | span.purple { color: purple; }
378 | span.red { color: red; }
379 | span.silver { color: silver; }
380 | span.teal { color: teal; }
381 | span.white { color: white; }
382 | span.yellow { color: yellow; }
383 |
384 | span.aqua-background { background: aqua; }
385 | span.black-background { background: black; }
386 | span.blue-background { background: blue; }
387 | span.fuchsia-background { background: fuchsia; }
388 | span.gray-background { background: gray; }
389 | span.green-background { background: green; }
390 | span.lime-background { background: lime; }
391 | span.maroon-background { background: maroon; }
392 | span.navy-background { background: navy; }
393 | span.olive-background { background: olive; }
394 | span.purple-background { background: purple; }
395 | span.red-background { background: red; }
396 | span.silver-background { background: silver; }
397 | span.teal-background { background: teal; }
398 | span.white-background { background: white; }
399 | span.yellow-background { background: yellow; }
400 |
401 | span.big { font-size: 2em; }
402 | span.small { font-size: 0.6em; }
403 |
404 | span.underline { text-decoration: underline; }
405 | span.overline { text-decoration: overline; }
406 | span.line-through { text-decoration: line-through; }
407 |
408 | div.unbreakable { page-break-inside: avoid; }
409 |
410 |
411 | /*
412 | * xhtml11 specific
413 | *
414 | * */
415 |
416 | div.tableblock {
417 | margin-top: 1.0em;
418 | margin-bottom: 1.5em;
419 | }
420 | div.tableblock > table {
421 | border: 3px solid #527bbd;
422 | }
423 | thead, p.table.header {
424 | font-weight: bold;
425 | color: #527bbd;
426 | }
427 | p.table {
428 | margin-top: 0;
429 | }
430 | /* Because the table frame attribute is overriden by CSS in most browsers. */
431 | div.tableblock > table[frame="void"] {
432 | border-style: none;
433 | }
434 | div.tableblock > table[frame="hsides"] {
435 | border-left-style: none;
436 | border-right-style: none;
437 | }
438 | div.tableblock > table[frame="vsides"] {
439 | border-top-style: none;
440 | border-bottom-style: none;
441 | }
442 |
443 |
444 | /*
445 | * html5 specific
446 | *
447 | * */
448 |
449 | table.tableblock {
450 | margin-top: 1.0em;
451 | margin-bottom: 1.5em;
452 | }
453 | thead, p.tableblock.header {
454 | font-weight: bold;
455 | color: #527bbd;
456 | }
457 | p.tableblock {
458 | margin-top: 0;
459 | }
460 | table.tableblock {
461 | border-width: 3px;
462 | border-spacing: 0px;
463 | border-style: solid;
464 | border-color: #527bbd;
465 | border-collapse: collapse;
466 | }
467 | th.tableblock, td.tableblock {
468 | border-width: 1px;
469 | padding: 4px;
470 | border-style: solid;
471 | border-color: #527bbd;
472 | }
473 |
474 | table.tableblock.frame-topbot {
475 | border-left-style: hidden;
476 | border-right-style: hidden;
477 | }
478 | table.tableblock.frame-sides {
479 | border-top-style: hidden;
480 | border-bottom-style: hidden;
481 | }
482 | table.tableblock.frame-none {
483 | border-style: hidden;
484 | }
485 |
486 | th.tableblock.halign-left, td.tableblock.halign-left {
487 | text-align: left;
488 | }
489 | th.tableblock.halign-center, td.tableblock.halign-center {
490 | text-align: center;
491 | }
492 | th.tableblock.halign-right, td.tableblock.halign-right {
493 | text-align: right;
494 | }
495 |
496 | th.tableblock.valign-top, td.tableblock.valign-top {
497 | vertical-align: top;
498 | }
499 | th.tableblock.valign-middle, td.tableblock.valign-middle {
500 | vertical-align: middle;
501 | }
502 | th.tableblock.valign-bottom, td.tableblock.valign-bottom {
503 | vertical-align: bottom;
504 | }
505 |
506 |
507 | /*
508 | * manpage specific
509 | *
510 | * */
511 |
512 | body.manpage h1 {
513 | padding-top: 0.5em;
514 | padding-bottom: 0.5em;
515 | border-top: 2px solid silver;
516 | border-bottom: 2px solid silver;
517 | }
518 | body.manpage h2 {
519 | border-style: none;
520 | }
521 | body.manpage div.sectionbody {
522 | margin-left: 3em;
523 | }
524 |
525 | @media print {
526 | body.manpage div#toc { display: none; }
527 | }
528 |
--------------------------------------------------------------------------------
/css/docbook-xsl.css:
--------------------------------------------------------------------------------
1 | /*
2 | CSS stylesheet for XHTML produced by DocBook XSL stylesheets.
3 | */
4 |
5 | body {
6 | font-family: Georgia,serif;
7 | }
8 |
9 | code, pre {
10 | font-family: "Courier New", Courier, monospace;
11 | }
12 |
13 | span.strong {
14 | font-weight: bold;
15 | }
16 |
17 | body blockquote {
18 | margin-top: .75em;
19 | line-height: 1.5;
20 | margin-bottom: .75em;
21 | }
22 |
23 | html body {
24 | margin: 1em 5% 1em 5%;
25 | line-height: 1.2;
26 | }
27 |
28 | body div {
29 | margin: 0;
30 | }
31 |
32 | h1, h2, h3, h4, h5, h6
33 | {
34 | color: #527bbd;
35 | font-family: Arial,Helvetica,sans-serif;
36 | }
37 |
38 | div.toc p:first-child,
39 | div.list-of-figures p:first-child,
40 | div.list-of-tables p:first-child,
41 | div.list-of-examples p:first-child,
42 | div.example p.title,
43 | div.sidebar p.title
44 | {
45 | font-weight: bold;
46 | color: #527bbd;
47 | font-family: Arial,Helvetica,sans-serif;
48 | margin-bottom: 0.2em;
49 | }
50 |
51 | body h1 {
52 | margin: .0em 0 0 -4%;
53 | line-height: 1.3;
54 | border-bottom: 2px solid silver;
55 | }
56 |
57 | body h2 {
58 | margin: 0.5em 0 0 -4%;
59 | line-height: 1.3;
60 | border-bottom: 2px solid silver;
61 | }
62 |
63 | body h3 {
64 | margin: .8em 0 0 -3%;
65 | line-height: 1.3;
66 | }
67 |
68 | body h4 {
69 | margin: .8em 0 0 -3%;
70 | line-height: 1.3;
71 | }
72 |
73 | body h5 {
74 | margin: .8em 0 0 -2%;
75 | line-height: 1.3;
76 | }
77 |
78 | body h6 {
79 | margin: .8em 0 0 -1%;
80 | line-height: 1.3;
81 | }
82 |
83 | body hr {
84 | border: none; /* Broken on IE6 */
85 | }
86 | div.footnotes hr {
87 | border: 1px solid silver;
88 | }
89 |
90 | div.navheader th, div.navheader td, div.navfooter td {
91 | font-family: Arial,Helvetica,sans-serif;
92 | font-size: 0.9em;
93 | font-weight: bold;
94 | color: #527bbd;
95 | }
96 | div.navheader img, div.navfooter img {
97 | border-style: none;
98 | }
99 | div.navheader a, div.navfooter a {
100 | font-weight: normal;
101 | }
102 | div.navfooter hr {
103 | border: 1px solid silver;
104 | }
105 |
106 | body td {
107 | line-height: 1.2
108 | }
109 |
110 | body th {
111 | line-height: 1.2;
112 | }
113 |
114 | ol {
115 | line-height: 1.2;
116 | }
117 |
118 | ul, body dir, body menu {
119 | line-height: 1.2;
120 | }
121 |
122 | html {
123 | margin: 0;
124 | padding: 0;
125 | }
126 |
127 | body h1, body h2, body h3, body h4, body h5, body h6 {
128 | margin-left: 0
129 | }
130 |
131 | body pre {
132 | margin: 0.5em 10% 0.5em 1em;
133 | line-height: 1.0;
134 | color: navy;
135 | }
136 |
137 | tt.literal, code.literal {
138 | color: navy;
139 | }
140 |
141 | .programlisting, .screen {
142 | border: 1px solid silver;
143 | background: #f4f4f4;
144 | margin: 0.5em 10% 0.5em 0;
145 | padding: 0.5em 1em;
146 | }
147 |
148 | div.sidebar {
149 | background: #ffffee;
150 | margin: 1.0em 10% 0.5em 0;
151 | padding: 0.5em 1em;
152 | border: 1px solid silver;
153 | }
154 | div.sidebar * { padding: 0; }
155 | div.sidebar div { margin: 0; }
156 | div.sidebar p.title {
157 | margin-top: 0.5em;
158 | margin-bottom: 0.2em;
159 | }
160 |
161 | div.bibliomixed {
162 | margin: 0.5em 5% 0.5em 1em;
163 | }
164 |
165 | div.glossary dt {
166 | font-weight: bold;
167 | }
168 | div.glossary dd p {
169 | margin-top: 0.2em;
170 | }
171 |
172 | dl {
173 | margin: .8em 0;
174 | line-height: 1.2;
175 | }
176 |
177 | dt {
178 | margin-top: 0.5em;
179 | }
180 |
181 | dt span.term {
182 | font-style: normal;
183 | color: navy;
184 | }
185 |
186 | div.variablelist dd p {
187 | margin-top: 0;
188 | }
189 |
190 | div.itemizedlist li, div.orderedlist li {
191 | margin-left: -0.8em;
192 | margin-top: 0.5em;
193 | }
194 |
195 | ul, ol {
196 | list-style-position: outside;
197 | }
198 |
199 | div.sidebar ul, div.sidebar ol {
200 | margin-left: 2.8em;
201 | }
202 |
203 | div.itemizedlist p.title,
204 | div.orderedlist p.title,
205 | div.variablelist p.title
206 | {
207 | margin-bottom: -0.8em;
208 | }
209 |
210 | div.revhistory table {
211 | border-collapse: collapse;
212 | border: none;
213 | }
214 | div.revhistory th {
215 | border: none;
216 | color: #527bbd;
217 | font-family: Arial,Helvetica,sans-serif;
218 | }
219 | div.revhistory td {
220 | border: 1px solid silver;
221 | }
222 |
223 | /* Keep TOC and index lines close together. */
224 | div.toc dl, div.toc dt,
225 | div.list-of-figures dl, div.list-of-figures dt,
226 | div.list-of-tables dl, div.list-of-tables dt,
227 | div.indexdiv dl, div.indexdiv dt
228 | {
229 | line-height: normal;
230 | margin-top: 0;
231 | margin-bottom: 0;
232 | }
233 |
234 | /*
235 | Table styling does not work because of overriding attributes in
236 | generated HTML.
237 | */
238 | div.table table,
239 | div.informaltable table
240 | {
241 | margin-left: 0;
242 | margin-right: 5%;
243 | margin-bottom: 0.8em;
244 | }
245 | div.informaltable table
246 | {
247 | margin-top: 0.4em
248 | }
249 | div.table thead,
250 | div.table tfoot,
251 | div.table tbody,
252 | div.informaltable thead,
253 | div.informaltable tfoot,
254 | div.informaltable tbody
255 | {
256 | /* No effect in IE6. */
257 | border-top: 3px solid #527bbd;
258 | border-bottom: 3px solid #527bbd;
259 | }
260 | div.table thead, div.table tfoot,
261 | div.informaltable thead, div.informaltable tfoot
262 | {
263 | font-weight: bold;
264 | }
265 |
266 | div.mediaobject img {
267 | margin-bottom: 0.8em;
268 | }
269 | div.figure p.title,
270 | div.table p.title
271 | {
272 | margin-top: 1em;
273 | margin-bottom: 0.4em;
274 | }
275 |
276 | div.calloutlist p
277 | {
278 | margin-top: 0em;
279 | margin-bottom: 0.4em;
280 | }
281 |
282 | a img {
283 | border-style: none;
284 | }
285 |
286 | @media print {
287 | div.navheader, div.navfooter { display: none; }
288 | }
289 |
290 | span.aqua { color: aqua; }
291 | span.black { color: black; }
292 | span.blue { color: blue; }
293 | span.fuchsia { color: fuchsia; }
294 | span.gray { color: gray; }
295 | span.green { color: green; }
296 | span.lime { color: lime; }
297 | span.maroon { color: maroon; }
298 | span.navy { color: navy; }
299 | span.olive { color: olive; }
300 | span.purple { color: purple; }
301 | span.red { color: red; }
302 | span.silver { color: silver; }
303 | span.teal { color: teal; }
304 | span.white { color: white; }
305 | span.yellow { color: yellow; }
306 |
307 | span.aqua-background { background: aqua; }
308 | span.black-background { background: black; }
309 | span.blue-background { background: blue; }
310 | span.fuchsia-background { background: fuchsia; }
311 | span.gray-background { background: gray; }
312 | span.green-background { background: green; }
313 | span.lime-background { background: lime; }
314 | span.maroon-background { background: maroon; }
315 | span.navy-background { background: navy; }
316 | span.olive-background { background: olive; }
317 | span.purple-background { background: purple; }
318 | span.red-background { background: red; }
319 | span.silver-background { background: silver; }
320 | span.teal-background { background: teal; }
321 | span.white-background { background: white; }
322 | span.yellow-background { background: yellow; }
323 |
324 | span.big { font-size: 2em; }
325 | span.small { font-size: 0.6em; }
326 |
327 | span.underline { text-decoration: underline; }
328 | span.overline { text-decoration: overline; }
329 | span.line-through { text-decoration: line-through; }
330 |
--------------------------------------------------------------------------------
/css/pygments.css:
--------------------------------------------------------------------------------
1 | .highlight .hll { background-color: #ffffcc }
2 | .highlight { background: #f8f8f8; }
3 | .highlight .c { color: #408080; font-style: italic } /* Comment */
4 | .highlight .err { border: 1px solid #FF0000 } /* Error */
5 | .highlight .k { color: #008000; font-weight: bold } /* Keyword */
6 | .highlight .o { color: #666666 } /* Operator */
7 | .highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
8 | .highlight .cp { color: #BC7A00 } /* Comment.Preproc */
9 | .highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
10 | .highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
11 | .highlight .gd { color: #A00000 } /* Generic.Deleted */
12 | .highlight .ge { font-style: italic } /* Generic.Emph */
13 | .highlight .gr { color: #FF0000 } /* Generic.Error */
14 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
15 | .highlight .gi { color: #00A000 } /* Generic.Inserted */
16 | .highlight .go { color: #808080 } /* Generic.Output */
17 | .highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
18 | .highlight .gs { font-weight: bold } /* Generic.Strong */
19 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
20 | .highlight .gt { color: #0040D0 } /* Generic.Traceback */
21 | .highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
22 | .highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
23 | .highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
24 | .highlight .kp { color: #008000 } /* Keyword.Pseudo */
25 | .highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
26 | .highlight .kt { color: #B00040 } /* Keyword.Type */
27 | .highlight .m { color: #666666 } /* Literal.Number */
28 | .highlight .s { color: #BA2121 } /* Literal.String */
29 | .highlight .na { color: #7D9029 } /* Name.Attribute */
30 | .highlight .nb { color: #008000 } /* Name.Builtin */
31 | .highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
32 | .highlight .no { color: #880000 } /* Name.Constant */
33 | .highlight .nd { color: #AA22FF } /* Name.Decorator */
34 | .highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
35 | .highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
36 | .highlight .nf { color: #0000FF } /* Name.Function */
37 | .highlight .nl { color: #A0A000 } /* Name.Label */
38 | .highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
39 | .highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
40 | .highlight .nv { color: #19177C } /* Name.Variable */
41 | .highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
42 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */
43 | .highlight .mf { color: #666666 } /* Literal.Number.Float */
44 | .highlight .mh { color: #666666 } /* Literal.Number.Hex */
45 | .highlight .mi { color: #666666 } /* Literal.Number.Integer */
46 | .highlight .mo { color: #666666 } /* Literal.Number.Oct */
47 | .highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
48 | .highlight .sc { color: #BA2121 } /* Literal.String.Char */
49 | .highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
50 | .highlight .s2 { color: #BA2121 } /* Literal.String.Double */
51 | .highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
52 | .highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
53 | .highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
54 | .highlight .sx { color: #008000 } /* Literal.String.Other */
55 | .highlight .sr { color: #BB6688 } /* Literal.String.Regex */
56 | .highlight .s1 { color: #BA2121 } /* Literal.String.Single */
57 | .highlight .ss { color: #19177C } /* Literal.String.Symbol */
58 | .highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
59 | .highlight .vc { color: #19177C } /* Name.Variable.Class */
60 | .highlight .vg { color: #19177C } /* Name.Variable.Global */
61 | .highlight .vi { color: #19177C } /* Name.Variable.Instance */
62 | .highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
63 |
--------------------------------------------------------------------------------
/css/slidy.css:
--------------------------------------------------------------------------------
1 | /* slidy.css
2 |
3 | Copyright (c) 2005-2010 W3C (MIT, ERCIM, Keio), All Rights Reserved.
4 | W3C liability, trademark, document use and software licensing
5 | rules apply, see:
6 |
7 | http://www.w3.org/Consortium/Legal/copyright-documents
8 | http://www.w3.org/Consortium/Legal/copyright-software
9 | */
10 |
11 | /*
12 | SJR: 2010-09-29: Modified for AsciiDoc slidy backend.
13 | Mostly just commented out stuff that is handled by AsciiDoc's CSS files.
14 | */
15 |
16 | body
17 | {
18 | margin: 0 0 0 0;
19 | padding: 0 0 0 0;
20 | width: 100%;
21 | height: 100%;
22 | color: black;
23 | background-color: white;
24 | /*
25 | font-family: "Gill Sans MT", "Gill Sans", GillSans, sans-serif;
26 | */
27 | font-size: 14pt;
28 | }
29 |
30 | div.toolbar {
31 | position: fixed; z-index: 200;
32 | top: auto; bottom: 0; left: 0; right: 0;
33 | height: 1.2em; text-align: right;
34 | padding-left: 1em;
35 | padding-right: 1em;
36 | font-size: 60%;
37 | color: red;
38 | background-color: rgb(240,240,240);
39 | border-top: solid 1px rgb(180,180,180);
40 | }
41 |
42 | div.toolbar span.copyright {
43 | color: black;
44 | margin-left: 0.5em;
45 | }
46 |
47 | div.initial_prompt {
48 | position: absolute;
49 | z-index: 1000;
50 | bottom: 1.2em;
51 | width: 90%;
52 | background-color: rgb(200,200,200);
53 | opacity: 0.35;
54 | background-color: rgb(200,200,200, 0.35);
55 | cursor: pointer;
56 | }
57 |
58 | div.initial_prompt p.help {
59 | text-align: center;
60 | }
61 |
62 | div.initial_prompt p.close {
63 | text-align: right;
64 | font-style: italic;
65 | }
66 |
67 | div.slidy_toc {
68 | position: absolute;
69 | z-index: 300;
70 | width: 60%;
71 | max-width: 30em;
72 | height: 30em;
73 | overflow: auto;
74 | top: auto;
75 | right: auto;
76 | left: 4em;
77 | bottom: 4em;
78 | padding: 1em;
79 | background: rgb(240,240,240);
80 | border-style: solid;
81 | border-width: 2px;
82 | font-size: 60%;
83 | }
84 |
85 | div.slidy_toc .toc_heading {
86 | text-align: center;
87 | width: 100%;
88 | margin: 0;
89 | margin-bottom: 1em;
90 | border-bottom-style: solid;
91 | border-bottom-color: rgb(180,180,180);
92 | border-bottom-width: 1px;
93 | }
94 |
95 | div.slide {
96 | z-index: 20;
97 | margin: 0 0 0 0;
98 | padding-top: 0;
99 | padding-bottom: 0;
100 | padding-left: 20px;
101 | padding-right: 20px;
102 | border-width: 0;
103 | clear: both;
104 | top: 0;
105 | bottom: 0;
106 | left: 0;
107 | right: 0;
108 | line-height: 120%;
109 | background-color: transparent;
110 | }
111 |
112 | div.background {
113 | display: none;
114 | }
115 |
116 | div.handout {
117 | margin-left: 20px;
118 | margin-right: 20px;
119 | }
120 |
121 | div.slide.titlepage {
122 | text-align: center;
123 | }
124 |
125 | div.slide.titlepage.h1 {
126 | padding-top: 10%;
127 | }
128 |
129 | div.slide h1 {
130 | padding-left: 0;
131 | padding-right: 20pt;
132 | padding-top: 4pt;
133 | padding-bottom: 4pt;
134 | margin-top: 0;
135 | margin-left: 0;
136 | margin-right: 60pt;
137 | margin-bottom: 0.5em;
138 | display: block;
139 | font-size: 160%;
140 | line-height: 1.2em;
141 | background: transparent;
142 | }
143 |
144 | div.toc {
145 | position: absolute;
146 | top: auto;
147 | bottom: 4em;
148 | left: 4em;
149 | right: auto;
150 | width: 60%;
151 | max-width: 30em;
152 | height: 30em;
153 | border: solid thin black;
154 | padding: 1em;
155 | background: rgb(240,240,240);
156 | color: black;
157 | z-index: 300;
158 | overflow: auto;
159 | display: block;
160 | visibility: visible;
161 | }
162 |
163 | div.toc-heading {
164 | width: 100%;
165 | border-bottom: solid 1px rgb(180,180,180);
166 | margin-bottom: 1em;
167 | text-align: center;
168 | }
169 |
170 | /*
171 | pre {
172 | font-size: 80%;
173 | font-weight: bold;
174 | line-height: 120%;
175 | padding-top: 0.2em;
176 | padding-bottom: 0.2em;
177 | padding-left: 1em;
178 | padding-right: 1em;
179 | border-style: solid;
180 | border-left-width: 1em;
181 | border-top-width: thin;
182 | border-right-width: thin;
183 | border-bottom-width: thin;
184 | border-color: #95ABD0;
185 | color: #00428C;
186 | background-color: #E4E5E7;
187 | }
188 | */
189 |
190 | /*
191 | li pre { margin-left: 0; }
192 |
193 | blockquote { font-style: italic }
194 |
195 | img { background-color: transparent }
196 |
197 | p.copyright { font-size: smaller }
198 | */
199 |
200 | .center { text-align: center }
201 | .footnote { font-size: smaller; margin-left: 2em; }
202 |
203 | /*
204 | a img { border-width: 0; border-style: none }
205 | */
206 |
207 | a:visited { color: navy }
208 | a:link { color: navy }
209 | a:hover { color: red; text-decoration: underline }
210 | a:active { color: red; text-decoration: underline }
211 |
212 | a {text-decoration: none}
213 | .navbar a:link {color: white}
214 | .navbar a:visited {color: yellow}
215 | .navbar a:active {color: red}
216 | .navbar a:hover {color: red}
217 |
218 | /*
219 | ul { list-style-type: square; }
220 | ul ul { list-style-type: disc; }
221 | ul ul ul { list-style-type: circle; }
222 | ul ul ul ul { list-style-type: disc; }
223 | li { margin-left: 0.5em; margin-top: 0.5em; }
224 | li li { font-size: 85%; font-style: italic }
225 | li li li { font-size: 85%; font-style: normal }
226 | */
227 |
228 | div dt
229 | {
230 | margin-left: 0;
231 | margin-top: 1em;
232 | margin-bottom: 0.5em;
233 | font-weight: bold;
234 | }
235 | div dd
236 | {
237 | margin-left: 2em;
238 | margin-bottom: 0.5em;
239 | }
240 |
241 |
242 | /*
243 | p,pre,ul,ol,blockquote,h2,h3,h4,h5,h6,dl,table {
244 | margin-left: 1em;
245 | margin-right: 1em;
246 | }
247 | */
248 |
249 | p.subhead { font-weight: bold; margin-top: 2em; }
250 |
251 | .smaller { font-size: smaller }
252 | .bigger { font-size: 130% }
253 |
254 | /*
255 | td,th { padding: 0.2em }
256 | */
257 |
258 | ul {
259 | margin: 0.5em 1.5em 0.5em 1.5em;
260 | padding: 0;
261 | }
262 |
263 | ol {
264 | margin: 0.5em 1.5em 0.5em 1.5em;
265 | padding: 0;
266 | }
267 |
268 | ul { list-style-type: square; }
269 | ul ul { list-style-type: disc; }
270 | ul ul ul { list-style-type: circle; }
271 | ul ul ul ul { list-style-type: disc; }
272 |
273 | /*
274 | ul li {
275 | list-style: square;
276 | margin: 0.1em 0em 0.6em 0;
277 | padding: 0 0 0 0;
278 | line-height: 140%;
279 | }
280 |
281 | ol li {
282 | margin: 0.1em 0em 0.6em 1.5em;
283 | padding: 0 0 0 0px;
284 | line-height: 140%;
285 | list-style-type: decimal;
286 | }
287 |
288 | li ul li {
289 | font-size: 85%;
290 | font-style: italic;
291 | list-style-type: disc;
292 | background: transparent;
293 | padding: 0 0 0 0;
294 | }
295 | li li ul li {
296 | font-size: 85%;
297 | font-style: normal;
298 | list-style-type: circle;
299 | background: transparent;
300 | padding: 0 0 0 0;
301 | }
302 | li li li ul li {
303 | list-style-type: disc;
304 | background: transparent;
305 | padding: 0 0 0 0;
306 | }
307 |
308 | li ol li {
309 | list-style-type: decimal;
310 | }
311 |
312 |
313 | li li ol li {
314 | list-style-type: decimal;
315 | }
316 | */
317 |
318 | /*
319 | setting class="outline" on ol or ul makes it behave as an
320 | ouline list where blocklevel content in li elements is
321 | hidden by default and can be expanded or collapsed with
322 | mouse click. Set class="expand" on li to override default
323 | */
324 |
325 | ol.outline li:hover { cursor: pointer }
326 | ol.outline li.nofold:hover { cursor: default }
327 |
328 | ul.outline li:hover { cursor: pointer }
329 | ul.outline li.nofold:hover { cursor: default }
330 |
331 | ol.outline { list-style:decimal; }
332 | ol.outline ol { list-style-type:lower-alpha }
333 |
334 | ol.outline li.nofold {
335 | padding: 0 0 0 20px;
336 | background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em;
337 | }
338 | ol.outline li.unfolded {
339 | padding: 0 0 0 20px;
340 | background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em;
341 | }
342 | ol.outline li.folded {
343 | padding: 0 0 0 20px;
344 | background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em;
345 | }
346 | ol.outline li.unfolded:hover {
347 | padding: 0 0 0 20px;
348 | background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em;
349 | }
350 | ol.outline li.folded:hover {
351 | padding: 0 0 0 20px;
352 | background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em;
353 | }
354 |
355 | ul.outline li.nofold {
356 | padding: 0 0 0 20px;
357 | background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em;
358 | }
359 | ul.outline li.unfolded {
360 | padding: 0 0 0 20px;
361 | background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em;
362 | }
363 | ul.outline li.folded {
364 | padding: 0 0 0 20px;
365 | background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em;
366 | }
367 | ul.outline li.unfolded:hover {
368 | padding: 0 0 0 20px;
369 | background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em;
370 | }
371 | ul.outline li.folded:hover {
372 | padding: 0 0 0 20px;
373 | background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em;
374 | }
375 |
376 | /* for slides with class "title" in table of contents */
377 | a.titleslide { font-weight: bold; font-style: italic }
378 |
379 | /*
380 | hide images for work around for save as bug
381 | where browsers fail to save images used by CSS
382 | */
383 | img.hidden { display: none; visibility: hidden }
384 | div.initial_prompt { display: none; visibility: hidden }
385 |
386 | div.slide {
387 | visibility: visible;
388 | position: inherit;
389 | }
390 | div.handout {
391 | border-top-style: solid;
392 | border-top-width: thin;
393 | border-top-color: black;
394 | }
395 |
396 | @media screen {
397 | .hidden { display: none; visibility: visible }
398 |
399 | div.slide.hidden { display: block; visibility: visible }
400 | div.handout.hidden { display: block; visibility: visible }
401 | div.background { display: none; visibility: hidden }
402 | body.single_slide div.initial_prompt { display: block; visibility: visible }
403 | body.single_slide div.background { display: block; visibility: visible }
404 | body.single_slide div.background.hidden { display: none; visibility: hidden }
405 | body.single_slide .invisible { visibility: hidden }
406 | body.single_slide .hidden { display: none; visibility: hidden }
407 | body.single_slide div.slide { position: absolute }
408 | body.single_slide div.handout { display: none; visibility: hidden }
409 | }
410 |
411 | @media print {
412 | .hidden { display: block; visibility: visible }
413 |
414 | /*
415 | div.slide pre { font-size: 60%; padding-left: 0.5em; }
416 | */
417 | div.toolbar { display: none; visibility: hidden; }
418 | div.slidy_toc { display: none; visibility: hidden; }
419 | div.background { display: none; visibility: hidden; }
420 | div.slide { page-break-before: always }
421 | /* :first-child isn't reliable for print media */
422 | div.slide.first-slide { page-break-before: avoid }
423 | }
424 |
425 |
426 | /* SJR: AsciiDoc slidy backend tweaks */
427 |
428 | ol, ul {
429 | margin: 0.8em 1.5em 0.8em 1.8em;
430 | }
431 | li > ul, li > ol {
432 | margin-top: 0.5em;
433 | }
434 |
435 | .outline > li.folded,
436 | .outline > li.unfolded {
437 | color: #527bbd;
438 | }
439 | ul > li{ color: #aaa; }
440 | ul > li > *, ol > li > * { color: black; }
441 |
442 | li {
443 | margin-top: 0.5em;
444 | margin-bottom: 0.5em;
445 | }
446 |
--------------------------------------------------------------------------------
/css/toc2.css:
--------------------------------------------------------------------------------
1 | @media screen {
2 | body {
3 | max-width: 50em; /* approximately 80 characters wide */
4 | margin-left: 16em;
5 | }
6 |
7 | #toc {
8 | position: fixed;
9 | top: 0;
10 | left: 0;
11 | bottom: 0;
12 | width: 13em;
13 | padding: 0.5em;
14 | padding-bottom: 1.5em;
15 | margin: 0;
16 | overflow: auto;
17 | border-right: 3px solid #f8f8f8;
18 | background-color: white;
19 | }
20 |
21 | #toc .toclevel1 {
22 | margin-top: 0.5em;
23 | }
24 |
25 | #toc .toclevel2 {
26 | margin-top: 0.25em;
27 | display: list-item;
28 | color: #aaaaaa;
29 | }
30 |
31 | #toctitle {
32 | margin-top: 0.5em;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/css/uber-custom.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/uber-hypermedia/specification/69a7c809a828e2a5c08ca16c75338400cb74f290/css/uber-custom.css
--------------------------------------------------------------------------------
/css/xhtml11-quirks.css:
--------------------------------------------------------------------------------
1 | /* Workarounds for IE6's broken and incomplete CSS2. */
2 |
3 | div.sidebar-content {
4 | background: #ffffee;
5 | border: 1px solid silver;
6 | padding: 0.5em;
7 | }
8 | div.sidebar-title, div.image-title {
9 | color: #527bbd;
10 | font-family: Arial,Helvetica,sans-serif;
11 | font-weight: bold;
12 | margin-top: 0.0em;
13 | margin-bottom: 0.5em;
14 | }
15 |
16 | div.listingblock div.content {
17 | border: 1px solid silver;
18 | background: #f4f4f4;
19 | padding: 0.5em;
20 | }
21 |
22 | div.quoteblock-attribution {
23 | padding-top: 0.5em;
24 | text-align: right;
25 | }
26 |
27 | pre.verseblock-content {
28 | font-family: inherit;
29 | }
30 | div.verseblock-attribution {
31 | padding-top: 0.75em;
32 | text-align: left;
33 | }
34 |
35 | div.exampleblock-content {
36 | border-left: 3px solid #dddddd;
37 | padding-left: 0.5em;
38 | }
39 |
40 | div.imageblock.latex div.image-title { margin-top: 0.5em; }
41 |
42 | /* IE6 sets dynamically generated links as visited. */
43 | div#toc a:visited { color: blue; }
44 |
--------------------------------------------------------------------------------
/includes/error-sample.js:
--------------------------------------------------------------------------------
1 | {
2 | "uber" :
3 | {
4 | "version" : "1.0",
5 | "error" :
6 | {
7 | "data" :
8 | [
9 | {
10 | "name" : "type",
11 | "rel" : ["https://example.com/rels/http-problem#type"],
12 | "value" : "out-of-credit"
13 | },
14 | {
15 | "name" : "title",
16 | "rel" : ["https://example.com/rels/http-problem#title"],
17 | "value" : "You do not have enough credit"
18 | },
19 | {
20 | "name" : "detail",
21 | "rel" : ["https://example.com/rels/http-problem#detail"],
22 | "value" : "Your balance is 30, but the cost is 50."
23 | },
24 | {
25 | "name" : "balance",
26 | "rel" : ["https://example.com/rels/http-problem#balance"],
27 | "value" : "30"
28 | }
29 | ]
30 | }
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/includes/error-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | out-of-credit
6 |
7 |
9 | You do not have enough credit
10 |
11 |
13 | Your current balance is 30, but the cost is 50
14 |
15 |
17 | 30
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/includes/full-example.js:
--------------------------------------------------------------------------------
1 | {
2 | "uber" :
3 | {
4 | "version" : "1.0",
5 | "data" :
6 | [
7 | {"rel" : ["self"], "url" : "http://example.org/"},
8 | {"rel" : ["profile"], "url" : "http://example.org/profiles/people-and-places"},
9 | {
10 | "id" : "people",
11 | "rel" : ["collection","http://example.org/rels/people"],
12 | "url" : "http://example.org/people/",
13 | "data" :
14 | [
15 | {
16 | "name" : "create",
17 | "rel" : ["http://example.org/rels/create"],
18 | "url" : "http://example.org/people/",
19 | "model" : "g={givenName}&f={familyName}&e={email}",
20 | "action" : "append"
21 | },
22 | {
23 | "name" : "search",
24 | "rel" : ["search","collection"],
25 | "url" : "http://example.org/people/search{?givenName,familyName,email}",
26 | "templated" : "true"
27 | },
28 | {
29 | "name" : "person",
30 | "rel" : ["item","http://example.org/rels/person"],
31 | "url" : "http://example.org/people/1",
32 | "data" :
33 | [
34 | {"name" : "givenName", "value" : "Mike", "label" : "First Name"},
35 | {"name" : "familyName", "value" : "Amundsen", "label" : "Last Name"},
36 | {"name" : "email", "value" : "mike@example.org", "label" : "E-mail"},
37 | {"name" : "avatarUrl", "transclude" : "true",
38 | "url" : "http://example.org/avatars/1",
39 | "value" : "User Photo",
40 | "accepting" : ["image/*"]
41 | }
42 | ]
43 | },
44 | {
45 | "name" : "person",
46 | "rel" : ["item","http://example.org/rels/person"],
47 | "url" : "http://example.org/people/2",
48 | "data" :
49 | [
50 | {"name" : "givenName", "value" : "Mildred", "label" : "First Name"},
51 | {"name" : "familyName", "value" : "Amundsen", "label" : "Last Name"},
52 | {"name" : "email", "value" : "mildred@example.org", "label" : "E-mail"},
53 | {"name" : "avatarUrl", "transclude" : "true",
54 | "url" : "http://example.org/avatars/2",
55 | "value" : "User Photo",
56 | "accepting" : ["image/*"]
57 | }
58 | ]
59 | }
60 | ]
61 | },
62 |
63 | {
64 | "id" : "places",
65 | "rel" : ["collection","http://example.org/rels/places"],
66 | "url" : "http://example.org/places/",
67 | "data" :
68 | [
69 | {
70 | "name" : "search",
71 | "rel" : ["search","collection"],
72 | "url" : "http://example.org/places/search{?addressRegion,addressLocality,postalCode}",
73 | "templated" : "true"
74 | },
75 | {
76 | "name" : "place",
77 | "rel" : ["item","http://example.org/rels/place"],
78 | "url" : "http://example.org/places/a",
79 | "data" :
80 | [
81 | {
82 | "name" : "name",
83 | "value" : "Home"
84 | },
85 | {
86 | "name" : "address",
87 | "data" :
88 | [
89 | {"name" : "streetAddress", "value" : "123 Main Street", "label" : "Street Address"},
90 | {"name" : "addressLocality", "value" : "Byteville", "label" : "City"},
91 | {"name" : "addressRegion", "value" : "MD", "label" : "State"},
92 | {"name" : "postalCode", "value" : "12345", "label" : "ZIP"}
93 | ]
94 | }
95 | ]
96 | },
97 | {
98 | "name" : "place",
99 | "rel" : ["item","http://example.org/rels/place"],
100 | "url" : "http://example.org/places/b",
101 | "data" :
102 | [
103 | {
104 | "name" : "name",
105 | "value" : "Work"
106 | },
107 | {
108 | "name" : "address",
109 | "data" :
110 | [
111 | {"name" : "streetAddress", "value" : "1456 Grand Ave.", "label" : "Street Address"},
112 | {"name" : "addressLocality", "value" : "Byteville", "label" : "City"},
113 | {"name" : "addressRegion", "value" : "MD", "label" : "State"},
114 | {"name" : "postalCode", "value" : "12345", "label" : "ZIP"}
115 | ]
116 | }
117 | ]
118 | }
119 | ]
120 | }
121 | ]
122 | }
123 | }
124 |
125 |
--------------------------------------------------------------------------------
/includes/full-example.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 |
15 |
16 |
17 | Mildred
18 | Amundsen
19 | mildred@example.org
20 | User Photo
22 |
23 |
24 | Mildred
25 | Amundsen
26 | mildred@example.org
27 | User Photo
29 |
30 |
31 |
32 |
33 |
37 |
38 |
39 | Home
40 |
41 | 123 Main
42 | Byteville
43 | MD
44 | 12345
45 |
46 |
47 |
48 | Work
49 |
50 | 456 Grand Ave.
51 | Byteville
52 | MD
53 | 12345
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/includes/message-model.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/includes/search-sample.js:
--------------------------------------------------------------------------------
1 | {
2 | "uber" :
3 | {
4 | "version" : "1.0",
5 | "data" :
6 | [
7 | {
8 | "rel" : ["self"],
9 | "url" : "http://example.org/"
10 | },
11 | {
12 | "name" : "list",
13 | "label" : "ToDo List",
14 | "rel" : ["collection"],
15 | "url" : "http://example.org/list/"
16 | },
17 | {
18 | "name" : "search",
19 | "label" : "Search",
20 | "rel" : ["search","collection"],
21 | "url" : "http://example.org/search{?title}",
22 | "templated" : "true"
23 | },
24 | {
25 | "name" : "todo",
26 | "rel" : ["item","http://example.org/rels/todo"],
27 | "url" : "http://example.org/list/1",
28 | "data" :
29 | [
30 | {"name" : "title", "label" : "Title", "value" : "Clean house"},
31 | {"name" : "dueDate", "label" : "Date Due", "value" : "2014-05-01"}
32 | ]
33 | },
34 | {
35 | "name" : "todo",
36 | "rel" : ["item","http://example.org/rels/todo"],
37 | "url" : "http://example.org/list/2",
38 | "data" :
39 | [
40 | {"name" : "title", "label" : "Title", "value" : "Paint the fence"},
41 | {"name" : "dueDate", "label" : "Date Due", "value" : "2014-06-01"}
42 | ]
43 | }
44 | ]
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/includes/search-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Clean House
7 | 2014-05-01
8 |
9 |
10 | Paint the fence
11 | 2014-06-01
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/includes/uber-query-string.txt:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | Assume the values supplied are:
10 | givenName = Mike
11 | familyName = Amundsen
12 | email = mike@example.org
13 |
14 | *** HTTP Request ***
15 | GET /search/?givenName=Mike&familyName=Amundsen&email=mike%40example.org HTTP/1.1
16 | Host: example.org
17 | Accept-Type: application/vnd.uber+xml
18 |
19 |
--------------------------------------------------------------------------------
/includes/uber-request-body.txt:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 | Assume the values supplied are:
9 | givenName = Mike
10 | familyName = Amundsen
11 | email = mike@example.org
12 | avatarUrl = http://example.org/avatars/mike.png
13 |
14 | *** HTTP Request ***
15 | POST /people/ HTTP/1.1
16 | Host: example.org
17 | Accept-Type: application/vnd.uber+xml
18 | Content-Type: application/x-www-form-urlencoded
19 | Content-Length: xxx
20 |
21 | g=Mike&f=Amundsen&e=mike%40example.org&a=http%3A%2F%2Fexample.org%2Favatars%2Fmike.png
22 |
23 |
--------------------------------------------------------------------------------
/js/ASCIIMathML.js:
--------------------------------------------------------------------------------
1 | /*
2 | ASCIIMathML.js
3 | ==============
4 | This file contains JavaScript functions to convert ASCII math notation
5 | to Presentation MathML. The conversion is done while the (X)HTML page
6 | loads, and should work with Firefox/Mozilla/Netscape 7+ and Internet
7 | Explorer 6+MathPlayer (http://www.dessci.com/en/products/mathplayer/).
8 | Just add the next line to your (X)HTML page with this file in the same folder:
9 | This is a convenient and inexpensive solution for authoring MathML.
10 |
11 | Version 1.4.7 Dec 15, 2005, (c) Peter Jipsen http://www.chapman.edu/~jipsen
12 | Latest version at http://www.chapman.edu/~jipsen/mathml/ASCIIMathML.js
13 | For changes see http://www.chapman.edu/~jipsen/mathml/asciimathchanges.txt
14 | If you use it on a webpage, please send the URL to jipsen@chapman.edu
15 |
16 | This program is free software; you can redistribute it and/or modify
17 | it under the terms of the GNU General Public License as published by
18 | the Free Software Foundation; either version 2 of the License, or (at
19 | your option) any later version.
20 |
21 | This program is distributed in the hope that it will be useful,
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 | General Public License (at http://www.gnu.org/copyleft/gpl.html)
25 | for more details.
26 | */
27 |
28 | var checkForMathML = true; // check if browser can display MathML
29 | var notifyIfNoMathML = true; // display note if no MathML capability
30 | var alertIfNoMathML = false; // show alert box if no MathML capability
31 | var mathcolor = ""; // change it to "" (to inherit) or any other color
32 | var mathfontfamily = "serif"; // change to "" to inherit (works in IE)
33 | // or another family (e.g. "arial")
34 | var displaystyle = true; // puts limits above and below large operators
35 | var showasciiformulaonhover = true; // helps students learn ASCIIMath
36 | var decimalsign = "."; // change to "," if you like, beware of `(1,2)`!
37 | var AMdelimiter1 = "`", AMescape1 = "\\\\`"; // can use other characters
38 | var AMdelimiter2 = "$", AMescape2 = "\\\\\\$", AMdelimiter2regexp = "\\$";
39 | var doubleblankmathdelimiter = false; // if true, x+1 is equal to `x+1`
40 | // for IE this works only in
41 | //var separatetokens;// has been removed (email me if this is a problem)
42 | var isIE = document.createElementNS==null;
43 |
44 | if (document.getElementById==null)
45 | alert("This webpage requires a recent browser such as\
46 | \nMozilla/Netscape 7+ or Internet Explorer 6+MathPlayer")
47 |
48 | // all further global variables start with "AM"
49 |
50 | function AMcreateElementXHTML(t) {
51 | if (isIE) return document.createElement(t);
52 | else return document.createElementNS("http://www.w3.org/1999/xhtml",t);
53 | }
54 |
55 | function AMnoMathMLNote() {
56 | var nd = AMcreateElementXHTML("h3");
57 | nd.setAttribute("align","center")
58 | nd.appendChild(AMcreateElementXHTML("p"));
59 | nd.appendChild(document.createTextNode("To view the "));
60 | var an = AMcreateElementXHTML("a");
61 | an.appendChild(document.createTextNode("ASCIIMathML"));
62 | an.setAttribute("href","http://www.chapman.edu/~jipsen/asciimath.html");
63 | nd.appendChild(an);
64 | nd.appendChild(document.createTextNode(" notation use Internet Explorer 6+"));
65 | an = AMcreateElementXHTML("a");
66 | an.appendChild(document.createTextNode("MathPlayer"));
67 | an.setAttribute("href","http://www.dessci.com/en/products/mathplayer/download.htm");
68 | nd.appendChild(an);
69 | nd.appendChild(document.createTextNode(" or Netscape/Mozilla/Firefox"));
70 | nd.appendChild(AMcreateElementXHTML("p"));
71 | return nd;
72 | }
73 |
74 | function AMisMathMLavailable() {
75 | if (navigator.appName.slice(0,8)=="Netscape")
76 | if (navigator.appVersion.slice(0,1)>="5") return null;
77 | else return AMnoMathMLNote();
78 | else if (navigator.appName.slice(0,9)=="Microsoft")
79 | try {
80 | var ActiveX = new ActiveXObject("MathPlayer.Factory.1");
81 | return null;
82 | } catch (e) {
83 | return AMnoMathMLNote();
84 | }
85 | else return AMnoMathMLNote();
86 | }
87 |
88 | // character lists for Mozilla/Netscape fonts
89 | 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];
90 | 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];
91 | 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];
92 |
93 | var CONST = 0, UNARY = 1, BINARY = 2, INFIX = 3, LEFTBRACKET = 4,
94 | RIGHTBRACKET = 5, SPACE = 6, UNDEROVER = 7, DEFINITION = 8,
95 | LEFTRIGHT = 9, TEXT = 10; // token types
96 |
97 | var AMsqrt = {input:"sqrt", tag:"msqrt", output:"sqrt", tex:null, ttype:UNARY},
98 | AMroot = {input:"root", tag:"mroot", output:"root", tex:null, ttype:BINARY},
99 | AMfrac = {input:"frac", tag:"mfrac", output:"/", tex:null, ttype:BINARY},
100 | AMdiv = {input:"/", tag:"mfrac", output:"/", tex:null, ttype:INFIX},
101 | AMover = {input:"stackrel", tag:"mover", output:"stackrel", tex:null, ttype:BINARY},
102 | AMsub = {input:"_", tag:"msub", output:"_", tex:null, ttype:INFIX},
103 | AMsup = {input:"^", tag:"msup", output:"^", tex:null, ttype:INFIX},
104 | AMtext = {input:"text", tag:"mtext", output:"text", tex:null, ttype:TEXT},
105 | AMmbox = {input:"mbox", tag:"mtext", output:"mbox", tex:null, ttype:TEXT},
106 | AMquote = {input:"\"", tag:"mtext", output:"mbox", tex:null, ttype:TEXT};
107 |
108 | var AMsymbols = [
109 | //some greek symbols
110 | {input:"alpha", tag:"mi", output:"\u03B1", tex:null, ttype:CONST},
111 | {input:"beta", tag:"mi", output:"\u03B2", tex:null, ttype:CONST},
112 | {input:"chi", tag:"mi", output:"\u03C7", tex:null, ttype:CONST},
113 | {input:"delta", tag:"mi", output:"\u03B4", tex:null, ttype:CONST},
114 | {input:"Delta", tag:"mo", output:"\u0394", tex:null, ttype:CONST},
115 | {input:"epsi", tag:"mi", output:"\u03B5", tex:"epsilon", ttype:CONST},
116 | {input:"varepsilon", tag:"mi", output:"\u025B", tex:null, ttype:CONST},
117 | {input:"eta", tag:"mi", output:"\u03B7", tex:null, ttype:CONST},
118 | {input:"gamma", tag:"mi", output:"\u03B3", tex:null, ttype:CONST},
119 | {input:"Gamma", tag:"mo", output:"\u0393", tex:null, ttype:CONST},
120 | {input:"iota", tag:"mi", output:"\u03B9", tex:null, ttype:CONST},
121 | {input:"kappa", tag:"mi", output:"\u03BA", tex:null, ttype:CONST},
122 | {input:"lambda", tag:"mi", output:"\u03BB", tex:null, ttype:CONST},
123 | {input:"Lambda", tag:"mo", output:"\u039B", tex:null, ttype:CONST},
124 | {input:"mu", tag:"mi", output:"\u03BC", tex:null, ttype:CONST},
125 | {input:"nu", tag:"mi", output:"\u03BD", tex:null, ttype:CONST},
126 | {input:"omega", tag:"mi", output:"\u03C9", tex:null, ttype:CONST},
127 | {input:"Omega", tag:"mo", output:"\u03A9", tex:null, ttype:CONST},
128 | {input:"phi", tag:"mi", output:"\u03C6", tex:null, ttype:CONST},
129 | {input:"varphi", tag:"mi", output:"\u03D5", tex:null, ttype:CONST},
130 | {input:"Phi", tag:"mo", output:"\u03A6", tex:null, ttype:CONST},
131 | {input:"pi", tag:"mi", output:"\u03C0", tex:null, ttype:CONST},
132 | {input:"Pi", tag:"mo", output:"\u03A0", tex:null, ttype:CONST},
133 | {input:"psi", tag:"mi", output:"\u03C8", tex:null, ttype:CONST},
134 | {input:"Psi", tag:"mi", output:"\u03A8", tex:null, ttype:CONST},
135 | {input:"rho", tag:"mi", output:"\u03C1", tex:null, ttype:CONST},
136 | {input:"sigma", tag:"mi", output:"\u03C3", tex:null, ttype:CONST},
137 | {input:"Sigma", tag:"mo", output:"\u03A3", tex:null, ttype:CONST},
138 | {input:"tau", tag:"mi", output:"\u03C4", tex:null, ttype:CONST},
139 | {input:"theta", tag:"mi", output:"\u03B8", tex:null, ttype:CONST},
140 | {input:"vartheta", tag:"mi", output:"\u03D1", tex:null, ttype:CONST},
141 | {input:"Theta", tag:"mo", output:"\u0398", tex:null, ttype:CONST},
142 | {input:"upsilon", tag:"mi", output:"\u03C5", tex:null, ttype:CONST},
143 | {input:"xi", tag:"mi", output:"\u03BE", tex:null, ttype:CONST},
144 | {input:"Xi", tag:"mo", output:"\u039E", tex:null, ttype:CONST},
145 | {input:"zeta", tag:"mi", output:"\u03B6", tex:null, ttype:CONST},
146 |
147 | //binary operation symbols
148 | {input:"*", tag:"mo", output:"\u22C5", tex:"cdot", ttype:CONST},
149 | {input:"**", tag:"mo", output:"\u22C6", tex:"star", ttype:CONST},
150 | {input:"//", tag:"mo", output:"/", tex:null, ttype:CONST},
151 | {input:"\\\\", tag:"mo", output:"\\", tex:"backslash", ttype:CONST},
152 | {input:"setminus", tag:"mo", output:"\\", tex:null, ttype:CONST},
153 | {input:"xx", tag:"mo", output:"\u00D7", tex:"times", ttype:CONST},
154 | {input:"-:", tag:"mo", output:"\u00F7", tex:"divide", ttype:CONST},
155 | {input:"@", tag:"mo", output:"\u2218", tex:"circ", ttype:CONST},
156 | {input:"o+", tag:"mo", output:"\u2295", tex:"oplus", ttype:CONST},
157 | {input:"ox", tag:"mo", output:"\u2297", tex:"otimes", ttype:CONST},
158 | {input:"o.", tag:"mo", output:"\u2299", tex:"odot", ttype:CONST},
159 | {input:"sum", tag:"mo", output:"\u2211", tex:null, ttype:UNDEROVER},
160 | {input:"prod", tag:"mo", output:"\u220F", tex:null, ttype:UNDEROVER},
161 | {input:"^^", tag:"mo", output:"\u2227", tex:"wedge", ttype:CONST},
162 | {input:"^^^", tag:"mo", output:"\u22C0", tex:"bigwedge", ttype:UNDEROVER},
163 | {input:"vv", tag:"mo", output:"\u2228", tex:"vee", ttype:CONST},
164 | {input:"vvv", tag:"mo", output:"\u22C1", tex:"bigvee", ttype:UNDEROVER},
165 | {input:"nn", tag:"mo", output:"\u2229", tex:"cap", ttype:CONST},
166 | {input:"nnn", tag:"mo", output:"\u22C2", tex:"bigcap", ttype:UNDEROVER},
167 | {input:"uu", tag:"mo", output:"\u222A", tex:"cup", ttype:CONST},
168 | {input:"uuu", tag:"mo", output:"\u22C3", tex:"bigcup", ttype:UNDEROVER},
169 |
170 | //binary relation symbols
171 | {input:"!=", tag:"mo", output:"\u2260", tex:"ne", ttype:CONST},
172 | {input:":=", tag:"mo", output:":=", tex:null, ttype:CONST},
173 | {input:"lt", tag:"mo", output:"<", tex:null, ttype:CONST},
174 | {input:"<=", tag:"mo", output:"\u2264", tex:"le", ttype:CONST},
175 | {input:"lt=", tag:"mo", output:"\u2264", tex:"leq", ttype:CONST},
176 | {input:">=", tag:"mo", output:"\u2265", tex:"ge", ttype:CONST},
177 | {input:"geq", tag:"mo", output:"\u2265", tex:null, ttype:CONST},
178 | {input:"-<", tag:"mo", output:"\u227A", tex:"prec", ttype:CONST},
179 | {input:"-lt", tag:"mo", output:"\u227A", tex:null, ttype:CONST},
180 | {input:">-", tag:"mo", output:"\u227B", tex:"succ", ttype:CONST},
181 | {input:"-<=", tag:"mo", output:"\u2AAF", tex:"preceq", ttype:CONST},
182 | {input:">-=", tag:"mo", output:"\u2AB0", tex:"succeq", ttype:CONST},
183 | {input:"in", tag:"mo", output:"\u2208", tex:null, ttype:CONST},
184 | {input:"!in", tag:"mo", output:"\u2209", tex:"notin", ttype:CONST},
185 | {input:"sub", tag:"mo", output:"\u2282", tex:"subset", ttype:CONST},
186 | {input:"sup", tag:"mo", output:"\u2283", tex:"supset", ttype:CONST},
187 | {input:"sube", tag:"mo", output:"\u2286", tex:"subseteq", ttype:CONST},
188 | {input:"supe", tag:"mo", output:"\u2287", tex:"supseteq", ttype:CONST},
189 | {input:"-=", tag:"mo", output:"\u2261", tex:"equiv", ttype:CONST},
190 | {input:"~=", tag:"mo", output:"\u2245", tex:"cong", ttype:CONST},
191 | {input:"~~", tag:"mo", output:"\u2248", tex:"approx", ttype:CONST},
192 | {input:"prop", tag:"mo", output:"\u221D", tex:"propto", ttype:CONST},
193 |
194 | //logical symbols
195 | {input:"and", tag:"mtext", output:"and", tex:null, ttype:SPACE},
196 | {input:"or", tag:"mtext", output:"or", tex:null, ttype:SPACE},
197 | {input:"not", tag:"mo", output:"\u00AC", tex:"neg", ttype:CONST},
198 | {input:"=>", tag:"mo", output:"\u21D2", tex:"implies", ttype:CONST},
199 | {input:"if", tag:"mo", output:"if", tex:null, ttype:SPACE},
200 | {input:"<=>", tag:"mo", output:"\u21D4", tex:"iff", ttype:CONST},
201 | {input:"AA", tag:"mo", output:"\u2200", tex:"forall", ttype:CONST},
202 | {input:"EE", tag:"mo", output:"\u2203", tex:"exists", ttype:CONST},
203 | {input:"_|_", tag:"mo", output:"\u22A5", tex:"bot", ttype:CONST},
204 | {input:"TT", tag:"mo", output:"\u22A4", tex:"top", ttype:CONST},
205 | {input:"|--", tag:"mo", output:"\u22A2", tex:"vdash", ttype:CONST},
206 | {input:"|==", tag:"mo", output:"\u22A8", tex:"models", ttype:CONST},
207 |
208 | //grouping brackets
209 | {input:"(", tag:"mo", output:"(", tex:null, ttype:LEFTBRACKET},
210 | {input:")", tag:"mo", output:")", tex:null, ttype:RIGHTBRACKET},
211 | {input:"[", tag:"mo", output:"[", tex:null, ttype:LEFTBRACKET},
212 | {input:"]", tag:"mo", output:"]", tex:null, ttype:RIGHTBRACKET},
213 | {input:"{", tag:"mo", output:"{", tex:null, ttype:LEFTBRACKET},
214 | {input:"}", tag:"mo", output:"}", tex:null, ttype:RIGHTBRACKET},
215 | {input:"|", tag:"mo", output:"|", tex:null, ttype:LEFTRIGHT},
216 | //{input:"||", tag:"mo", output:"||", tex:null, ttype:LEFTRIGHT},
217 | {input:"(:", tag:"mo", output:"\u2329", tex:"langle", ttype:LEFTBRACKET},
218 | {input:":)", tag:"mo", output:"\u232A", tex:"rangle", ttype:RIGHTBRACKET},
219 | {input:"<<", tag:"mo", output:"\u2329", tex:null, ttype:LEFTBRACKET},
220 | {input:">>", tag:"mo", output:"\u232A", tex:null, ttype:RIGHTBRACKET},
221 | {input:"{:", tag:"mo", output:"{:", tex:null, ttype:LEFTBRACKET, invisible:true},
222 | {input:":}", tag:"mo", output:":}", tex:null, ttype:RIGHTBRACKET, invisible:true},
223 |
224 | //miscellaneous symbols
225 | {input:"int", tag:"mo", output:"\u222B", tex:null, ttype:CONST},
226 | {input:"dx", tag:"mi", output:"{:d x:}", tex:null, ttype:DEFINITION},
227 | {input:"dy", tag:"mi", output:"{:d y:}", tex:null, ttype:DEFINITION},
228 | {input:"dz", tag:"mi", output:"{:d z:}", tex:null, ttype:DEFINITION},
229 | {input:"dt", tag:"mi", output:"{:d t:}", tex:null, ttype:DEFINITION},
230 | {input:"oint", tag:"mo", output:"\u222E", tex:null, ttype:CONST},
231 | {input:"del", tag:"mo", output:"\u2202", tex:"partial", ttype:CONST},
232 | {input:"grad", tag:"mo", output:"\u2207", tex:"nabla", ttype:CONST},
233 | {input:"+-", tag:"mo", output:"\u00B1", tex:"pm", ttype:CONST},
234 | {input:"O/", tag:"mo", output:"\u2205", tex:"emptyset", ttype:CONST},
235 | {input:"oo", tag:"mo", output:"\u221E", tex:"infty", ttype:CONST},
236 | {input:"aleph", tag:"mo", output:"\u2135", tex:null, ttype:CONST},
237 | {input:"...", tag:"mo", output:"...", tex:"ldots", ttype:CONST},
238 | {input:":.", tag:"mo", output:"\u2234", tex:"therefore", ttype:CONST},
239 | {input:"/_", tag:"mo", output:"\u2220", tex:"angle", ttype:CONST},
240 | {input:"\\ ", tag:"mo", output:"\u00A0", tex:null, ttype:CONST},
241 | {input:"quad", tag:"mo", output:"\u00A0\u00A0", tex:null, ttype:CONST},
242 | {input:"qquad", tag:"mo", output:"\u00A0\u00A0\u00A0\u00A0", tex:null, ttype:CONST},
243 | {input:"cdots", tag:"mo", output:"\u22EF", tex:null, ttype:CONST},
244 | {input:"vdots", tag:"mo", output:"\u22EE", tex:null, ttype:CONST},
245 | {input:"ddots", tag:"mo", output:"\u22F1", tex:null, ttype:CONST},
246 | {input:"diamond", tag:"mo", output:"\u22C4", tex:null, ttype:CONST},
247 | {input:"square", tag:"mo", output:"\u25A1", tex:null, ttype:CONST},
248 | {input:"|__", tag:"mo", output:"\u230A", tex:"lfloor", ttype:CONST},
249 | {input:"__|", tag:"mo", output:"\u230B", tex:"rfloor", ttype:CONST},
250 | {input:"|~", tag:"mo", output:"\u2308", tex:"lceiling", ttype:CONST},
251 | {input:"~|", tag:"mo", output:"\u2309", tex:"rceiling", ttype:CONST},
252 | {input:"CC", tag:"mo", output:"\u2102", tex:null, ttype:CONST},
253 | {input:"NN", tag:"mo", output:"\u2115", tex:null, ttype:CONST},
254 | {input:"QQ", tag:"mo", output:"\u211A", tex:null, ttype:CONST},
255 | {input:"RR", tag:"mo", output:"\u211D", tex:null, ttype:CONST},
256 | {input:"ZZ", tag:"mo", output:"\u2124", tex:null, ttype:CONST},
257 | {input:"f", tag:"mi", output:"f", tex:null, ttype:UNARY, func:true},
258 | {input:"g", tag:"mi", output:"g", tex:null, ttype:UNARY, func:true},
259 |
260 | //standard functions
261 | {input:"lim", tag:"mo", output:"lim", tex:null, ttype:UNDEROVER},
262 | {input:"Lim", tag:"mo", output:"Lim", tex:null, ttype:UNDEROVER},
263 | {input:"sin", tag:"mo", output:"sin", tex:null, ttype:UNARY, func:true},
264 | {input:"cos", tag:"mo", output:"cos", tex:null, ttype:UNARY, func:true},
265 | {input:"tan", tag:"mo", output:"tan", tex:null, ttype:UNARY, func:true},
266 | {input:"sinh", tag:"mo", output:"sinh", tex:null, ttype:UNARY, func:true},
267 | {input:"cosh", tag:"mo", output:"cosh", tex:null, ttype:UNARY, func:true},
268 | {input:"tanh", tag:"mo", output:"tanh", tex:null, ttype:UNARY, func:true},
269 | {input:"cot", tag:"mo", output:"cot", tex:null, ttype:UNARY, func:true},
270 | {input:"sec", tag:"mo", output:"sec", tex:null, ttype:UNARY, func:true},
271 | {input:"csc", tag:"mo", output:"csc", tex:null, ttype:UNARY, func:true},
272 | {input:"log", tag:"mo", output:"log", tex:null, ttype:UNARY, func:true},
273 | {input:"ln", tag:"mo", output:"ln", tex:null, ttype:UNARY, func:true},
274 | {input:"det", tag:"mo", output:"det", tex:null, ttype:UNARY, func:true},
275 | {input:"dim", tag:"mo", output:"dim", tex:null, ttype:CONST},
276 | {input:"mod", tag:"mo", output:"mod", tex:null, ttype:CONST},
277 | {input:"gcd", tag:"mo", output:"gcd", tex:null, ttype:UNARY, func:true},
278 | {input:"lcm", tag:"mo", output:"lcm", tex:null, ttype:UNARY, func:true},
279 | {input:"lub", tag:"mo", output:"lub", tex:null, ttype:CONST},
280 | {input:"glb", tag:"mo", output:"glb", tex:null, ttype:CONST},
281 | {input:"min", tag:"mo", output:"min", tex:null, ttype:UNDEROVER},
282 | {input:"max", tag:"mo", output:"max", tex:null, ttype:UNDEROVER},
283 |
284 | //arrows
285 | {input:"uarr", tag:"mo", output:"\u2191", tex:"uparrow", ttype:CONST},
286 | {input:"darr", tag:"mo", output:"\u2193", tex:"downarrow", ttype:CONST},
287 | {input:"rarr", tag:"mo", output:"\u2192", tex:"rightarrow", ttype:CONST},
288 | {input:"->", tag:"mo", output:"\u2192", tex:"to", ttype:CONST},
289 | {input:"|->", tag:"mo", output:"\u21A6", tex:"mapsto", ttype:CONST},
290 | {input:"larr", tag:"mo", output:"\u2190", tex:"leftarrow", ttype:CONST},
291 | {input:"harr", tag:"mo", output:"\u2194", tex:"leftrightarrow", ttype:CONST},
292 | {input:"rArr", tag:"mo", output:"\u21D2", tex:"Rightarrow", ttype:CONST},
293 | {input:"lArr", tag:"mo", output:"\u21D0", tex:"Leftarrow", ttype:CONST},
294 | {input:"hArr", tag:"mo", output:"\u21D4", tex:"Leftrightarrow", ttype:CONST},
295 |
296 | //commands with argument
297 | AMsqrt, AMroot, AMfrac, AMdiv, AMover, AMsub, AMsup,
298 | {input:"hat", tag:"mover", output:"\u005E", tex:null, ttype:UNARY, acc:true},
299 | {input:"bar", tag:"mover", output:"\u00AF", tex:"overline", ttype:UNARY, acc:true},
300 | {input:"vec", tag:"mover", output:"\u2192", tex:null, ttype:UNARY, acc:true},
301 | {input:"dot", tag:"mover", output:".", tex:null, ttype:UNARY, acc:true},
302 | {input:"ddot", tag:"mover", output:"..", tex:null, ttype:UNARY, acc:true},
303 | {input:"ul", tag:"munder", output:"\u0332", tex:"underline", ttype:UNARY, acc:true},
304 | AMtext, AMmbox, AMquote,
305 | {input:"bb", tag:"mstyle", atname:"fontweight", atval:"bold", output:"bb", tex:null, ttype:UNARY},
306 | {input:"mathbf", tag:"mstyle", atname:"fontweight", atval:"bold", output:"mathbf", tex:null, ttype:UNARY},
307 | {input:"sf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"sf", tex:null, ttype:UNARY},
308 | {input:"mathsf", tag:"mstyle", atname:"fontfamily", atval:"sans-serif", output:"mathsf", tex:null, ttype:UNARY},
309 | {input:"bbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"bbb", tex:null, ttype:UNARY, codes:AMbbb},
310 | {input:"mathbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", output:"mathbb", tex:null, ttype:UNARY, codes:AMbbb},
311 | {input:"cc", tag:"mstyle", atname:"mathvariant", atval:"script", output:"cc", tex:null, ttype:UNARY, codes:AMcal},
312 | {input:"mathcal", tag:"mstyle", atname:"mathvariant", atval:"script", output:"mathcal", tex:null, ttype:UNARY, codes:AMcal},
313 | {input:"tt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"tt", tex:null, ttype:UNARY},
314 | {input:"mathtt", tag:"mstyle", atname:"fontfamily", atval:"monospace", output:"mathtt", tex:null, ttype:UNARY},
315 | {input:"fr", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"fr", tex:null, ttype:UNARY, codes:AMfrk},
316 | {input:"mathfrak", tag:"mstyle", atname:"mathvariant", atval:"fraktur", output:"mathfrak", tex:null, ttype:UNARY, codes:AMfrk}
317 | ];
318 |
319 | function compareNames(s1,s2) {
320 | if (s1.input > s2.input) return 1
321 | else return -1;
322 | }
323 |
324 | var AMnames = []; //list of input symbols
325 |
326 | function AMinitSymbols() {
327 | var texsymbols = [], i;
328 | for (i=0; i=n where str appears or would be inserted
369 | // assumes arr is sorted
370 | if (n==0) {
371 | var h,m;
372 | n = -1;
373 | h = arr.length;
374 | while (n+1> 1;
376 | if (arr[m]=str
382 | }
383 |
384 | function AMgetSymbol(str) {
385 | //return maximal initial substring of str that appears in names
386 | //return null if there is none
387 | var k = 0; //new pos
388 | var j = 0; //old pos
389 | var mk; //match pos
390 | var st;
391 | var tagst;
392 | var match = "";
393 | var more = true;
394 | for (var i=1; i<=str.length && more; i++) {
395 | st = str.slice(0,i); //initial substring of length i
396 | j = k;
397 | k = AMposition(AMnames, st, j);
398 | if (k=AMnames[k];
404 | }
405 | AMpreviousSymbol=AMcurrentSymbol;
406 | if (match!=""){
407 | AMcurrentSymbol=AMsymbols[mk].ttype;
408 | return AMsymbols[mk];
409 | }
410 | // if str[0] is a digit or - return maxsubstring of digits.digits
411 | AMcurrentSymbol=CONST;
412 | k = 1;
413 | st = str.slice(0,1);
414 | var integ = true;
415 | while ("0"<=st && st<="9" && k<=str.length) {
416 | st = str.slice(k,k+1);
417 | k++;
418 | }
419 | if (st == decimalsign) {
420 | st = str.slice(k,k+1);
421 | if ("0"<=st && st<="9") {
422 | integ = false;
423 | k++;
424 | while ("0"<=st && st<="9" && k<=str.length) {
425 | st = str.slice(k,k+1);
426 | k++;
427 | }
428 | }
429 | }
430 | if ((integ && k>1) || k>2) {
431 | st = str.slice(0,k-1);
432 | tagst = "mn";
433 | } else {
434 | k = 2;
435 | st = str.slice(0,1); //take 1 character
436 | tagst = (("A">st || st>"Z") && ("a">st || st>"z")?"mo":"mi");
437 | }
438 | if (st=="-" && AMpreviousSymbol==INFIX) {
439 | AMcurrentSymbol = INFIX; //trick "/" into recognizing "-" on second parse
440 | return {input:st, tag:tagst, output:st, ttype:UNARY, func:true};
441 | }
442 | return {input:st, tag:tagst, output:st, ttype:CONST};
443 | }
444 |
445 | function AMremoveBrackets(node) {
446 | var st;
447 | if (node.nodeName=="mrow") {
448 | st = node.firstChild.firstChild.nodeValue;
449 | if (st=="(" || st=="[" || st=="{") node.removeChild(node.firstChild);
450 | }
451 | if (node.nodeName=="mrow") {
452 | st = node.lastChild.firstChild.nodeValue;
453 | if (st==")" || st=="]" || st=="}") node.removeChild(node.lastChild);
454 | }
455 | }
456 |
457 | /*Parsing ASCII math expressions with the following grammar
458 | v ::= [A-Za-z] | greek letters | numbers | other constant symbols
459 | u ::= sqrt | text | bb | other unary symbols for font commands
460 | b ::= frac | root | stackrel binary symbols
461 | l ::= ( | [ | { | (: | {: left brackets
462 | r ::= ) | ] | } | :) | :} right brackets
463 | S ::= v | lEr | uS | bSS Simple expression
464 | I ::= S_S | S^S | S_S^S | S Intermediate expression
465 | E ::= IE | I/I Expression
466 | Each terminal symbol is translated into a corresponding mathml node.*/
467 |
468 | var AMnestingDepth,AMpreviousSymbol,AMcurrentSymbol;
469 |
470 | function AMparseSexpr(str) { //parses str and returns [node,tailstr]
471 | var symbol, node, result, i, st,// rightvert = false,
472 | newFrag = document.createDocumentFragment();
473 | str = AMremoveCharsAndBlanks(str,0);
474 | symbol = AMgetSymbol(str); //either a token or a bracket or empty
475 | if (symbol == null || symbol.ttype == RIGHTBRACKET && AMnestingDepth > 0) {
476 | return [null,str];
477 | }
478 | if (symbol.ttype == DEFINITION) {
479 | str = symbol.output+AMremoveCharsAndBlanks(str,symbol.input.length);
480 | symbol = AMgetSymbol(str);
481 | }
482 | switch (symbol.ttype) {
483 | case UNDEROVER:
484 | case CONST:
485 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
486 | return [AMcreateMmlNode(symbol.tag, //its a constant
487 | document.createTextNode(symbol.output)),str];
488 | case LEFTBRACKET: //read (expr+)
489 | AMnestingDepth++;
490 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
491 | result = AMparseExpr(str,true);
492 | AMnestingDepth--;
493 | if (typeof symbol.invisible == "boolean" && symbol.invisible)
494 | node = AMcreateMmlNode("mrow",result[0]);
495 | else {
496 | node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
497 | node = AMcreateMmlNode("mrow",node);
498 | node.appendChild(result[0]);
499 | }
500 | return [node,result[1]];
501 | case TEXT:
502 | if (symbol!=AMquote) str = AMremoveCharsAndBlanks(str,symbol.input.length);
503 | if (str.charAt(0)=="{") i=str.indexOf("}");
504 | else if (str.charAt(0)=="(") i=str.indexOf(")");
505 | else if (str.charAt(0)=="[") i=str.indexOf("]");
506 | else if (symbol==AMquote) i=str.slice(1).indexOf("\"")+1;
507 | else i = 0;
508 | if (i==-1) i = str.length;
509 | st = str.slice(1,i);
510 | if (st.charAt(0) == " ") {
511 | node = AMcreateElementMathML("mspace");
512 | node.setAttribute("width","1ex");
513 | newFrag.appendChild(node);
514 | }
515 | newFrag.appendChild(
516 | AMcreateMmlNode(symbol.tag,document.createTextNode(st)));
517 | if (st.charAt(st.length-1) == " ") {
518 | node = AMcreateElementMathML("mspace");
519 | node.setAttribute("width","1ex");
520 | newFrag.appendChild(node);
521 | }
522 | str = AMremoveCharsAndBlanks(str,i+1);
523 | return [AMcreateMmlNode("mrow",newFrag),str];
524 | case UNARY:
525 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
526 | result = AMparseSexpr(str);
527 | if (result[0]==null) return [AMcreateMmlNode(symbol.tag,
528 | document.createTextNode(symbol.output)),str];
529 | if (typeof symbol.func == "boolean" && symbol.func) { // functions hack
530 | st = str.charAt(0);
531 | if (st=="^" || st=="_" || st=="/" || st=="|" || st==",") {
532 | return [AMcreateMmlNode(symbol.tag,
533 | document.createTextNode(symbol.output)),str];
534 | } else {
535 | node = AMcreateMmlNode("mrow",
536 | AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
537 | node.appendChild(result[0]);
538 | return [node,result[1]];
539 | }
540 | }
541 | AMremoveBrackets(result[0]);
542 | if (symbol.input == "sqrt") { // sqrt
543 | return [AMcreateMmlNode(symbol.tag,result[0]),result[1]];
544 | } else if (typeof symbol.acc == "boolean" && symbol.acc) { // accent
545 | node = AMcreateMmlNode(symbol.tag,result[0]);
546 | node.appendChild(AMcreateMmlNode("mo",document.createTextNode(symbol.output)));
547 | return [node,result[1]];
548 | } else { // font change command
549 | if (!isIE && typeof symbol.codes != "undefined") {
550 | for (i=0; i64 && st.charCodeAt(j)<91) newst = newst +
557 | String.fromCharCode(symbol.codes[st.charCodeAt(j)-65]);
558 | else newst = newst + st.charAt(j);
559 | if (result[0].nodeName=="mi")
560 | result[0]=AMcreateElementMathML("mo").
561 | appendChild(document.createTextNode(newst));
562 | else result[0].replaceChild(AMcreateElementMathML("mo").
563 | appendChild(document.createTextNode(newst)),result[0].childNodes[i]);
564 | }
565 | }
566 | node = AMcreateMmlNode(symbol.tag,result[0]);
567 | node.setAttribute(symbol.atname,symbol.atval);
568 | return [node,result[1]];
569 | }
570 | case BINARY:
571 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
572 | result = AMparseSexpr(str);
573 | if (result[0]==null) return [AMcreateMmlNode("mo",
574 | document.createTextNode(symbol.input)),str];
575 | AMremoveBrackets(result[0]);
576 | var result2 = AMparseSexpr(result[1]);
577 | if (result2[0]==null) return [AMcreateMmlNode("mo",
578 | document.createTextNode(symbol.input)),str];
579 | AMremoveBrackets(result2[0]);
580 | if (symbol.input=="root" || symbol.input=="stackrel")
581 | newFrag.appendChild(result2[0]);
582 | newFrag.appendChild(result[0]);
583 | if (symbol.input=="frac") newFrag.appendChild(result2[0]);
584 | return [AMcreateMmlNode(symbol.tag,newFrag),result2[1]];
585 | case INFIX:
586 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
587 | return [AMcreateMmlNode("mo",document.createTextNode(symbol.output)),str];
588 | case SPACE:
589 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
590 | node = AMcreateElementMathML("mspace");
591 | node.setAttribute("width","1ex");
592 | newFrag.appendChild(node);
593 | newFrag.appendChild(
594 | AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
595 | node = AMcreateElementMathML("mspace");
596 | node.setAttribute("width","1ex");
597 | newFrag.appendChild(node);
598 | return [AMcreateMmlNode("mrow",newFrag),str];
599 | case LEFTRIGHT:
600 | // if (rightvert) return [null,str]; else rightvert = true;
601 | AMnestingDepth++;
602 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
603 | result = AMparseExpr(str,false);
604 | AMnestingDepth--;
605 | var st = "";
606 | if (result[0].lastChild!=null)
607 | st = result[0].lastChild.firstChild.nodeValue;
608 | if (st == "|") { // its an absolute value subterm
609 | node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
610 | node = AMcreateMmlNode("mrow",node);
611 | node.appendChild(result[0]);
612 | return [node,result[1]];
613 | } else { // the "|" is a \mid
614 | node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
615 | node = AMcreateMmlNode("mrow",node);
616 | return [node,str];
617 | }
618 | default:
619 | //alert("default");
620 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
621 | return [AMcreateMmlNode(symbol.tag, //its a constant
622 | document.createTextNode(symbol.output)),str];
623 | }
624 | }
625 |
626 | function AMparseIexpr(str) {
627 | var symbol, sym1, sym2, node, result, underover;
628 | str = AMremoveCharsAndBlanks(str,0);
629 | sym1 = AMgetSymbol(str);
630 | result = AMparseSexpr(str);
631 | node = result[0];
632 | str = result[1];
633 | symbol = AMgetSymbol(str);
634 | if (symbol.ttype == INFIX && symbol.input != "/") {
635 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
636 | // if (symbol.input == "/") result = AMparseIexpr(str); else ...
637 | result = AMparseSexpr(str);
638 | if (result[0] == null) // show box in place of missing argument
639 | result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
640 | else AMremoveBrackets(result[0]);
641 | str = result[1];
642 | // if (symbol.input == "/") AMremoveBrackets(node);
643 | if (symbol.input == "_") {
644 | sym2 = AMgetSymbol(str);
645 | underover = (sym1.ttype == UNDEROVER);
646 | if (sym2.input == "^") {
647 | str = AMremoveCharsAndBlanks(str,sym2.input.length);
648 | var res2 = AMparseSexpr(str);
649 | AMremoveBrackets(res2[0]);
650 | str = res2[1];
651 | node = AMcreateMmlNode((underover?"munderover":"msubsup"),node);
652 | node.appendChild(result[0]);
653 | node.appendChild(res2[0]);
654 | node = AMcreateMmlNode("mrow",node); // so sum does not stretch
655 | } else {
656 | node = AMcreateMmlNode((underover?"munder":"msub"),node);
657 | node.appendChild(result[0]);
658 | }
659 | } else {
660 | node = AMcreateMmlNode(symbol.tag,node);
661 | node.appendChild(result[0]);
662 | }
663 | }
664 | return [node,str];
665 | }
666 |
667 | function AMparseExpr(str,rightbracket) {
668 | var symbol, node, result, i, nodeList = [],
669 | newFrag = document.createDocumentFragment();
670 | do {
671 | str = AMremoveCharsAndBlanks(str,0);
672 | result = AMparseIexpr(str);
673 | node = result[0];
674 | str = result[1];
675 | symbol = AMgetSymbol(str);
676 | if (symbol.ttype == INFIX && symbol.input == "/") {
677 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
678 | result = AMparseIexpr(str);
679 | if (result[0] == null) // show box in place of missing argument
680 | result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
681 | else AMremoveBrackets(result[0]);
682 | str = result[1];
683 | AMremoveBrackets(node);
684 | node = AMcreateMmlNode(symbol.tag,node);
685 | node.appendChild(result[0]);
686 | newFrag.appendChild(node);
687 | symbol = AMgetSymbol(str);
688 | }
689 | else if (node!=undefined) newFrag.appendChild(node);
690 | } while ((symbol.ttype != RIGHTBRACKET &&
691 | (symbol.ttype != LEFTRIGHT || rightbracket)
692 | || AMnestingDepth == 0) && symbol!=null && symbol.output!="");
693 | if (symbol.ttype == RIGHTBRACKET || symbol.ttype == LEFTRIGHT) {
694 | // if (AMnestingDepth > 0) AMnestingDepth--;
695 | var len = newFrag.childNodes.length;
696 | if (len>0 && newFrag.childNodes[len-1].nodeName == "mrow" && len>1 &&
697 | newFrag.childNodes[len-2].nodeName == "mo" &&
698 | newFrag.childNodes[len-2].firstChild.nodeValue == ",") { //matrix
699 | var right = newFrag.childNodes[len-1].lastChild.firstChild.nodeValue;
700 | if (right==")" || right=="]") {
701 | var left = newFrag.childNodes[len-1].firstChild.firstChild.nodeValue;
702 | if (left=="(" && right==")" && symbol.output != "}" ||
703 | left=="[" && right=="]") {
704 | var pos = []; // positions of commas
705 | var matrix = true;
706 | var m = newFrag.childNodes.length;
707 | for (i=0; matrix && i1) matrix = pos[i].length == pos[i-2].length;
720 | }
721 | if (matrix) {
722 | var row, frag, n, k, table = document.createDocumentFragment();
723 | for (i=0; i(-,-,...,-,-)
727 | n = node.childNodes.length;
728 | k = 0;
729 | node.removeChild(node.firstChild); //remove (
730 | for (j=1; j2) {
739 | newFrag.removeChild(newFrag.firstChild); //remove )
740 | newFrag.removeChild(newFrag.firstChild); //remove ,
741 | }
742 | table.appendChild(AMcreateMmlNode("mtr",row));
743 | }
744 | node = AMcreateMmlNode("mtable",table);
745 | if (typeof symbol.invisible == "boolean" && symbol.invisible) node.setAttribute("columnalign","left");
746 | newFrag.replaceChild(node,newFrag.firstChild);
747 | }
748 | }
749 | }
750 | }
751 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
752 | if (typeof symbol.invisible != "boolean" || !symbol.invisible) {
753 | node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
754 | newFrag.appendChild(node);
755 | }
756 | }
757 | return [newFrag,str];
758 | }
759 |
760 | function AMparseMath(str) {
761 | var result, node = AMcreateElementMathML("mstyle");
762 | if (mathcolor != "") node.setAttribute("mathcolor",mathcolor);
763 | if (displaystyle) node.setAttribute("displaystyle","true");
764 | if (mathfontfamily != "") node.setAttribute("fontfamily",mathfontfamily);
765 | AMnestingDepth = 0;
766 | node.appendChild(AMparseExpr(str.replace(/^\s+/g,""),false)[0]);
767 | node = AMcreateMmlNode("math",node);
768 | if (showasciiformulaonhover) //fixed by djhsu so newline
769 | node.setAttribute("title",str.replace(/\s+/g," "));//does not show in Gecko
770 | if (mathfontfamily != "" && (isIE || mathfontfamily != "serif")) {
771 | var fnode = AMcreateElementXHTML("font");
772 | fnode.setAttribute("face",mathfontfamily);
773 | fnode.appendChild(node);
774 | return fnode;
775 | }
776 | return node;
777 | }
778 |
779 | function AMstrarr2docFrag(arr, linebreaks) {
780 | var newFrag=document.createDocumentFragment();
781 | var expr = false;
782 | for (var i=0; i1 || mtch) {
827 | if (checkForMathML) {
828 | checkForMathML = false;
829 | var nd = AMisMathMLavailable();
830 | AMnoMathML = nd != null;
831 | if (AMnoMathML && notifyIfNoMathML)
832 | if (alertIfNoMathML)
833 | alert("To view the ASCIIMathML notation use Internet Explorer 6 +\nMathPlayer (free from www.dessci.com)\n\
834 | or Firefox/Mozilla/Netscape");
835 | else AMbody.insertBefore(nd,AMbody.childNodes[0]);
836 | }
837 | if (!AMnoMathML) {
838 | frg = AMstrarr2docFrag(arr,n.nodeType==8);
839 | var len = frg.childNodes.length;
840 | n.parentNode.replaceChild(frg,n);
841 | return len-1;
842 | } else return 0;
843 | }
844 | }
845 | } else return 0;
846 | } else if (n.nodeName!="math") {
847 | for (i=0; i");
889 | document.write("");
890 | }
891 |
892 | // GO1.1 Generic onload by Brothercake
893 | // http://www.brothercake.com/
894 | //onload function (replaces the onload="translate()" in the tag)
895 | function generic()
896 | {
897 | translate();
898 | };
899 | //setup onload function
900 | if(typeof window.addEventListener != 'undefined')
901 | {
902 | //.. gecko, safari, konqueror and standard
903 | window.addEventListener('load', generic, false);
904 | }
905 | else if(typeof document.addEventListener != 'undefined')
906 | {
907 | //.. opera 7
908 | document.addEventListener('load', generic, false);
909 | }
910 | else if(typeof window.attachEvent != 'undefined')
911 | {
912 | //.. win/ie
913 | window.attachEvent('onload', generic);
914 | }
915 | //** remove this condition to degrade older browsers
916 | else
917 | {
918 | //.. mac/ie5 and anything else that gets this far
919 | //if there's an existing onload function
920 | if(typeof window.onload == 'function')
921 | {
922 | //store it
923 | var existing = onload;
924 | //add new onload handler
925 | window.onload = function()
926 | {
927 | //call existing onload function
928 | existing();
929 | //call generic onload function
930 | generic();
931 | };
932 | }
933 | else
934 | {
935 | //setup onload function
936 | window.onload = generic;
937 | }
938 | }
939 |
--------------------------------------------------------------------------------
/js/LaTeXMathML.js:
--------------------------------------------------------------------------------
1 | /*
2 | LaTeXMathML.js
3 | ==============
4 |
5 | This file, in this form, is due to Douglas Woodall, June 2006.
6 | It contains JavaScript functions to convert (most simple) LaTeX
7 | math notation to Presentation MathML. It was obtained by
8 | downloading the file ASCIIMathML.js from
9 | http://www1.chapman.edu/~jipsen/mathml/asciimathdownload/
10 | and modifying it so that it carries out ONLY those conversions
11 | that would be carried out in LaTeX. A description of the original
12 | file, with examples, can be found at
13 | www1.chapman.edu/~jipsen/mathml/asciimath.html
14 | ASCIIMathML: Math on the web for everyone
15 |
16 | Here is the header notice from the original file:
17 |
18 | ASCIIMathML.js
19 | ==============
20 | This file contains JavaScript functions to convert ASCII math notation
21 | to Presentation MathML. The conversion is done while the (X)HTML page
22 | loads, and should work with Firefox/Mozilla/Netscape 7+ and Internet
23 | Explorer 6+MathPlayer (http://www.dessci.com/en/products/mathplayer/).
24 | Just add the next line to your (X)HTML page with this file in the same folder:
25 | This is a convenient and inexpensive solution for authoring MathML.
26 |
27 | Version 1.4.7 Dec 15, 2005, (c) Peter Jipsen http://www.chapman.edu/~jipsen
28 | Latest version at http://www.chapman.edu/~jipsen/mathml/ASCIIMathML.js
29 | For changes see http://www.chapman.edu/~jipsen/mathml/asciimathchanges.txt
30 | If you use it on a webpage, please send the URL to jipsen@chapman.edu
31 |
32 | This program is free software; you can redistribute it and/or modify
33 | it under the terms of the GNU General Public License as published by
34 | the Free Software Foundation; either version 2 of the License, or (at
35 | your option) any later version.
36 |
37 | This program is distributed in the hope that it will be useful,
38 | but WITHOUT ANY WARRANTY; without even the implied warranty of
39 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40 | General Public License (at http://www.gnu.org/copyleft/gpl.html)
41 | for more details.
42 |
43 | LaTeXMathML.js (ctd)
44 | ==============
45 |
46 | The instructions for use are the same as for the original
47 | ASCIIMathML.js, except that of course the line you add to your
48 | file should be
49 | Or use absolute path names if the file is not in the same folder
50 | as your (X)HTML page.
51 | */
52 |
53 | var checkForMathML = true; // check if browser can display MathML
54 | var notifyIfNoMathML = true; // display note if no MathML capability
55 | var alertIfNoMathML = false; // show alert box if no MathML capability
56 | // was "red":
57 | var mathcolor = ""; // change it to "" (to inherit) or any other color
58 | // was "serif":
59 | var mathfontfamily = ""; // change to "" to inherit (works in IE)
60 | // or another family (e.g. "arial")
61 | var showasciiformulaonhover = true; // helps students learn ASCIIMath
62 | /*
63 | // Commented out by DRW -- not now used -- see DELIMITERS (twice) near the end
64 | var displaystyle = false; // puts limits above and below large operators
65 | var decimalsign = "."; // change to "," if you like, beware of `(1,2)`!
66 | var AMdelimiter1 = "`", AMescape1 = "\\\\`"; // can use other characters
67 | var AMdelimiter2 = "$", AMescape2 = "\\\\\\$", AMdelimiter2regexp = "\\$";
68 | var doubleblankmathdelimiter = false; // if true, x+1 is equal to `x+1`
69 | // for IE this works only in
70 | //var separatetokens;// has been removed (email me if this is a problem)
71 | */
72 | var isIE = document.createElementNS==null;
73 |
74 | if (document.getElementById==null)
75 | alert("This webpage requires a recent browser such as\
76 | \nMozilla/Netscape 7+ or Internet Explorer 6+MathPlayer")
77 |
78 | // all further global variables start with "AM"
79 |
80 | function AMcreateElementXHTML(t) {
81 | if (isIE) return document.createElement(t);
82 | else return document.createElementNS("http://www.w3.org/1999/xhtml",t);
83 | }
84 |
85 | function AMnoMathMLNote() {
86 | var nd = AMcreateElementXHTML("h3");
87 | nd.setAttribute("align","center")
88 | nd.appendChild(AMcreateElementXHTML("p"));
89 | nd.appendChild(document.createTextNode("To view the "));
90 | var an = AMcreateElementXHTML("a");
91 | an.appendChild(document.createTextNode("LaTeXMathML"));
92 | an.setAttribute("href","http://www.maths.nott.ac.uk/personal/drw/lm.html");
93 | nd.appendChild(an);
94 | nd.appendChild(document.createTextNode(" notation use Internet Explorer 6+"));
95 | an = AMcreateElementXHTML("a");
96 | an.appendChild(document.createTextNode("MathPlayer"));
97 | an.setAttribute("href","http://www.dessci.com/en/products/mathplayer/download.htm");
98 | nd.appendChild(an);
99 | nd.appendChild(document.createTextNode(" or Netscape/Mozilla/Firefox"));
100 | nd.appendChild(AMcreateElementXHTML("p"));
101 | return nd;
102 | }
103 |
104 | function AMisMathMLavailable() {
105 | if (navigator.appName.slice(0,8)=="Netscape")
106 | if (navigator.appVersion.slice(0,1)>="5") return null;
107 | else return AMnoMathMLNote();
108 | else if (navigator.appName.slice(0,9)=="Microsoft")
109 | try {
110 | var ActiveX = new ActiveXObject("MathPlayer.Factory.1");
111 | return null;
112 | } catch (e) {
113 | return AMnoMathMLNote();
114 | }
115 | else return AMnoMathMLNote();
116 | }
117 |
118 | // character lists for Mozilla/Netscape fonts
119 | 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];
120 | 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];
121 | 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];
122 |
123 | var CONST = 0, UNARY = 1, BINARY = 2, INFIX = 3, LEFTBRACKET = 4,
124 | RIGHTBRACKET = 5, SPACE = 6, UNDEROVER = 7, DEFINITION = 8,
125 | TEXT = 9, BIG = 10, LONG = 11, STRETCHY = 12, MATRIX = 13; // token types
126 |
127 | var AMsqrt = {input:"\\sqrt", tag:"msqrt", output:"sqrt", ttype:UNARY},
128 | AMroot = {input:"\\root", tag:"mroot", output:"root", ttype:BINARY},
129 | AMfrac = {input:"\\frac", tag:"mfrac", output:"/", ttype:BINARY},
130 | AMover = {input:"\\stackrel", tag:"mover", output:"stackrel", ttype:BINARY},
131 | AMatop = {input:"\\atop", tag:"mfrac", output:"", ttype:INFIX},
132 | AMchoose = {input:"\\choose", tag:"mfrac", output:"", ttype:INFIX},
133 | AMsub = {input:"_", tag:"msub", output:"_", ttype:INFIX},
134 | AMsup = {input:"^", tag:"msup", output:"^", ttype:INFIX},
135 | AMtext = {input:"\\mathrm", tag:"mtext", output:"text", ttype:TEXT},
136 | AMmbox = {input:"\\mbox", tag:"mtext", output:"mbox", ttype:TEXT};
137 |
138 | // Commented out by DRW to prevent 1/2 turning into a 2-line fraction
139 | // AMdiv = {input:"/", tag:"mfrac", output:"/", ttype:INFIX},
140 | // Commented out by DRW so that " prints literally in equations
141 | // AMquote = {input:"\"", tag:"mtext", output:"mbox", ttype:TEXT};
142 |
143 | var AMsymbols = [
144 | //Greek letters
145 | {input:"\\alpha", tag:"mi", output:"\u03B1", ttype:CONST},
146 | {input:"\\beta", tag:"mi", output:"\u03B2", ttype:CONST},
147 | {input:"\\gamma", tag:"mi", output:"\u03B3", ttype:CONST},
148 | {input:"\\delta", tag:"mi", output:"\u03B4", ttype:CONST},
149 | {input:"\\epsilon", tag:"mi", output:"\u03B5", ttype:CONST},
150 | {input:"\\varepsilon", tag:"mi", output:"\u025B", ttype:CONST},
151 | {input:"\\zeta", tag:"mi", output:"\u03B6", ttype:CONST},
152 | {input:"\\eta", tag:"mi", output:"\u03B7", ttype:CONST},
153 | {input:"\\theta", tag:"mi", output:"\u03B8", ttype:CONST},
154 | {input:"\\vartheta", tag:"mi", output:"\u03D1", ttype:CONST},
155 | {input:"\\iota", tag:"mi", output:"\u03B9", ttype:CONST},
156 | {input:"\\kappa", tag:"mi", output:"\u03BA", ttype:CONST},
157 | {input:"\\lambda", tag:"mi", output:"\u03BB", ttype:CONST},
158 | {input:"\\mu", tag:"mi", output:"\u03BC", ttype:CONST},
159 | {input:"\\nu", tag:"mi", output:"\u03BD", ttype:CONST},
160 | {input:"\\xi", tag:"mi", output:"\u03BE", ttype:CONST},
161 | {input:"\\pi", tag:"mi", output:"\u03C0", ttype:CONST},
162 | {input:"\\varpi", tag:"mi", output:"\u03D6", ttype:CONST},
163 | {input:"\\rho", tag:"mi", output:"\u03C1", ttype:CONST},
164 | {input:"\\varrho", tag:"mi", output:"\u03F1", ttype:CONST},
165 | {input:"\\varsigma", tag:"mi", output:"\u03C2", ttype:CONST},
166 | {input:"\\sigma", tag:"mi", output:"\u03C3", ttype:CONST},
167 | {input:"\\tau", tag:"mi", output:"\u03C4", ttype:CONST},
168 | {input:"\\upsilon", tag:"mi", output:"\u03C5", ttype:CONST},
169 | {input:"\\phi", tag:"mi", output:"\u03C6", ttype:CONST},
170 | {input:"\\varphi", tag:"mi", output:"\u03D5", ttype:CONST},
171 | {input:"\\chi", tag:"mi", output:"\u03C7", ttype:CONST},
172 | {input:"\\psi", tag:"mi", output:"\u03C8", ttype:CONST},
173 | {input:"\\omega", tag:"mi", output:"\u03C9", ttype:CONST},
174 | {input:"\\Gamma", tag:"mo", output:"\u0393", ttype:CONST},
175 | {input:"\\Delta", tag:"mo", output:"\u0394", ttype:CONST},
176 | {input:"\\Theta", tag:"mo", output:"\u0398", ttype:CONST},
177 | {input:"\\Lambda", tag:"mo", output:"\u039B", ttype:CONST},
178 | {input:"\\Xi", tag:"mo", output:"\u039E", ttype:CONST},
179 | {input:"\\Pi", tag:"mo", output:"\u03A0", ttype:CONST},
180 | {input:"\\Sigma", tag:"mo", output:"\u03A3", ttype:CONST},
181 | {input:"\\Upsilon", tag:"mo", output:"\u03A5", ttype:CONST},
182 | {input:"\\Phi", tag:"mo", output:"\u03A6", ttype:CONST},
183 | {input:"\\Psi", tag:"mo", output:"\u03A8", ttype:CONST},
184 | {input:"\\Omega", tag:"mo", output:"\u03A9", ttype:CONST},
185 |
186 | //fractions
187 | {input:"\\frac12", tag:"mo", output:"\u00BD", ttype:CONST},
188 | {input:"\\frac14", tag:"mo", output:"\u00BC", ttype:CONST},
189 | {input:"\\frac34", tag:"mo", output:"\u00BE", ttype:CONST},
190 | {input:"\\frac13", tag:"mo", output:"\u2153", ttype:CONST},
191 | {input:"\\frac23", tag:"mo", output:"\u2154", ttype:CONST},
192 | {input:"\\frac15", tag:"mo", output:"\u2155", ttype:CONST},
193 | {input:"\\frac25", tag:"mo", output:"\u2156", ttype:CONST},
194 | {input:"\\frac35", tag:"mo", output:"\u2157", ttype:CONST},
195 | {input:"\\frac45", tag:"mo", output:"\u2158", ttype:CONST},
196 | {input:"\\frac16", tag:"mo", output:"\u2159", ttype:CONST},
197 | {input:"\\frac56", tag:"mo", output:"\u215A", ttype:CONST},
198 | {input:"\\frac18", tag:"mo", output:"\u215B", ttype:CONST},
199 | {input:"\\frac38", tag:"mo", output:"\u215C", ttype:CONST},
200 | {input:"\\frac58", tag:"mo", output:"\u215D", ttype:CONST},
201 | {input:"\\frac78", tag:"mo", output:"\u215E", ttype:CONST},
202 |
203 | //binary operation symbols
204 | {input:"\\pm", tag:"mo", output:"\u00B1", ttype:CONST},
205 | {input:"\\mp", tag:"mo", output:"\u2213", ttype:CONST},
206 | {input:"\\triangleleft",tag:"mo", output:"\u22B2", ttype:CONST},
207 | {input:"\\triangleright",tag:"mo",output:"\u22B3", ttype:CONST},
208 | {input:"\\cdot", tag:"mo", output:"\u22C5", ttype:CONST},
209 | {input:"\\star", tag:"mo", output:"\u22C6", ttype:CONST},
210 | {input:"\\ast", tag:"mo", output:"\u002A", ttype:CONST},
211 | {input:"\\times", tag:"mo", output:"\u00D7", ttype:CONST},
212 | {input:"\\div", tag:"mo", output:"\u00F7", ttype:CONST},
213 | {input:"\\circ", tag:"mo", output:"\u2218", ttype:CONST},
214 | //{input:"\\bullet", tag:"mo", output:"\u2219", ttype:CONST},
215 | {input:"\\bullet", tag:"mo", output:"\u2022", ttype:CONST},
216 | {input:"\\oplus", tag:"mo", output:"\u2295", ttype:CONST},
217 | {input:"\\ominus", tag:"mo", output:"\u2296", ttype:CONST},
218 | {input:"\\otimes", tag:"mo", output:"\u2297", ttype:CONST},
219 | {input:"\\bigcirc", tag:"mo", output:"\u25CB", ttype:CONST},
220 | {input:"\\oslash", tag:"mo", output:"\u2298", ttype:CONST},
221 | {input:"\\odot", tag:"mo", output:"\u2299", ttype:CONST},
222 | {input:"\\land", tag:"mo", output:"\u2227", ttype:CONST},
223 | {input:"\\wedge", tag:"mo", output:"\u2227", ttype:CONST},
224 | {input:"\\lor", tag:"mo", output:"\u2228", ttype:CONST},
225 | {input:"\\vee", tag:"mo", output:"\u2228", ttype:CONST},
226 | {input:"\\cap", tag:"mo", output:"\u2229", ttype:CONST},
227 | {input:"\\cup", tag:"mo", output:"\u222A", ttype:CONST},
228 | {input:"\\sqcap", tag:"mo", output:"\u2293", ttype:CONST},
229 | {input:"\\sqcup", tag:"mo", output:"\u2294", ttype:CONST},
230 | {input:"\\uplus", tag:"mo", output:"\u228E", ttype:CONST},
231 | {input:"\\amalg", tag:"mo", output:"\u2210", ttype:CONST},
232 | {input:"\\bigtriangleup",tag:"mo",output:"\u25B3", ttype:CONST},
233 | {input:"\\bigtriangledown",tag:"mo",output:"\u25BD", ttype:CONST},
234 | {input:"\\dag", tag:"mo", output:"\u2020", ttype:CONST},
235 | {input:"\\dagger", tag:"mo", output:"\u2020", ttype:CONST},
236 | {input:"\\ddag", tag:"mo", output:"\u2021", ttype:CONST},
237 | {input:"\\ddagger", tag:"mo", output:"\u2021", ttype:CONST},
238 | {input:"\\lhd", tag:"mo", output:"\u22B2", ttype:CONST},
239 | {input:"\\rhd", tag:"mo", output:"\u22B3", ttype:CONST},
240 | {input:"\\unlhd", tag:"mo", output:"\u22B4", ttype:CONST},
241 | {input:"\\unrhd", tag:"mo", output:"\u22B5", ttype:CONST},
242 |
243 |
244 | //BIG Operators
245 | {input:"\\sum", tag:"mo", output:"\u2211", ttype:UNDEROVER},
246 | {input:"\\prod", tag:"mo", output:"\u220F", ttype:UNDEROVER},
247 | {input:"\\bigcap", tag:"mo", output:"\u22C2", ttype:UNDEROVER},
248 | {input:"\\bigcup", tag:"mo", output:"\u22C3", ttype:UNDEROVER},
249 | {input:"\\bigwedge", tag:"mo", output:"\u22C0", ttype:UNDEROVER},
250 | {input:"\\bigvee", tag:"mo", output:"\u22C1", ttype:UNDEROVER},
251 | {input:"\\bigsqcap", tag:"mo", output:"\u2A05", ttype:UNDEROVER},
252 | {input:"\\bigsqcup", tag:"mo", output:"\u2A06", ttype:UNDEROVER},
253 | {input:"\\coprod", tag:"mo", output:"\u2210", ttype:UNDEROVER},
254 | {input:"\\bigoplus", tag:"mo", output:"\u2A01", ttype:UNDEROVER},
255 | {input:"\\bigotimes", tag:"mo", output:"\u2A02", ttype:UNDEROVER},
256 | {input:"\\bigodot", tag:"mo", output:"\u2A00", ttype:UNDEROVER},
257 | {input:"\\biguplus", tag:"mo", output:"\u2A04", ttype:UNDEROVER},
258 | {input:"\\int", tag:"mo", output:"\u222B", ttype:CONST},
259 | {input:"\\oint", tag:"mo", output:"\u222E", ttype:CONST},
260 |
261 | //binary relation symbols
262 | {input:":=", tag:"mo", output:":=", ttype:CONST},
263 | {input:"\\lt", tag:"mo", output:"<", ttype:CONST},
264 | {input:"\\gt", tag:"mo", output:">", ttype:CONST},
265 | {input:"\\ne", tag:"mo", output:"\u2260", ttype:CONST},
266 | {input:"\\neq", tag:"mo", output:"\u2260", ttype:CONST},
267 | {input:"\\le", tag:"mo", output:"\u2264", ttype:CONST},
268 | {input:"\\leq", tag:"mo", output:"\u2264", ttype:CONST},
269 | {input:"\\leqslant", tag:"mo", output:"\u2264", ttype:CONST},
270 | {input:"\\ge", tag:"mo", output:"\u2265", ttype:CONST},
271 | {input:"\\geq", tag:"mo", output:"\u2265", ttype:CONST},
272 | {input:"\\geqslant", tag:"mo", output:"\u2265", ttype:CONST},
273 | {input:"\\equiv", tag:"mo", output:"\u2261", ttype:CONST},
274 | {input:"\\ll", tag:"mo", output:"\u226A", ttype:CONST},
275 | {input:"\\gg", tag:"mo", output:"\u226B", ttype:CONST},
276 | {input:"\\doteq", tag:"mo", output:"\u2250", ttype:CONST},
277 | {input:"\\prec", tag:"mo", output:"\u227A", ttype:CONST},
278 | {input:"\\succ", tag:"mo", output:"\u227B", ttype:CONST},
279 | {input:"\\preceq", tag:"mo", output:"\u227C", ttype:CONST},
280 | {input:"\\succeq", tag:"mo", output:"\u227D", ttype:CONST},
281 | {input:"\\subset", tag:"mo", output:"\u2282", ttype:CONST},
282 | {input:"\\supset", tag:"mo", output:"\u2283", ttype:CONST},
283 | {input:"\\subseteq", tag:"mo", output:"\u2286", ttype:CONST},
284 | {input:"\\supseteq", tag:"mo", output:"\u2287", ttype:CONST},
285 | {input:"\\sqsubset", tag:"mo", output:"\u228F", ttype:CONST},
286 | {input:"\\sqsupset", tag:"mo", output:"\u2290", ttype:CONST},
287 | {input:"\\sqsubseteq", tag:"mo", output:"\u2291", ttype:CONST},
288 | {input:"\\sqsupseteq", tag:"mo", output:"\u2292", ttype:CONST},
289 | {input:"\\sim", tag:"mo", output:"\u223C", ttype:CONST},
290 | {input:"\\simeq", tag:"mo", output:"\u2243", ttype:CONST},
291 | {input:"\\approx", tag:"mo", output:"\u2248", ttype:CONST},
292 | {input:"\\cong", tag:"mo", output:"\u2245", ttype:CONST},
293 | {input:"\\Join", tag:"mo", output:"\u22C8", ttype:CONST},
294 | {input:"\\bowtie", tag:"mo", output:"\u22C8", ttype:CONST},
295 | {input:"\\in", tag:"mo", output:"\u2208", ttype:CONST},
296 | {input:"\\ni", tag:"mo", output:"\u220B", ttype:CONST},
297 | {input:"\\owns", tag:"mo", output:"\u220B", ttype:CONST},
298 | {input:"\\propto", tag:"mo", output:"\u221D", ttype:CONST},
299 | {input:"\\vdash", tag:"mo", output:"\u22A2", ttype:CONST},
300 | {input:"\\dashv", tag:"mo", output:"\u22A3", ttype:CONST},
301 | {input:"\\models", tag:"mo", output:"\u22A8", ttype:CONST},
302 | {input:"\\perp", tag:"mo", output:"\u22A5", ttype:CONST},
303 | {input:"\\smile", tag:"mo", output:"\u2323", ttype:CONST},
304 | {input:"\\frown", tag:"mo", output:"\u2322", ttype:CONST},
305 | {input:"\\asymp", tag:"mo", output:"\u224D", ttype:CONST},
306 | {input:"\\notin", tag:"mo", output:"\u2209", ttype:CONST},
307 |
308 | //matrices
309 | {input:"\\begin{eqnarray}", output:"X", ttype:MATRIX, invisible:true},
310 | {input:"\\begin{array}", output:"X", ttype:MATRIX, invisible:true},
311 | {input:"\\\\", output:"}&{", ttype:DEFINITION},
312 | {input:"\\end{eqnarray}", output:"}}", ttype:DEFINITION},
313 | {input:"\\end{array}", output:"}}", ttype:DEFINITION},
314 |
315 | //grouping and literal brackets -- ieval is for IE
316 | {input:"\\big", tag:"mo", output:"X", atval:"1.2", ieval:"2.2", ttype:BIG},
317 | {input:"\\Big", tag:"mo", output:"X", atval:"1.6", ieval:"2.6", ttype:BIG},
318 | {input:"\\bigg", tag:"mo", output:"X", atval:"2.2", ieval:"3.2", ttype:BIG},
319 | {input:"\\Bigg", tag:"mo", output:"X", atval:"2.9", ieval:"3.9", ttype:BIG},
320 | {input:"\\left", tag:"mo", output:"X", ttype:LEFTBRACKET},
321 | {input:"\\right", tag:"mo", output:"X", ttype:RIGHTBRACKET},
322 | {input:"{", output:"{", ttype:LEFTBRACKET, invisible:true},
323 | {input:"}", output:"}", ttype:RIGHTBRACKET, invisible:true},
324 |
325 | {input:"(", tag:"mo", output:"(", atval:"1", ttype:STRETCHY},
326 | {input:"[", tag:"mo", output:"[", atval:"1", ttype:STRETCHY},
327 | {input:"\\lbrack", tag:"mo", output:"[", atval:"1", ttype:STRETCHY},
328 | {input:"\\{", tag:"mo", output:"{", atval:"1", ttype:STRETCHY},
329 | {input:"\\lbrace", tag:"mo", output:"{", atval:"1", ttype:STRETCHY},
330 | {input:"\\langle", tag:"mo", output:"\u2329", atval:"1", ttype:STRETCHY},
331 | {input:"\\lfloor", tag:"mo", output:"\u230A", atval:"1", ttype:STRETCHY},
332 | {input:"\\lceil", tag:"mo", output:"\u2308", atval:"1", ttype:STRETCHY},
333 |
334 | // rtag:"mi" causes space to be inserted before a following sin, cos, etc.
335 | // (see function AMparseExpr() )
336 | {input:")", tag:"mo",output:")", rtag:"mi",atval:"1",ttype:STRETCHY},
337 | {input:"]", tag:"mo",output:"]", rtag:"mi",atval:"1",ttype:STRETCHY},
338 | {input:"\\rbrack",tag:"mo",output:"]", rtag:"mi",atval:"1",ttype:STRETCHY},
339 | {input:"\\}", tag:"mo",output:"}", rtag:"mi",atval:"1",ttype:STRETCHY},
340 | {input:"\\rbrace",tag:"mo",output:"}", rtag:"mi",atval:"1",ttype:STRETCHY},
341 | {input:"\\rangle",tag:"mo",output:"\u232A", rtag:"mi",atval:"1",ttype:STRETCHY},
342 | {input:"\\rfloor",tag:"mo",output:"\u230B", rtag:"mi",atval:"1",ttype:STRETCHY},
343 | {input:"\\rceil", tag:"mo",output:"\u2309", rtag:"mi",atval:"1",ttype:STRETCHY},
344 |
345 | // "|", "\\|", "\\vert" and "\\Vert" modified later: lspace = rspace = 0em
346 | {input:"|", tag:"mo", output:"\u2223", atval:"1", ttype:STRETCHY},
347 | {input:"\\|", tag:"mo", output:"\u2225", atval:"1", ttype:STRETCHY},
348 | {input:"\\vert", tag:"mo", output:"\u2223", atval:"1", ttype:STRETCHY},
349 | {input:"\\Vert", tag:"mo", output:"\u2225", atval:"1", ttype:STRETCHY},
350 | {input:"\\mid", tag:"mo", output:"\u2223", atval:"1", ttype:STRETCHY},
351 | {input:"\\parallel", tag:"mo", output:"\u2225", atval:"1", ttype:STRETCHY},
352 | {input:"/", tag:"mo", output:"/", atval:"1.01", ttype:STRETCHY},
353 | {input:"\\backslash", tag:"mo", output:"\u2216", atval:"1", ttype:STRETCHY},
354 | {input:"\\setminus", tag:"mo", output:"\\", ttype:CONST},
355 |
356 | //miscellaneous symbols
357 | {input:"\\!", tag:"mspace", atname:"width", atval:"-0.167em", ttype:SPACE},
358 | {input:"\\,", tag:"mspace", atname:"width", atval:"0.167em", ttype:SPACE},
359 | {input:"\\>", tag:"mspace", atname:"width", atval:"0.222em", ttype:SPACE},
360 | {input:"\\:", tag:"mspace", atname:"width", atval:"0.222em", ttype:SPACE},
361 | {input:"\\;", tag:"mspace", atname:"width", atval:"0.278em", ttype:SPACE},
362 | {input:"~", tag:"mspace", atname:"width", atval:"0.333em", ttype:SPACE},
363 | {input:"\\quad", tag:"mspace", atname:"width", atval:"1em", ttype:SPACE},
364 | {input:"\\qquad", tag:"mspace", atname:"width", atval:"2em", ttype:SPACE},
365 | //{input:"{}", tag:"mo", output:"\u200B", ttype:CONST}, // zero-width
366 | {input:"\\prime", tag:"mo", output:"\u2032", ttype:CONST},
367 | {input:"'", tag:"mo", output:"\u02B9", ttype:CONST},
368 | {input:"''", tag:"mo", output:"\u02BA", ttype:CONST},
369 | {input:"'''", tag:"mo", output:"\u2034", ttype:CONST},
370 | {input:"''''", tag:"mo", output:"\u2057", ttype:CONST},
371 | {input:"\\ldots", tag:"mo", output:"\u2026", ttype:CONST},
372 | {input:"\\cdots", tag:"mo", output:"\u22EF", ttype:CONST},
373 | {input:"\\vdots", tag:"mo", output:"\u22EE", ttype:CONST},
374 | {input:"\\ddots", tag:"mo", output:"\u22F1", ttype:CONST},
375 | {input:"\\forall", tag:"mo", output:"\u2200", ttype:CONST},
376 | {input:"\\exists", tag:"mo", output:"\u2203", ttype:CONST},
377 | {input:"\\Re", tag:"mo", output:"\u211C", ttype:CONST},
378 | {input:"\\Im", tag:"mo", output:"\u2111", ttype:CONST},
379 | {input:"\\aleph", tag:"mo", output:"\u2135", ttype:CONST},
380 | {input:"\\hbar", tag:"mo", output:"\u210F", ttype:CONST},
381 | {input:"\\ell", tag:"mo", output:"\u2113", ttype:CONST},
382 | {input:"\\wp", tag:"mo", output:"\u2118", ttype:CONST},
383 | {input:"\\emptyset", tag:"mo", output:"\u2205", ttype:CONST},
384 | {input:"\\infty", tag:"mo", output:"\u221E", ttype:CONST},
385 | {input:"\\surd", tag:"mo", output:"\\sqrt{}", ttype:DEFINITION},
386 | {input:"\\partial", tag:"mo", output:"\u2202", ttype:CONST},
387 | {input:"\\nabla", tag:"mo", output:"\u2207", ttype:CONST},
388 | {input:"\\triangle", tag:"mo", output:"\u25B3", ttype:CONST},
389 | {input:"\\therefore", tag:"mo", output:"\u2234", ttype:CONST},
390 | {input:"\\angle", tag:"mo", output:"\u2220", ttype:CONST},
391 | //{input:"\\\\ ", tag:"mo", output:"\u00A0", ttype:CONST},
392 | {input:"\\diamond", tag:"mo", output:"\u22C4", ttype:CONST},
393 | //{input:"\\Diamond", tag:"mo", output:"\u25CA", ttype:CONST},
394 | {input:"\\Diamond", tag:"mo", output:"\u25C7", ttype:CONST},
395 | {input:"\\neg", tag:"mo", output:"\u00AC", ttype:CONST},
396 | {input:"\\lnot", tag:"mo", output:"\u00AC", ttype:CONST},
397 | {input:"\\bot", tag:"mo", output:"\u22A5", ttype:CONST},
398 | {input:"\\top", tag:"mo", output:"\u22A4", ttype:CONST},
399 | {input:"\\square", tag:"mo", output:"\u25AB", ttype:CONST},
400 | {input:"\\Box", tag:"mo", output:"\u25A1", ttype:CONST},
401 | {input:"\\wr", tag:"mo", output:"\u2240", ttype:CONST},
402 |
403 | //standard functions
404 | //Note UNDEROVER *must* have tag:"mo" to work properly
405 | {input:"\\arccos", tag:"mi", output:"arccos", ttype:UNARY, func:true},
406 | {input:"\\arcsin", tag:"mi", output:"arcsin", ttype:UNARY, func:true},
407 | {input:"\\arctan", tag:"mi", output:"arctan", ttype:UNARY, func:true},
408 | {input:"\\arg", tag:"mi", output:"arg", ttype:UNARY, func:true},
409 | {input:"\\cos", tag:"mi", output:"cos", ttype:UNARY, func:true},
410 | {input:"\\cosh", tag:"mi", output:"cosh", ttype:UNARY, func:true},
411 | {input:"\\cot", tag:"mi", output:"cot", ttype:UNARY, func:true},
412 | {input:"\\coth", tag:"mi", output:"coth", ttype:UNARY, func:true},
413 | {input:"\\csc", tag:"mi", output:"csc", ttype:UNARY, func:true},
414 | {input:"\\deg", tag:"mi", output:"deg", ttype:UNARY, func:true},
415 | {input:"\\det", tag:"mi", output:"det", ttype:UNARY, func:true},
416 | {input:"\\dim", tag:"mi", output:"dim", ttype:UNARY, func:true}, //CONST?
417 | {input:"\\exp", tag:"mi", output:"exp", ttype:UNARY, func:true},
418 | {input:"\\gcd", tag:"mi", output:"gcd", ttype:UNARY, func:true}, //CONST?
419 | {input:"\\hom", tag:"mi", output:"hom", ttype:UNARY, func:true},
420 | {input:"\\inf", tag:"mo", output:"inf", ttype:UNDEROVER},
421 | {input:"\\ker", tag:"mi", output:"ker", ttype:UNARY, func:true},
422 | {input:"\\lg", tag:"mi", output:"lg", ttype:UNARY, func:true},
423 | {input:"\\lim", tag:"mo", output:"lim", ttype:UNDEROVER},
424 | {input:"\\liminf", tag:"mo", output:"liminf", ttype:UNDEROVER},
425 | {input:"\\limsup", tag:"mo", output:"limsup", ttype:UNDEROVER},
426 | {input:"\\ln", tag:"mi", output:"ln", ttype:UNARY, func:true},
427 | {input:"\\log", tag:"mi", output:"log", ttype:UNARY, func:true},
428 | {input:"\\max", tag:"mo", output:"max", ttype:UNDEROVER},
429 | {input:"\\min", tag:"mo", output:"min", ttype:UNDEROVER},
430 | {input:"\\Pr", tag:"mi", output:"Pr", ttype:UNARY, func:true},
431 | {input:"\\sec", tag:"mi", output:"sec", ttype:UNARY, func:true},
432 | {input:"\\sin", tag:"mi", output:"sin", ttype:UNARY, func:true},
433 | {input:"\\sinh", tag:"mi", output:"sinh", ttype:UNARY, func:true},
434 | {input:"\\sup", tag:"mo", output:"sup", ttype:UNDEROVER},
435 | {input:"\\tan", tag:"mi", output:"tan", ttype:UNARY, func:true},
436 | {input:"\\tanh", tag:"mi", output:"tanh", ttype:UNARY, func:true},
437 |
438 | //arrows
439 | {input:"\\gets", tag:"mo", output:"\u2190", ttype:CONST},
440 | {input:"\\leftarrow", tag:"mo", output:"\u2190", ttype:CONST},
441 | {input:"\\to", tag:"mo", output:"\u2192", ttype:CONST},
442 | {input:"\\rightarrow", tag:"mo", output:"\u2192", ttype:CONST},
443 | {input:"\\leftrightarrow", tag:"mo", output:"\u2194", ttype:CONST},
444 | {input:"\\uparrow", tag:"mo", output:"\u2191", ttype:CONST},
445 | {input:"\\downarrow", tag:"mo", output:"\u2193", ttype:CONST},
446 | {input:"\\updownarrow", tag:"mo", output:"\u2195", ttype:CONST},
447 | {input:"\\Leftarrow", tag:"mo", output:"\u21D0", ttype:CONST},
448 | {input:"\\Rightarrow", tag:"mo", output:"\u21D2", ttype:CONST},
449 | {input:"\\Leftrightarrow", tag:"mo", output:"\u21D4", ttype:CONST},
450 | {input:"\\iff", tag:"mo", output:"~\\Longleftrightarrow~", ttype:DEFINITION},
451 | {input:"\\Uparrow", tag:"mo", output:"\u21D1", ttype:CONST},
452 | {input:"\\Downarrow", tag:"mo", output:"\u21D3", ttype:CONST},
453 | {input:"\\Updownarrow", tag:"mo", output:"\u21D5", ttype:CONST},
454 | {input:"\\mapsto", tag:"mo", output:"\u21A6", ttype:CONST},
455 | {input:"\\longleftarrow", tag:"mo", output:"\u2190", ttype:LONG},
456 | {input:"\\longrightarrow", tag:"mo", output:"\u2192", ttype:LONG},
457 | {input:"\\longleftrightarrow", tag:"mo", output:"\u2194", ttype:LONG},
458 | {input:"\\Longleftarrow", tag:"mo", output:"\u21D0", ttype:LONG},
459 | {input:"\\Longrightarrow", tag:"mo", output:"\u21D2", ttype:LONG},
460 | {input:"\\Longleftrightarrow", tag:"mo", output:"\u21D4", ttype:LONG},
461 | {input:"\\longmapsto", tag:"mo", output:"\u21A6", ttype:CONST},
462 | // disaster if LONG
463 |
464 | //commands with argument
465 | AMsqrt, AMroot, AMfrac, AMover, AMsub, AMsup, AMtext, AMmbox, AMatop, AMchoose,
466 | //AMdiv, AMquote,
467 |
468 | //diacritical marks
469 | {input:"\\acute", tag:"mover", output:"\u00B4", ttype:UNARY, acc:true},
470 | //{input:"\\acute", tag:"mover", output:"\u0317", ttype:UNARY, acc:true},
471 | //{input:"\\acute", tag:"mover", output:"\u0301", ttype:UNARY, acc:true},
472 | //{input:"\\grave", tag:"mover", output:"\u0300", ttype:UNARY, acc:true},
473 | //{input:"\\grave", tag:"mover", output:"\u0316", ttype:UNARY, acc:true},
474 | {input:"\\grave", tag:"mover", output:"\u0060", ttype:UNARY, acc:true},
475 | {input:"\\breve", tag:"mover", output:"\u02D8", ttype:UNARY, acc:true},
476 | {input:"\\check", tag:"mover", output:"\u02C7", ttype:UNARY, acc:true},
477 | {input:"\\dot", tag:"mover", output:".", ttype:UNARY, acc:true},
478 | {input:"\\ddot", tag:"mover", output:"..", ttype:UNARY, acc:true},
479 | //{input:"\\ddot", tag:"mover", output:"\u00A8", ttype:UNARY, acc:true},
480 | {input:"\\mathring", tag:"mover", output:"\u00B0", ttype:UNARY, acc:true},
481 | {input:"\\vec", tag:"mover", output:"\u20D7", ttype:UNARY, acc:true},
482 | {input:"\\overrightarrow",tag:"mover",output:"\u20D7", ttype:UNARY, acc:true},
483 | {input:"\\overleftarrow",tag:"mover", output:"\u20D6", ttype:UNARY, acc:true},
484 | {input:"\\hat", tag:"mover", output:"\u005E", ttype:UNARY, acc:true},
485 | {input:"\\widehat", tag:"mover", output:"\u0302", ttype:UNARY, acc:true},
486 | {input:"\\tilde", tag:"mover", output:"~", ttype:UNARY, acc:true},
487 | //{input:"\\tilde", tag:"mover", output:"\u0303", ttype:UNARY, acc:true},
488 | {input:"\\widetilde", tag:"mover", output:"\u02DC", ttype:UNARY, acc:true},
489 | {input:"\\bar", tag:"mover", output:"\u203E", ttype:UNARY, acc:true},
490 | {input:"\\overbrace", tag:"mover", output:"\u23B4", ttype:UNARY, acc:true},
491 | {input:"\\overline", tag:"mover", output:"\u00AF", ttype:UNARY, acc:true},
492 | {input:"\\underbrace", tag:"munder", output:"\u23B5", ttype:UNARY, acc:true},
493 | {input:"\\underline", tag:"munder", output:"\u00AF", ttype:UNARY, acc:true},
494 | //{input:"underline", tag:"munder", output:"\u0332", ttype:UNARY, acc:true},
495 |
496 | //typestyles and fonts
497 | {input:"\\displaystyle",tag:"mstyle",atname:"displaystyle",atval:"true", ttype:UNARY},
498 | {input:"\\textstyle",tag:"mstyle",atname:"displaystyle",atval:"false", ttype:UNARY},
499 | {input:"\\scriptstyle",tag:"mstyle",atname:"scriptlevel",atval:"1", ttype:UNARY},
500 | {input:"\\scriptscriptstyle",tag:"mstyle",atname:"scriptlevel",atval:"2", ttype:UNARY},
501 | {input:"\\textrm", tag:"mstyle", output:"\\mathrm", ttype: DEFINITION},
502 | {input:"\\mathbf", tag:"mstyle", atname:"mathvariant", atval:"bold", ttype:UNARY},
503 | {input:"\\textbf", tag:"mstyle", atname:"mathvariant", atval:"bold", ttype:UNARY},
504 | {input:"\\mathit", tag:"mstyle", atname:"mathvariant", atval:"italic", ttype:UNARY},
505 | {input:"\\textit", tag:"mstyle", atname:"mathvariant", atval:"italic", ttype:UNARY},
506 | {input:"\\mathtt", tag:"mstyle", atname:"mathvariant", atval:"monospace", ttype:UNARY},
507 | {input:"\\texttt", tag:"mstyle", atname:"mathvariant", atval:"monospace", ttype:UNARY},
508 | {input:"\\mathsf", tag:"mstyle", atname:"mathvariant", atval:"sans-serif", ttype:UNARY},
509 | {input:"\\mathbb", tag:"mstyle", atname:"mathvariant", atval:"double-struck", ttype:UNARY, codes:AMbbb},
510 | {input:"\\mathcal",tag:"mstyle", atname:"mathvariant", atval:"script", ttype:UNARY, codes:AMcal},
511 | {input:"\\mathfrak",tag:"mstyle",atname:"mathvariant", atval:"fraktur",ttype:UNARY, codes:AMfrk}
512 | ];
513 |
514 | function compareNames(s1,s2) {
515 | if (s1.input > s2.input) return 1
516 | else return -1;
517 | }
518 |
519 | var AMnames = []; //list of input symbols
520 |
521 | function AMinitSymbols() {
522 | AMsymbols.sort(compareNames);
523 | for (i=0; i=n where str appears or would be inserted
556 | // assumes arr is sorted
557 | if (n==0) {
558 | var h,m;
559 | n = -1;
560 | h = arr.length;
561 | while (n+1> 1;
563 | if (arr[m]=str
569 | }
570 |
571 | function AMgetSymbol(str) {
572 | //return maximal initial substring of str that appears in names
573 | //return null if there is none
574 | var k = 0; //new pos
575 | var j = 0; //old pos
576 | var mk; //match pos
577 | var st;
578 | var tagst;
579 | var match = "";
580 | var more = true;
581 | for (var i=1; i<=str.length && more; i++) {
582 | st = str.slice(0,i); //initial substring of length i
583 | j = k;
584 | k = AMposition(AMnames, st, j);
585 | if (k=AMnames[k];
591 | }
592 | AMpreviousSymbol=AMcurrentSymbol;
593 | if (match!=""){
594 | AMcurrentSymbol=AMsymbols[mk].ttype;
595 | return AMsymbols[mk];
596 | }
597 | AMcurrentSymbol=CONST;
598 | k = 1;
599 | st = str.slice(0,1); //take 1 character
600 | if ("0"<=st && st<="9") tagst = "mn";
601 | else tagst = (("A">st || st>"Z") && ("a">st || st>"z")?"mo":"mi");
602 | /*
603 | // Commented out by DRW (not fully understood, but probably to do with
604 | // use of "/" as an INFIX version of "\\frac", which we don't want):
605 | //}
606 | //if (st=="-" && AMpreviousSymbol==INFIX) {
607 | // AMcurrentSymbol = INFIX; //trick "/" into recognizing "-" on second parse
608 | // return {input:st, tag:tagst, output:st, ttype:UNARY, func:true};
609 | //}
610 | */
611 | return {input:st, tag:tagst, output:st, ttype:CONST};
612 | }
613 |
614 |
615 | /*Parsing ASCII math expressions with the following grammar
616 | v ::= [A-Za-z] | greek letters | numbers | other constant symbols
617 | u ::= sqrt | text | bb | other unary symbols for font commands
618 | b ::= frac | root | stackrel binary symbols
619 | l ::= { | \left left brackets
620 | r ::= } | \right right brackets
621 | S ::= v | lEr | uS | bSS Simple expression
622 | I ::= S_S | S^S | S_S^S | S Intermediate expression
623 | E ::= IE | I/I Expression
624 | Each terminal symbol is translated into a corresponding mathml node.*/
625 |
626 | var AMpreviousSymbol,AMcurrentSymbol;
627 |
628 | function AMparseSexpr(str) { //parses str and returns [node,tailstr,(node)tag]
629 | var symbol, node, result, result2, i, st,// rightvert = false,
630 | newFrag = document.createDocumentFragment();
631 | str = AMremoveCharsAndBlanks(str,0);
632 | symbol = AMgetSymbol(str); //either a token or a bracket or empty
633 | if (symbol == null || symbol.ttype == RIGHTBRACKET)
634 | return [null,str,null];
635 | if (symbol.ttype == DEFINITION) {
636 | str = symbol.output+AMremoveCharsAndBlanks(str,symbol.input.length);
637 | symbol = AMgetSymbol(str);
638 | if (symbol == null || symbol.ttype == RIGHTBRACKET)
639 | return [null,str,null];
640 | }
641 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
642 | switch (symbol.ttype) {
643 | case SPACE:
644 | node = AMcreateElementMathML(symbol.tag);
645 | node.setAttribute(symbol.atname,symbol.atval);
646 | return [node,str,symbol.tag];
647 | case UNDEROVER:
648 | if (isIE) {
649 | if (symbol.input.substr(0,4) == "\\big") { // botch for missing symbols
650 | str = "\\"+symbol.input.substr(4)+str; // make \bigcup = \cup etc.
651 | symbol = AMgetSymbol(str);
652 | symbol.ttype = UNDEROVER;
653 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
654 | }
655 | }
656 | return [AMcreateMmlNode(symbol.tag,
657 | document.createTextNode(symbol.output)),str,symbol.tag];
658 | case CONST:
659 | var output = symbol.output;
660 | if (isIE) {
661 | if (symbol.input == "'")
662 | output = "\u2032";
663 | else if (symbol.input == "''")
664 | output = "\u2033";
665 | else if (symbol.input == "'''")
666 | output = "\u2033\u2032";
667 | else if (symbol.input == "''''")
668 | output = "\u2033\u2033";
669 | else if (symbol.input == "\\square")
670 | output = "\u25A1"; // same as \Box
671 | else if (symbol.input.substr(0,5) == "\\frac") {
672 | // botch for missing fractions
673 | var denom = symbol.input.substr(6,1);
674 | if (denom == "5" || denom == "6") {
675 | str = symbol.input.replace(/\\frac/,"\\frac ")+str;
676 | return [node,str,symbol.tag];
677 | }
678 | }
679 | }
680 | node = AMcreateMmlNode(symbol.tag,document.createTextNode(output));
681 | return [node,str,symbol.tag];
682 | case LONG: // added by DRW
683 | node = AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));
684 | node.setAttribute("minsize","1.5");
685 | node.setAttribute("maxsize","1.5");
686 | node = AMcreateMmlNode("mover",node);
687 | node.appendChild(AMcreateElementMathML("mspace"));
688 | return [node,str,symbol.tag];
689 | case STRETCHY: // added by DRW
690 | if (isIE && symbol.input == "\\backslash")
691 | symbol.output = "\\"; // doesn't expand, but then nor does "\u2216"
692 | node = AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));
693 | if (symbol.input == "|" || symbol.input == "\\vert" ||
694 | symbol.input == "\\|" || symbol.input == "\\Vert") {
695 | node.setAttribute("lspace","0em");
696 | node.setAttribute("rspace","0em");
697 | }
698 | node.setAttribute("maxsize",symbol.atval); // don't allow to stretch here
699 | if (symbol.rtag != null)
700 | return [node,str,symbol.rtag];
701 | else
702 | return [node,str,symbol.tag];
703 | case BIG: // added by DRW
704 | var atval = symbol.atval;
705 | if (isIE)
706 | atval = symbol.ieval;
707 | symbol = AMgetSymbol(str);
708 | if (symbol == null)
709 | return [null,str,null];
710 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
711 | node = AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));
712 | if (isIE) { // to get brackets to expand
713 | var space = AMcreateElementMathML("mspace");
714 | space.setAttribute("height",atval+"ex");
715 | node = AMcreateMmlNode("mrow",node);
716 | node.appendChild(space);
717 | } else { // ignored in IE
718 | node.setAttribute("minsize",atval);
719 | node.setAttribute("maxsize",atval);
720 | }
721 | return [node,str,symbol.tag];
722 | case LEFTBRACKET: //read (expr+)
723 | if (symbol.input == "\\left") { // left what?
724 | symbol = AMgetSymbol(str);
725 | if (symbol != null) {
726 | if (symbol.input == ".")
727 | symbol.invisible = true;
728 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
729 | }
730 | }
731 | result = AMparseExpr(str,true,false);
732 | if (symbol==null ||
733 | (typeof symbol.invisible == "boolean" && symbol.invisible))
734 | node = AMcreateMmlNode("mrow",result[0]);
735 | else {
736 | node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
737 | node = AMcreateMmlNode("mrow",node);
738 | node.appendChild(result[0]);
739 | }
740 | return [node,result[1],result[2]];
741 | case MATRIX: //read (expr+)
742 | if (symbol.input == "\\begin{array}") {
743 | var mask = "";
744 | symbol = AMgetSymbol(str);
745 | str = AMremoveCharsAndBlanks(str,0);
746 | if (symbol == null)
747 | mask = "l";
748 | else {
749 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
750 | if (symbol.input != "{")
751 | mask = "l";
752 | else do {
753 | symbol = AMgetSymbol(str);
754 | if (symbol != null) {
755 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
756 | if (symbol.input != "}")
757 | mask = mask+symbol.input;
758 | }
759 | } while (symbol != null && symbol.input != "" && symbol.input != "}");
760 | }
761 | result = AMparseExpr("{"+str,true,true);
762 | // if (result[0]==null) return [AMcreateMmlNode("mo",
763 | // document.createTextNode(symbol.input)),str];
764 | node = AMcreateMmlNode("mtable",result[0]);
765 | mask = mask.replace(/l/g,"left ");
766 | mask = mask.replace(/r/g,"right ");
767 | mask = mask.replace(/c/g,"center ");
768 | node.setAttribute("columnalign",mask);
769 | node.setAttribute("displaystyle","false");
770 | if (isIE)
771 | return [node,result[1],null];
772 | // trying to get a *little* bit of space around the array
773 | // (IE already includes it)
774 | var lspace = AMcreateElementMathML("mspace");
775 | lspace.setAttribute("width","0.167em");
776 | var rspace = AMcreateElementMathML("mspace");
777 | rspace.setAttribute("width","0.167em");
778 | var node1 = AMcreateMmlNode("mrow",lspace);
779 | node1.appendChild(node);
780 | node1.appendChild(rspace);
781 | return [node1,result[1],null];
782 | } else { // eqnarray
783 | result = AMparseExpr("{"+str,true,true);
784 | node = AMcreateMmlNode("mtable",result[0]);
785 | if (isIE)
786 | node.setAttribute("columnspacing","0.25em"); // best in practice?
787 | else
788 | node.setAttribute("columnspacing","0.167em"); // correct (but ignored?)
789 | node.setAttribute("columnalign","right center left");
790 | node.setAttribute("displaystyle","true");
791 | node = AMcreateMmlNode("mrow",node);
792 | return [node,result[1],null];
793 | }
794 | case TEXT:
795 | if (str.charAt(0)=="{") i=str.indexOf("}");
796 | else i = 0;
797 | if (i==-1)
798 | i = str.length;
799 | st = str.slice(1,i);
800 | if (st.charAt(0) == " ") {
801 | node = AMcreateElementMathML("mspace");
802 | node.setAttribute("width","0.33em"); // was 1ex
803 | newFrag.appendChild(node);
804 | }
805 | newFrag.appendChild(
806 | AMcreateMmlNode(symbol.tag,document.createTextNode(st)));
807 | if (st.charAt(st.length-1) == " ") {
808 | node = AMcreateElementMathML("mspace");
809 | node.setAttribute("width","0.33em"); // was 1ex
810 | newFrag.appendChild(node);
811 | }
812 | str = AMremoveCharsAndBlanks(str,i+1);
813 | return [AMcreateMmlNode("mrow",newFrag),str,null];
814 | case UNARY:
815 | result = AMparseSexpr(str);
816 | if (result[0]==null) return [AMcreateMmlNode(symbol.tag,
817 | document.createTextNode(symbol.output)),str];
818 | if (typeof symbol.func == "boolean" && symbol.func) { // functions hack
819 | st = str.charAt(0);
820 | // if (st=="^" || st=="_" || st=="/" || st=="|" || st==",") {
821 | if (st=="^" || st=="_" || st==",") {
822 | return [AMcreateMmlNode(symbol.tag,
823 | document.createTextNode(symbol.output)),str,symbol.tag];
824 | } else {
825 | node = AMcreateMmlNode("mrow",
826 | AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));
827 | if (isIE) {
828 | var space = AMcreateElementMathML("mspace");
829 | space.setAttribute("width","0.167em");
830 | node.appendChild(space);
831 | }
832 | node.appendChild(result[0]);
833 | return [node,result[1],symbol.tag];
834 | }
835 | }
836 | if (symbol.input == "\\sqrt") { // sqrt
837 | if (isIE) { // set minsize, for \surd
838 | var space = AMcreateElementMathML("mspace");
839 | space.setAttribute("height","1.2ex");
840 | space.setAttribute("width","0em"); // probably no effect
841 | node = AMcreateMmlNode(symbol.tag,result[0])
842 | // node.setAttribute("minsize","1"); // ignored
843 | // node = AMcreateMmlNode("mrow",node); // hopefully unnecessary
844 | node.appendChild(space);
845 | return [node,result[1],symbol.tag];
846 | } else
847 | return [AMcreateMmlNode(symbol.tag,result[0]),result[1],symbol.tag];
848 | } else if (typeof symbol.acc == "boolean" && symbol.acc) { // accent
849 | node = AMcreateMmlNode(symbol.tag,result[0]);
850 | var output = symbol.output;
851 | if (isIE) {
852 | if (symbol.input == "\\hat")
853 | output = "\u0302";
854 | else if (symbol.input == "\\widehat")
855 | output = "\u005E";
856 | else if (symbol.input == "\\bar")
857 | output = "\u00AF";
858 | else if (symbol.input == "\\grave")
859 | output = "\u0300";
860 | else if (symbol.input == "\\tilde")
861 | output = "\u0303";
862 | }
863 | var node1 = AMcreateMmlNode("mo",document.createTextNode(output));
864 | if (symbol.input == "\\vec" || symbol.input == "\\check")
865 | // don't allow to stretch
866 | node1.setAttribute("maxsize","1.2");
867 | // why doesn't "1" work? \vec nearly disappears in firefox
868 | if (isIE && symbol.input == "\\bar")
869 | node1.setAttribute("maxsize","0.5");
870 | if (symbol.input == "\\underbrace" || symbol.input == "\\underline")
871 | node1.setAttribute("accentunder","true");
872 | else
873 | node1.setAttribute("accent","true");
874 | node.appendChild(node1);
875 | if (symbol.input == "\\overbrace" || symbol.input == "\\underbrace")
876 | node.ttype = UNDEROVER;
877 | return [node,result[1],symbol.tag];
878 | } else { // font change or displaystyle command
879 | if (!isIE && typeof symbol.codes != "undefined") {
880 | for (i=0; i64 && st.charCodeAt(j)<91) newst = newst +
887 | String.fromCharCode(symbol.codes[st.charCodeAt(j)-65]);
888 | else newst = newst + st.charAt(j);
889 | if (result[0].nodeName=="mi")
890 | result[0]=AMcreateElementMathML("mo").
891 | appendChild(document.createTextNode(newst));
892 | else result[0].replaceChild(AMcreateElementMathML("mo").
893 | appendChild(document.createTextNode(newst)),result[0].childNodes[i]);
894 | }
895 | }
896 | node = AMcreateMmlNode(symbol.tag,result[0]);
897 | node.setAttribute(symbol.atname,symbol.atval);
898 | if (symbol.input == "\\scriptstyle" ||
899 | symbol.input == "\\scriptscriptstyle")
900 | node.setAttribute("displaystyle","false");
901 | return [node,result[1],symbol.tag];
902 | }
903 | case BINARY:
904 | result = AMparseSexpr(str);
905 | if (result[0]==null) return [AMcreateMmlNode("mo",
906 | document.createTextNode(symbol.input)),str,null];
907 | result2 = AMparseSexpr(result[1]);
908 | if (result2[0]==null) return [AMcreateMmlNode("mo",
909 | document.createTextNode(symbol.input)),str,null];
910 | if (symbol.input=="\\root" || symbol.input=="\\stackrel")
911 | newFrag.appendChild(result2[0]);
912 | newFrag.appendChild(result[0]);
913 | if (symbol.input=="\\frac") newFrag.appendChild(result2[0]);
914 | return [AMcreateMmlNode(symbol.tag,newFrag),result2[1],symbol.tag];
915 | case INFIX:
916 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
917 | return [AMcreateMmlNode("mo",document.createTextNode(symbol.output)),
918 | str,symbol.tag];
919 | default:
920 | return [AMcreateMmlNode(symbol.tag, //its a constant
921 | document.createTextNode(symbol.output)),str,symbol.tag];
922 | }
923 | }
924 |
925 | function AMparseIexpr(str) {
926 | var symbol, sym1, sym2, node, result, tag, underover;
927 | str = AMremoveCharsAndBlanks(str,0);
928 | sym1 = AMgetSymbol(str);
929 | result = AMparseSexpr(str);
930 | node = result[0];
931 | str = result[1];
932 | tag = result[2];
933 | symbol = AMgetSymbol(str);
934 | if (symbol.ttype == INFIX) {
935 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
936 | result = AMparseSexpr(str);
937 | if (result[0] == null) // show box in place of missing argument
938 | result[0] = AMcreateMmlNode("mo",document.createTextNode("\u25A1"));
939 | str = result[1];
940 | tag = result[2];
941 | if (symbol.input == "_" || symbol.input == "^") {
942 | sym2 = AMgetSymbol(str);
943 | tag = null; // no space between x^2 and a following sin, cos, etc.
944 | // This is for \underbrace and \overbrace
945 | underover = ((sym1.ttype == UNDEROVER) || (node.ttype == UNDEROVER));
946 | // underover = (sym1.ttype == UNDEROVER);
947 | if (symbol.input == "_" && sym2.input == "^") {
948 | str = AMremoveCharsAndBlanks(str,sym2.input.length);
949 | var res2 = AMparseSexpr(str);
950 | str = res2[1];
951 | tag = res2[2]; // leave space between x_1^2 and a following sin etc.
952 | node = AMcreateMmlNode((underover?"munderover":"msubsup"),node);
953 | node.appendChild(result[0]);
954 | node.appendChild(res2[0]);
955 | } else if (symbol.input == "_") {
956 | node = AMcreateMmlNode((underover?"munder":"msub"),node);
957 | node.appendChild(result[0]);
958 | } else {
959 | node = AMcreateMmlNode((underover?"mover":"msup"),node);
960 | node.appendChild(result[0]);
961 | }
962 | node = AMcreateMmlNode("mrow",node); // so sum does not stretch
963 | } else {
964 | node = AMcreateMmlNode(symbol.tag,node);
965 | if (symbol.input == "\\atop" || symbol.input == "\\choose")
966 | node.setAttribute("linethickness","0ex");
967 | node.appendChild(result[0]);
968 | if (symbol.input == "\\choose")
969 | node = AMcreateMmlNode("mfenced",node);
970 | }
971 | }
972 | return [node,str,tag];
973 | }
974 |
975 | function AMparseExpr(str,rightbracket,matrix) {
976 | var symbol, node, result, i, tag,
977 | newFrag = document.createDocumentFragment();
978 | do {
979 | str = AMremoveCharsAndBlanks(str,0);
980 | result = AMparseIexpr(str);
981 | node = result[0];
982 | str = result[1];
983 | tag = result[2];
984 | symbol = AMgetSymbol(str);
985 | if (node!=undefined) {
986 | if ((tag == "mn" || tag == "mi") && symbol!=null &&
987 | typeof symbol.func == "boolean" && symbol.func) {
988 | // Add space before \sin in 2\sin x or x\sin x
989 | var space = AMcreateElementMathML("mspace");
990 | space.setAttribute("width","0.167em");
991 | node = AMcreateMmlNode("mrow",node);
992 | node.appendChild(space);
993 | }
994 | newFrag.appendChild(node);
995 | }
996 | } while ((symbol.ttype != RIGHTBRACKET)
997 | && symbol!=null && symbol.output!="");
998 | tag = null;
999 | if (symbol.ttype == RIGHTBRACKET) {
1000 | if (symbol.input == "\\right") { // right what?
1001 | str = AMremoveCharsAndBlanks(str,symbol.input.length);
1002 | symbol = AMgetSymbol(str);
1003 | if (symbol != null && symbol.input == ".")
1004 | symbol.invisible = true;
1005 | if (symbol != null)
1006 | tag = symbol.rtag;
1007 | }
1008 | if (symbol!=null)
1009 | str = AMremoveCharsAndBlanks(str,symbol.input.length); // ready to return
1010 | var len = newFrag.childNodes.length;
1011 | if (matrix &&
1012 | len>0 && newFrag.childNodes[len-1].nodeName == "mrow" && len>1 &&
1013 | newFrag.childNodes[len-2].nodeName == "mo" &&
1014 | newFrag.childNodes[len-2].firstChild.nodeValue == "&") { //matrix
1015 | var pos = []; // positions of ampersands
1016 | var m = newFrag.childNodes.length;
1017 | for (i=0; matrix && i -&-&...&-&-
1029 | n = node.childNodes.length;
1030 | k = 0;
1031 | for (j=0; j2) {
1040 | newFrag.removeChild(newFrag.firstChild); //remove
1041 | newFrag.removeChild(newFrag.firstChild); //remove &
1042 | }
1043 | table.appendChild(AMcreateMmlNode("mtr",row));
1044 | }
1045 | return [table,str];
1046 | }
1047 | if (typeof symbol.invisible != "boolean" || !symbol.invisible) {
1048 | node = AMcreateMmlNode("mo",document.createTextNode(symbol.output));
1049 | newFrag.appendChild(node);
1050 | }
1051 | }
1052 | return [newFrag,str,tag];
1053 | }
1054 |
1055 | function AMparseMath(str) {
1056 | var result, node = AMcreateElementMathML("mstyle");
1057 | if (mathcolor != "") node.setAttribute("mathcolor",mathcolor);
1058 | if (mathfontfamily != "") node.setAttribute("fontfamily",mathfontfamily);
1059 | node.appendChild(AMparseExpr(str.replace(/^\s+/g,""),false,false)[0]);
1060 | node = AMcreateMmlNode("math",node);
1061 | if (showasciiformulaonhover) //fixed by djhsu so newline
1062 | node.setAttribute("title",str.replace(/\s+/g," "));//does not show in Gecko
1063 | if (mathfontfamily != "" && (isIE || mathfontfamily != "serif")) {
1064 | var fnode = AMcreateElementXHTML("font");
1065 | fnode.setAttribute("face",mathfontfamily);
1066 | fnode.appendChild(node);
1067 | return fnode;
1068 | }
1069 | return node;
1070 | }
1071 |
1072 | function AMstrarr2docFrag(arr, linebreaks) {
1073 | var newFrag=document.createDocumentFragment();
1074 | var expr = false;
1075 | for (var i=0; i1 || mtch) {
1112 | if (checkForMathML) {
1113 | checkForMathML = false;
1114 | var nd = AMisMathMLavailable();
1115 | AMnoMathML = nd != null;
1116 | if (AMnoMathML && notifyIfNoMathML)
1117 | if (alertIfNoMathML)
1118 | alert("To view the ASCIIMathML notation use Internet Explorer 6 +\nMathPlayer (free from www.dessci.com)\n\
1119 | or Firefox/Mozilla/Netscape");
1120 | else AMbody.insertBefore(nd,AMbody.childNodes[0]);
1121 | }
1122 | if (!AMnoMathML) {
1123 | frg = AMstrarr2docFrag(arr,n.nodeType==8);
1124 | var len = frg.childNodes.length;
1125 | n.parentNode.replaceChild(frg,n);
1126 | return len-1;
1127 | } else return 0;
1128 | }
1129 | }
1130 | } else return 0;
1131 | } else if (n.nodeName!="math") {
1132 | for (i=0; i");
1174 | document.write("");
1175 | }
1176 |
1177 | // GO1.1 Generic onload by Brothercake
1178 | // http://www.brothercake.com/
1179 | //onload function (replaces the onload="translate()" in the tag)
1180 | function generic()
1181 | {
1182 | translate();
1183 | };
1184 | //setup onload function
1185 | if(typeof window.addEventListener != 'undefined')
1186 | {
1187 | //.. gecko, safari, konqueror and standard
1188 | window.addEventListener('load', generic, false);
1189 | }
1190 | else if(typeof document.addEventListener != 'undefined')
1191 | {
1192 | //.. opera 7
1193 | document.addEventListener('load', generic, false);
1194 | }
1195 | else if(typeof window.attachEvent != 'undefined')
1196 | {
1197 | //.. win/ie
1198 | window.attachEvent('onload', generic);
1199 | }
1200 | //** remove this condition to degrade older browsers
1201 | else
1202 | {
1203 | //.. mac/ie5 and anything else that gets this far
1204 | //if there's an existing onload function
1205 | if(typeof window.onload == 'function')
1206 | {
1207 | //store it
1208 | var existing = onload;
1209 | //add new onload handler
1210 | window.onload = function()
1211 | {
1212 | //call existing onload function
1213 | existing();
1214 | //call generic onload function
1215 | generic();
1216 | };
1217 | }
1218 | else
1219 | {
1220 | //setup onload function
1221 | window.onload = generic;
1222 | }
1223 | }
1224 |
--------------------------------------------------------------------------------
/js/asciidoc.js:
--------------------------------------------------------------------------------
1 | var asciidoc = { // Namespace.
2 |
3 | /////////////////////////////////////////////////////////////////////
4 | // Table Of Contents generator
5 | /////////////////////////////////////////////////////////////////////
6 |
7 | /* Author: Mihai Bazon, September 2002
8 | * http://students.infoiasi.ro/~mishoo
9 | *
10 | * Table Of Content generator
11 | * Version: 0.4
12 | *
13 | * Feel free to use this script under the terms of the GNU General Public
14 | * License, as long as you do not remove or alter this notice.
15 | */
16 |
17 | /* modified by Troy D. Hanson, September 2006. License: GPL */
18 | /* modified by Stuart Rackham, 2006, 2009. License: GPL */
19 |
20 | // toclevels = 1..4.
21 | toc: function (toclevels) {
22 |
23 | function getText(el) {
24 | var text = "";
25 | for (var i = el.firstChild; i != null; i = i.nextSibling) {
26 | if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
27 | text += i.data;
28 | else if (i.firstChild != null)
29 | text += getText(i);
30 | }
31 | return text;
32 | }
33 |
34 | function TocEntry(el, text, toclevel) {
35 | this.element = el;
36 | this.text = text;
37 | this.toclevel = toclevel;
38 | }
39 |
40 | function tocEntries(el, toclevels) {
41 | var result = new Array;
42 | var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
43 | // Function that scans the DOM tree for header elements (the DOM2
44 | // nodeIterator API would be a better technique but not supported by all
45 | // browsers).
46 | var iterate = function (el) {
47 | for (var i = el.firstChild; i != null; i = i.nextSibling) {
48 | if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
49 | var mo = re.exec(i.tagName);
50 | if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
51 | result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
52 | }
53 | iterate(i);
54 | }
55 | }
56 | }
57 | iterate(el);
58 | return result;
59 | }
60 |
61 | var toc = document.getElementById("toc");
62 | if (!toc) {
63 | return;
64 | }
65 |
66 | // Delete existing TOC entries in case we're reloading the TOC.
67 | var tocEntriesToRemove = [];
68 | var i;
69 | for (i = 0; i < toc.childNodes.length; i++) {
70 | var entry = toc.childNodes[i];
71 | if (entry.nodeName.toLowerCase() == 'div'
72 | && entry.getAttribute("class")
73 | && entry.getAttribute("class").match(/^toclevel/))
74 | tocEntriesToRemove.push(entry);
75 | }
76 | for (i = 0; i < tocEntriesToRemove.length; i++) {
77 | toc.removeChild(tocEntriesToRemove[i]);
78 | }
79 |
80 | // Rebuild TOC entries.
81 | var entries = tocEntries(document.getElementById("content"), toclevels);
82 | for (var i = 0; i < entries.length; ++i) {
83 | var entry = entries[i];
84 | if (entry.element.id == "")
85 | entry.element.id = "_toc_" + i;
86 | var a = document.createElement("a");
87 | a.href = "#" + entry.element.id;
88 | a.appendChild(document.createTextNode(entry.text));
89 | var div = document.createElement("div");
90 | div.appendChild(a);
91 | div.className = "toclevel" + entry.toclevel;
92 | toc.appendChild(div);
93 | }
94 | if (entries.length == 0)
95 | toc.parentNode.removeChild(toc);
96 | },
97 |
98 |
99 | /////////////////////////////////////////////////////////////////////
100 | // Footnotes generator
101 | /////////////////////////////////////////////////////////////////////
102 |
103 | /* Based on footnote generation code from:
104 | * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
105 | */
106 |
107 | footnotes: function () {
108 | // Delete existing footnote entries in case we're reloading the footnodes.
109 | var i;
110 | var noteholder = document.getElementById("footnotes");
111 | if (!noteholder) {
112 | return;
113 | }
114 | var entriesToRemove = [];
115 | for (i = 0; i < noteholder.childNodes.length; i++) {
116 | var entry = noteholder.childNodes[i];
117 | if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
118 | entriesToRemove.push(entry);
119 | }
120 | for (i = 0; i < entriesToRemove.length; i++) {
121 | noteholder.removeChild(entriesToRemove[i]);
122 | }
123 |
124 | // Rebuild footnote entries.
125 | var cont = document.getElementById("content");
126 | var spans = cont.getElementsByTagName("span");
127 | var refs = {};
128 | var n = 0;
129 | for (i=0; i