qownnotes / scripts

QOwnNotes script repository
http://www.qownnotes.org
GNU General Public License v3.0
106 stars 80 forks source link

KaTeX in markdown-it #50

Open ptah-alexs opened 5 years ago

ptah-alexs commented 5 years ago

Please add KaTeX into markdown-in bundle in QOwnNotes.

https://www.npmjs.com/package/@iktakahiro/markdown-it-katex

pbek commented 5 years ago

I'm open for pull requests. See #48. (https://github.com/qownnotes/scripts/commit/4859db3504371579ae82bba610bc25b6ecbc21e9 will help you too)

r00tr4v3n commented 4 years ago

This looks interesting, it should be faster than generating (two) images for formulas (as preview and export). But how do I access the library correctly in QML? I tried:

import "katex.js" as Katex
...
property variant katex;
....
katex = new this.Katex();
...
html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
            throwOnError: false
        });

markdown-it.qml:73: TypeError: Type error markdown-it/katex.js:271: TypeError: Type error

pbek commented 4 years ago

Has "the internet" something to say about that?

r00tr4v3n commented 4 years ago

Nothing of use to me. As a JS/QML novice, I'd expected the library to be called statically with katex.renderToString() or to be instantiated as a module like var katex = new Katex(). I don't get if this is a petty JS mistake or a missing step for QML.