waylonflinn / markdown-it-katex

Add Math to your Markdown with a KaTeX plugin for Markdown-it
MIT License
251 stars 155 forks source link

Unicode-Support #16

Open Syndesi opened 6 years ago

Syndesi commented 6 years ago

Hi,

when I'm using special letters like äöü in \text{}, the while equation will not be rendered :( But it worked with Katex's demo (added \text{äöü} to the black box) so I think that the bug may be in this package.

moriyuu commented 6 years ago

I want it too!!

waylonflinn commented 6 years ago

Thanks for bringing this to my attention. Hopefully I'll get some time in the next few weeks to fix a few of these outstanding items.

Syndesi commented 6 years ago

Actually this bug is more than just "language support": As in the Katex-documentation writen, some symbols must be written in Unicode. Therefore this formula will brake at this moment:

$\frac{a}{b} a, b ∈ ℕ$
Syndesi commented 6 years ago

I now looked into the code and found out that katex don't return a string when the latex-input contains these characters. Updating the packages led to compatibility issues and even when these were fixed (with webpack instead of watchify), the reported bug still exists. Therefore I think that the issue is more related to katex itself than to this project. And indeed, they have currently some related errors: #895 and #979. At least they are working on a bugfix...

But their demo is working with the expression $\frac{a}{b} a, b ∈ ℕ$. Therefore I'm currently more confused than anything else :/

kevinbarabash commented 6 years ago

It's possible the version that's on the demo is ahead what got released in the most current published package. My apologies if that's the case.

Syndesi commented 6 years ago

Hey, they completed the bugfix and the current alpha-build (without the new commit) can now render Unicode (yeah! :D ). But there are now other problems, e.g. fractions are now rendered with a huge black element in the background. But because I'm using a alpha version, I think this will be removed soon :P

left part of the website the 'a' of the fraction is rendered in the center of the black element and the right part of the website and Unicode characters are now working :D

And this is the source code of the generated expression:

<span class="katex">
  <span class="katex-mathml">
    <math>
      <semantics>
        <mrow>
          <mfrac>
            <mrow>
              <mi>a</mi>
            </mrow>
            <mrow>
              <mi>b</mi>
            </mrow>
          </mfrac>
          <mi>a</mi>
          <mo separator="true">,</mo>
          <mi>b</mi>
          <mo>∈</mo>
          <mrow>
            <mi mathvariant="double-struck">N</mi>
          </mrow>
        </mrow>
        <annotation encoding="application/x-tex">\frac{a}{b} a, b ∈ ℕ</annotation>
      </semantics>
    </math>
  </span>
  <span class="katex-html" aria-hidden="true">
    <span class="strut" style="height:0.695392em;"></span>
    <span class="strut bottom" style="height:1.040392em;vertical-align:-0.345em;"></span>
    <span class="base">
      <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:0.695392em;">
                <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 mathit mtight">b</span>
                    </span>
                  </span>
                </span>
                <span style="top:-3.23em;">
                  <span class="pstrut" style="height:3em;"></span>
                  <span class="frac-line hide-tail" style="height:0.04em;">
                    <svg width="400em" height="400em" viewBox="0 0 400000 400000" preserveAspectRatio="xMinYMin slice">
                      <path d="M0 0 h400000 v400000 h-400000z M0 0 h400000 v400000 h-400000z"></path>
                    </svg>
                  </span>
                </span>
                <span style="top:-3.394em;">
                  <span class="pstrut" style="height:3em;"></span>
                  <span class="sizing reset-size6 size3 mtight">
                    <span class="mord mtight">
                      <span class="mord mathit mtight">a</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 class="mclose nulldelimiter"></span>
      </span>
      <span class="mord mathit">a</span>
      <span class="mpunct">,</span>
      <span class="mord mathit">b</span>
      <span class="mrel">∈</span>
      <span class="mord">
        <span class="mord mathbb">N</span>
      </span>
    </span>
  </span>
</span>

The black element is created by this line: <path d="M0 0 h400000 v400000 h-400000z M0 0 h400000 v400000 h-400000z"></path>

kevinbarabash commented 6 years ago

@Syndesi the classes on <span class="frac-line hide-tail" style="height:0.04em;"> should be clipping that rectangle.

zackw commented 1 year ago

The bad rendering of \text{äöü} appears to be fixed in KaTeX 0.16.x. The rendering of is improved in 0.16.x but still not 100% correct, see https://github.com/KaTeX/KaTeX/issues/3755.