Skip to content

Mathml and epub : missing xmlns and xml-annotation #345

Open
@artragis

Description

@artragis

When we process math with KaTeX for epub we output something like this :

<span class="inlineMath">
      <span class="katex">
       <span class="katex-mathml">
        <math>
         <semantics>
          <mrow>
           <mfrac>
            <mrow>
             <mi>
              N
             </mi>
             <mo>
              ×
             </mo>
             <mo>
              (
             </mo>
             <mi>
              N
             </mi>
             <mo>
              +
             </mo>
             <mn>
              1
             </mn>
             <mo>
              )
             </mo>
            </mrow>
            <mn>
             2
            </mn>
           </mfrac>
          </mrow>
          <annotation>
           \frac {N \times (N+1)} {2}
          </annotation>
         </semantics>
        </math>
       </span>
       <span class="katex-html">
        <span class="base">
         <span class="strut" style="height:1.355em;vertical-align:-0.345em;">
         </span>
         <span class="mord">
          <span class="mopen nulldelimiter">
          </span>
          <span class="mfrac">
           <span class="vlist-t vlist-t2">
            <span class="vlist-r">
             <span class="vlist" style="height:1.01em;">
              <span style="top:-2.6550000000000002em;">
               <span class="pstrut" style="height:3em;">
               </span>
               <span class="sizing reset-size6 size3 mtight">
                <span class="mord mtight">
                 <span class="mord mtight">
                  2
                 </span>
                </span>
               </span>
              </span>
              <span style="top:-3.23em;">
               <span class="pstrut" style="height:3em;">
               </span>
               <span class="frac-line" style="border-bottom-width:0.04em;">
               </span>
              </span>
              <span style="top:-3.485em;">
               <span class="pstrut" style="height:3em;">
               </span>
               <span class="sizing reset-size6 size3 mtight">
                <span class="mord mtight">
                 <span class="mord mathdefault mtight" style="margin-right:0.10903em;">
                  N
                 </span>
                 <span class="mbin mtight">
                  ×
                 </span>
                 <span class="mopen mtight">
                  (
                 </span>
                 <span class="mord mathdefault mtight" style="margin-right:0.10903em;">
                  N
                 </span>
                 <span class="mbin mtight">
                  +
                 </span>
                 <span class="mord mtight">
                  1
                 </span>
                 <span class="mclose mtight">
                  )
                 </span>
                </span>
               </span>
              </span>
             </span>
             <span class="vlist-s"></span>
            </span>
            <span class="vlist-r">
             <span class="vlist" style="height:0.345em;">
              <span>
              </span>
             </span>
            </span>
           </span>
          </span>
          <span class="mclose nulldelimiter">
          </span>
         </span>
        </span>
       </span>
      </span>
     </span>

For epub, the interresting part is only

 <span class="katex-mathml">
        <math>
         <semantics>
          <mrow>
           <mfrac>
            <mrow>
             <mi>
              N
             </mi>
             <mo>
              ×
             </mo>
             <mo>
              (
             </mo>
             <mi>
              N
             </mi>
             <mo>
              +
             </mo>
             <mn>
              1
             </mn>
             <mo>
              )
             </mo>
            </mrow>
            <mn>
             2
            </mn>
           </mfrac>
          </mrow>
          <annotation>
           \frac {N \times (N+1)} {2}
          </annotation>
         </semantics>
        </math>
       </span>

The problem is :

  • the math tag is missing xmlns="http://www.w3.org/1998/Math/MathML" attribute (not mandatory, most of readers include it automaticaly
  • the <semantics> tags is missing a xml-annotation element like specified here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked/upstreamAwaiting for upstream changessemver/minorThis is a backward-compatible changestatus/verifiedThis has been checked by a maintainertype/requestThis is great to have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions