|
332 | 332 | },
|
333 | 333 | ".MathJax_Processed": {display:"none!important"},
|
334 | 334 |
|
335 |
| - ".MathJax_ExBox": { |
336 |
| - display:"block!important", overflow:"hidden", |
337 |
| - width:"1px", height:"60ex", |
338 |
| - "min-height": 0, "max-height":"none" |
339 |
| - }, |
340 |
| - ".MathJax .MathJax_EmBox": { |
341 |
| - display:"block!important", overflow:"hidden", |
342 |
| - width:"1px", height:"60em", |
343 |
| - "min-height": 0, "max-height":"none" |
| 335 | + ".MathJax_test": { |
| 336 | + "font-style": "normal", |
| 337 | + "font-weight": "normal", |
| 338 | + "font-size": "100%", |
| 339 | + "font-size-adjust":"none", |
| 340 | + "text-indent": 0, |
| 341 | + "text-transform": "none", |
| 342 | + "letter-spacing": "normal", |
| 343 | + "word-spacing": "normal", |
| 344 | + overflow: "hidden", |
| 345 | + height: "1px" |
344 | 346 | },
|
345 |
| - ".MathJax_LineBox": { |
| 347 | + ".MathJax_test.mjx-test-display": { |
346 | 348 | display: (oldIE ? "block" : "table") + "!important"
|
347 | 349 | },
|
348 |
| - ".MathJax_LineBox span": { |
| 350 | + ".MathJax_test.mjx-test-inline": { |
| 351 | + display: "inline!important", |
| 352 | + "margin-right": "-1px" |
| 353 | + }, |
| 354 | + ".MathJax_test.mjx-test-default": { |
| 355 | + display: "block!important", |
| 356 | + clear: "both" |
| 357 | + }, |
| 358 | + ".MathJax_ex_box": { |
| 359 | + display: "inline-block!important", |
| 360 | + position: "absolute", |
| 361 | + overflow: "hidden", |
| 362 | + "min-height": 0, "max-height":"none", |
| 363 | + padding:0, border: 0, margin: 0, |
| 364 | + width:"1px", height:"60ex" |
| 365 | + }, |
| 366 | + ".MathJax_em_box": { |
| 367 | + display: "inline-block!important", |
| 368 | + position: "absolute", |
| 369 | + overflow: "hidden", |
| 370 | + "min-height": 0, "max-height":"none", |
| 371 | + padding:0, border: 0, margin: 0, |
| 372 | + width:"1px", height:"60em" |
| 373 | + }, |
| 374 | + ".mjx-test-inline .MathJax_left_box": { |
| 375 | + display: "inline-block", |
| 376 | + width: 0, |
| 377 | + float:"left" |
| 378 | + }, |
| 379 | + ".mjx-test-inline .MathJax_right_box": { |
| 380 | + display: "inline-block", |
| 381 | + width: 0, |
| 382 | + float:"right" |
| 383 | + }, |
| 384 | + ".mjx-test-display .MathJax_right_box": { |
349 | 385 | display: (oldIE ? "block" : "table-cell") + "!important",
|
350 | 386 | width: (oldIE ? "100%" : "10000em") + "!important",
|
351 | 387 | "min-width":0, "max-width":"none",
|
352 | 388 | padding:0, border:0, margin:0
|
353 | 389 | },
|
354 |
| - |
| 390 | + |
355 | 391 | ".MathJax .MathJax_HitBox": {
|
356 | 392 | cursor: "text",
|
357 | 393 | background: "white",
|
|
491 | 527 | }
|
492 | 528 |
|
493 | 529 | // Used in preTranslate to get scaling factors
|
494 |
| - this.EmExSpan = this.Element("span", |
495 |
| - {style:{position:"absolute","font-size-adjust":"none"}}, |
| 530 | + this.TestSpan = this.Element("span", |
| 531 | + {className:"MathJax_test"}, |
496 | 532 | [
|
497 |
| - ["span",{className:"MathJax_ExBox"}], |
498 |
| - ["span",{className:"MathJax"}, |
499 |
| - [["span",{className:"MathJax_EmBox"}]] |
500 |
| - ] |
| 533 | + ["span",{className:"MathJax_left_box"}], |
| 534 | + ["span",{className:"MathJax_ex_box"}], |
| 535 | + ["span",{className:"MathJax_em_box"}], |
| 536 | + ["span",{className:"MathJax_right_box"}] |
501 | 537 | ]
|
502 | 538 | );
|
503 | 539 |
|
504 |
| - // Used in preTranslate to get linebreak width |
505 |
| - this.linebreakSpan = MathJax.HTML.Element("span",{className:"MathJax_LineBox"},[["span"]]); |
506 |
| - |
507 | 540 | // Set up styles and preload web fonts
|
508 | 541 | return AJAX.Styles(this.config.styles,["InitializeHTML",this]);
|
509 | 542 | },
|
|
554 | 587 | //
|
555 | 588 | // Get the default sizes (need styles in place to do this)
|
556 | 589 | //
|
557 |
| - document.body.appendChild(this.EmExSpan); |
558 |
| - document.body.appendChild(this.linebreakSpan); |
559 |
| - this.defaultEx = this.EmExSpan.firstChild.offsetHeight/60; |
560 |
| - this.defaultEm = this.EmExSpan.lastChild.firstChild.offsetHeight/60; |
561 |
| - this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth; |
562 |
| - document.body.removeChild(this.linebreakSpan); |
563 |
| - document.body.removeChild(this.EmExSpan); |
| 590 | + var test = document.body.appendChild(this.TestSpan.cloneNode(true)); |
| 591 | + test.className += " mjx-test-inline mjx-test-default"; |
| 592 | + this.defaultEx = test.childNodes[1].offsetHeight/60; |
| 593 | + this.defaultEm = test.childNodes[2].offsetHeight/60; |
| 594 | + this.defaultWidth = Math.max(0,test.lastChild.offsetLeft-test.firstChild.offsetLeft-2); |
| 595 | + document.body.removeChild(test); |
564 | 596 | },
|
565 | 597 |
|
566 | 598 | preTranslate: function (state) {
|
|
614 | 646 | //
|
615 | 647 | // Add the test span for determining scales and linebreak widths
|
616 | 648 | //
|
617 |
| - script.parentNode.insertBefore(this.EmExSpan.cloneNode(true),script); |
618 |
| - div.parentNode.insertBefore(this.linebreakSpan.cloneNode(true),div) |
| 649 | + test = this.TestSpan.cloneNode(true); |
| 650 | + test.className += " mjx-test-" + (jax.HTMLCSS.display ? "display" : "inline"); |
| 651 | + script.parentNode.insertBefore(test,script); |
619 | 652 | }
|
620 | 653 | //
|
621 | 654 | // Determine the scaling factors for each script
|
|
628 | 661 | script = scripts[i]; if (!script.parentNode) continue;
|
629 | 662 | test = script.previousSibling; div = test.previousSibling;
|
630 | 663 | jax = script.MathJax.elementJax; if (!jax) continue;
|
631 |
| - ex = test.firstChild.offsetHeight/60; |
632 |
| - em = test.lastChild.firstChild.offsetHeight/60; |
633 |
| - cwidth = Math.max(0,div.previousSibling.firstChild.offsetWidth - 2); |
| 664 | + ex = test.childNodes[1].offsetHeight/60; |
| 665 | + em = test.childNodes[2].offsetHeight/60; |
| 666 | + cwidth = Math.max(0, jax.HTMLCSS.display ? test.lastChild.offsetWidth - 1: |
| 667 | + test.lastChild.offsetLeft - test.firstChild.offsetLeft - 2); |
634 | 668 | if (ex === 0 || ex === "NaN") {
|
635 | 669 | // can't read width, so move to hidden div for processing
|
636 | 670 | hidden.push(div);
|
637 | 671 | jax.HTMLCSS.isHidden = true;
|
638 | 672 | ex = this.defaultEx; em = this.defaultEm; cwidth = this.defaultWidth;
|
639 | 673 | }
|
| 674 | + if (cwidth === 0) cwidth = this.defaultWidth; |
640 | 675 | if (relwidth) {maxwidth = cwidth}
|
641 | 676 | scale = (this.config.matchFontHeight ? ex/this.TeX.x_height/em : 1);
|
642 | 677 | scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale)*this.config.scale);
|
|
654 | 689 | //
|
655 | 690 | for (i = 0; i < m; i++) {
|
656 | 691 | script = scripts[i]; if (!script.parentNode) continue;
|
657 |
| - test = scripts[i].previousSibling; |
658 | 692 | jax = scripts[i].MathJax.elementJax; if (!jax) continue;
|
659 |
| - span = test.previousSibling; |
660 |
| - if (!jax.HTMLCSS.isHidden) {span = span.previousSibling} |
661 |
| - span.parentNode.removeChild(span); |
662 |
| - test.parentNode.removeChild(test); |
| 693 | + script.parentNode.removeChild(script.previousSibling); |
663 | 694 | if (script.MathJax.preview) script.MathJax.preview.style.display = "";
|
664 | 695 | }
|
665 | 696 | //
|
|
0 commit comments