Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.
This repository was archived by the owner on May 7, 2025. It is now read-only.

MathJax SVG AuthorInit / StartupHook rendering bug #214

@danielweck

Description

@danielweck

See discussion:
https://groups.google.com/d/msg/readium-dev/lGWYDvSMwdY/Vqm9OQk0PjIJ

The proposed fix is to remove the "AuthorInit" section:
https://raw.githubusercontent.com/readium/readium-js-viewer/develop/lib/mathjax/MathJax.js

AuthorInit: function () { 
        MathJax.Hub.Register.StartupHook("SVG Jax Ready", function () { 
            var SVG = MathJax.OutputJax.SVG, GLYPH = SVG.BBOX.GLYPH; 
            GLYPH.Augment({ 
                Init: function (scale, id, h, d, w, l, r, p) { 
                    var t = SVG.config.blacker, 
                        def = {"stroke-width": t}; 
                    if (p !== "") { 
                        def.d = "M" + p + "Z" 
                    } 
                    if (scale !== 1) { 
                        def.transform = "scale(" + scale + ")" 
                    } 
                    this.SUPER(arguments).Init.call(this, def); 
                    this.h = (h + t) * scale; 
                    this.d = (d + t) * scale; 
                    this.w = (w + t / 2) * scale; 
                    this.l = (l + t / 2) * scale; 
                    this.r = (r + t / 2) * scale; 
                    this.H = Math.max(0, this.h); 
                    this.D = Math.max(0, this.d); 
                    this.x = this.y = 0; 
                    this.scale = scale; 
                } 
            }); 
        }); 
    } 

Before proposed fix:

readium_mathml_svg_before

After (seems to work fine):

readium_mathml_svg_after

To test, edit

readium-js-viewer/epub_content/linear-algebra/EPUB/xhtml/titlepage.html

and add:

        <div class="foreign mathml">
           <math xmlns="http://www.w3.org/1998/Math/MathML">
              <mstyle displaystyle="true">
                 <mrow>
                    <mrow>
                       <mo>{</mo>
                       <mtable>
                          <mtr>
                             <mtd columnalign="left">
                                <mrow>
                                   <msub>
                                      <mrow>
                                         <mi>t</mi>
                                      </mrow>
                                      <mrow>
                                         <msub>
                                            <mrow>
                                               <mi>S</mi>
                                            </mrow>
                                            <mrow>
                                               <mi>i</mi>
                                            </mrow>
                                         </msub>
                                      </mrow>
                                   </msub>
                                   <mo>=</mo>
                                   <msub>
                                      <mrow>
                                         <mi>t</mi>
                                      </mrow>
                                      <mrow>
                                         <msub>
                                            <mrow>
                                               <mi>th</mi>
                                            </mrow>
                                            <mrow>
                                               <mi>i</mi>
                                            </mrow>
                                         </msub>
                                      </mrow>
                                   </msub>
                                </mrow>
                             </mtd>
                          </mtr>
                          <mtr>
                             <mtd columnalign="left">
                                <mrow>
                                   <msub>
                                      <mrow>
                                         <mi>t</mi>
                                      </mrow>
                                      <mrow>
                                         <msub>
                                            <mrow>
                                               <mi>E</mi>
                                            </mrow>
                                            <mrow>
                                               <mi>i</mi>
                                            </mrow>
                                         </msub>
                                      </mrow>
                                   </msub>
                                   <mo>=</mo>
                                   <msub>
                                      <mrow>
                                         <mi>t</mi>
                                      </mrow>
                                      <mrow>
                                         <msub>
                                            <mrow>
                                               <mi>th</mi>
                                            </mrow>
                                            <mrow>
                                               <mi>i</mi>
                                               <mo>+</mo>
                                               <mn>1</mn>
                                            </mrow>
                                         </msub>
                                      </mrow>
                                   </msub>
                                </mrow>
                             </mtd>
                          </mtr>
                       </mtable>
                       <mo> </mo>
                    </mrow>
                 </mrow>
              </mstyle>
           </math>
        </div>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions