Code Monkey home page Code Monkey logo

Comments (8)

NicolasNewman avatar NicolasNewman commented on May 18, 2024 1

Great! The issue comes down OSes using different fonts and browsers having different MathML implementations. On Windows the first shows as being elongated while the 2nd is correct.

image.

Unfortunately it was a bit of an oversight as I didn't think to test different fonts but the useLegacyMathML option only defaults to using the stylesheet if MathML is not supported at all in a browser. Going forward the config field should be re-worked to also allow using the KaTeX's stylesheet if specified, and never the browser's implementation. I'll hopefully have a PR opened by this weekend to address the problem.

from mermaid.

NicolasNewman avatar NicolasNewman commented on May 18, 2024

@pbreheny Do you happen to know which version of chrome this was?

On v123.0.6312.123:
image

And on Firefox v124.0.2:
image

Granted the sqrt goes further down then it should.

from mermaid.

NicolasNewman avatar NicolasNewman commented on May 18, 2024

I agree that this is an issue on Mermaid's end. Here's the same formula displayed in Joplin (Electron based app with KaTeX integration)

KaTeX v0.16.9
Electron v29.1.0 (Chromium v122.0.6261.39)

image

from mermaid.

pbreheny avatar pbreheny commented on May 18, 2024

Oh, interesting...it is indeed browser dependent. The mistake shows up on Chromium (Linux) Version 124.0.6367.60 (Official Build) snap (64-bit). When I go over to a Windows machine and run on Google Chrome / Edge / Firefox, the equation is correctly displayed on all three browsers.

from mermaid.

NicolasNewman avatar NicolasNewman commented on May 18, 2024

Does this effect how it renders on Linux?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
        integrity="sha384-wcIxkf4k558AjM3Yz3BBFQUbk/zgIYC2R0QpeeYb+TwlBVMrlgLqwRjRtGZiK7ww" crossorigin="anonymous">
    <script type="module">
        import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
        mermaid.initialize({
            theme: 'forest',
            legacyMathML: true,
        });
    </script>
</head>
<body>
    <div class="mermaid">
        graph LR
        B("$$\sqrt{\frac{\pi(1-\pi)}{n}}$$")
        A-->B
    </div>
</body>
</html>

from mermaid.

pbreheny avatar pbreheny commented on May 18, 2024

No; sqrt is still misplaced:

Screenshot from 2024-04-22 11-46-17

from mermaid.

NicolasNewman avatar NicolasNewman commented on May 18, 2024

Could you try opening the following? Does one of them render the same as your 2nd screenshot?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
        integrity="sha384-wcIxkf4k558AjM3Yz3BBFQUbk/zgIYC2R0QpeeYb+TwlBVMrlgLqwRjRtGZiK7ww" crossorigin="anonymous">

    <!-- The loading of KaTeX is deferred to speed up page rendering -->
    <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
        integrity="sha384-hIoBPJpTUs74ddyc4bFZSM1TVlQDA60VBbJS0oA934VSz82sBx1X7kSx2ATBDIyd"
        crossorigin="anonymous"></script>
    <script type="module">
        import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
        const element = document.querySelector('div.math')
        const element2 = document.querySelector('div.math2')
        katex.render(String.raw`\sqrt{\frac{\pi(1-\pi)}{n}}`, element, {
            throwOnError: false,
            displayMode: true,
            output: 'mathml'
        }
        );
        katex.render(String.raw`\sqrt{\frac{\pi(1-\pi)}{n}}`, element2, {
            throwOnError: false,
            displayMode: true,
            output: 'htmlAndMathml'
        }
        );

    </script>
</head>
<body>
    <div class="math"></div>
    <div class="math2"></div>
    <div class="mermaid">
        graph LR
        B("$$\sqrt{\frac{\pi(1-\pi)}{n}}$$")
        A-->B
    </div>
</body>
</html>

from mermaid.

pbreheny avatar pbreheny commented on May 18, 2024

Yes; first one is incorrect, second one is correct:

Screenshot from 2024-04-22 12-03-37

from mermaid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.