zestedesavoir / zmarkdown

Live demo: https://zestedesavoir.github.io/zmarkdown/
MIT License
220 stars 52 forks source link

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

Open artragis opened 4 years ago

artragis commented 4 years ago

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 :

StaloneLab commented 4 years ago

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?