zmarkdown icon indicating copy to clipboard operation
zmarkdown copied to clipboard

Mathml and epub : missing xmlns and xml-annotation

Open artragis opened this issue 6 years ago • 1 comments

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.

artragis avatar Jul 28 '19 20:07 artragis

Tested on standalone parser/serializer, the problem is the same:

remark-math does his job => rehype-katex passes directly to => katex where the problems are actually located

About the missing xmlns attribute, it will be in the next release of KaTeX, so we just need to wait for it to be updated on both rehype-katex and zds-site.

I opened an issue concerning the xml-annotation element, but we can't do much ourselves, so do we keep this issue open until addition of theses features on the dependencies?

StaloneLab avatar Jul 29 '19 09:07 StaloneLab