Skip to content

Conversation

@CJendantix
Copy link
Contributor

@CJendantix CJendantix commented May 4, 2025

I wanted LaTeX rendering so I added it myself. Code addition quality may not be the greatest quality considering this is the first real work I've done with JS or QML, but it works.

This adds the markdown-it-katex plugin with the MathML output mode (it is a baseline feature now, and it is simpler than HTML and CSS). Of course the preview cannot display this so it displays the formula in italics and colors it red if there are errors.

@pbek
Copy link
Member

pbek commented May 4, 2025

Can you please all code formatting changes in another commit (I cannot review what actually was changed) and add yourself as author of the script?

@milan-rusev, @bessw, are you ok with those changes?

@pbek
Copy link
Member

pbek commented May 4, 2025

And can you please mention the plugin and what it does in the description? Could be interesting for #253.

@CJendantix
Copy link
Contributor Author

CJendantix commented May 4, 2025

Can you please all code formatting changes in another commit (I cannot review what actually was changed) and add yourself as author of the script?

@milan-rusev, @bessw, are you ok with those changes?

I'm a little confused by what you mean. Do you want me to separate the actual addition of the plugin and the preview rendering? The diff is quite clear.

@CJendantix
Copy link
Contributor Author

CJendantix commented May 4, 2025

And can you please mention the plugin and what it does in the description? Could be interesting for #253.

Do you want me to do that here or in the description of the script? If here, this is the plugin I used: https://github.com/mdit-plugins/mdit-plugins/tree/main/packages/katex. The plugin does the same thing as KaTeX and is therefore unrelated to #253 (as KaTeX renders to html while the plugin used in #253 renders an image and displays it). I just bundled it as a UMD with rollup (resolve, commonjs, and typescript plugins), changed the prelude slightly to use this then transpiled it to ES5 with babel. Finally I had to remove "use strict"; I'm not a JS developer so I couldn't tell you why I had to remove that, but it only worked if I did.

"default": null
},
]
property variant settingsVariables: [{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You changed a lot of whitespaces in this and the following lines. That's what I meant with code formatting changes.

Copy link
Contributor Author

@CJendantix CJendantix May 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. The diff looks cleaner in VSCode. That section all I did was add a boolean option titled LaTeX Support that would enable or disable KaTeX.

@pbek
Copy link
Member

pbek commented May 4, 2025

Do you want me to do that here or in the description of the script?

Yes, you could mention the KaTeX feature.

@CJendantix
Copy link
Contributor Author

Can you please all code formatting changes in another commit (I cannot review what actually was changed) and add yourself as author of the script?

@milan-rusev, @bessw, are you ok with those changes?

Also if you're still waiting on this, I don't think I can separate it into multiple commits now that there are commits after it, and if I can, I don't know how to.

@CJendantix CJendantix mentioned this pull request May 4, 2025

return mdHtml;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you add that on purpose?

Copy link
Contributor Author

@CJendantix CJendantix May 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that was the QML formatter's doing, though I don't imagine it's a problem.

@bessw
Copy link
Contributor

bessw commented May 4, 2025

Can you please all code formatting changes in another commit (I cannot review what actually was changed) and add yourself as author of the script?

@milan-rusev, @bessw, are you ok with those changes?

Sure. I'm not using this anymore and didn't test it, but it looks like a great addition.

@CJendantix
Copy link
Contributor Author

That last commit should hopefully resolve #77

@CJendantix
Copy link
Contributor Author

CJendantix commented May 4, 2025

Okay. In my opinion this PR is ready for merge, though it may need more testing. It should hopefully resolve #77, it might resolve #253 if they are willing to use a different script and export to HTML when they are finished. It won't resolve #263 because that would need a rendering overhaul that I am not qualified to do. I could implement this, but if I do, I would submit it in a separate pull request.

@pbek pbek merged commit 80f33d8 into qownnotes:master May 4, 2025
1 check passed
@CJendantix CJendantix deleted the markdown-it-katex-plugin branch May 4, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants