Vencord icon indicating copy to clipboard operation
Vencord copied to clipboard

Add TeX plugin

Open Kyuuhachi opened this issue 1 year ago • 3 comments

Renders $\LaTeX$ formulas. `$\sin x$` renders as $\sin x$, `$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$` renders as $\displaystyle x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$. The latter is intentionally set to an inline-block instead of a block, to save space.

This plugin requires external libraries, which will not work in the userscript version without additional workarounds.

Kyuuhachi avatar Mar 26 '24 21:03 Kyuuhachi

math is pretty scary ngl

but this plugin seems helpful

byeoon avatar Mar 27 '24 00:03 byeoon

Do you think it's possible to add a command to send latex as a rendered image as well? So you can share math stuff with people without the plugin

idk if this is out of scope

waresnew avatar Mar 28 '24 13:03 waresnew

That would be nice, but not really possible until KaTeX implements it; see this issue.

Kyuuhachi avatar Mar 28 '24 13:03 Kyuuhachi

thanks for the contribution!

a few thoughts:

  • how safe is this? using dangerouslySetInnerHTML is sketch. we don't want any XSS happening
  • there are some commands that may load external files, such as
    \includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://katex.org/img/khan-academy.png}
    
    have you made sure these are disabled?
  • does this prevent infinite loops? e.g.
    \def\x{Hello!\par\x}
    \x
    

i'm also not sure how useful a plugin like this is in light of the recent userapps. tex inside discord is already fairly niche, and in an era where you can just install an app to your account and use /tex anywhere, it doesn't seem that useful

Vendicated avatar May 14 '24 02:05 Vendicated

Those are good points. I personally have no issue with dangerouslySetInnerHTML, but I understand that it can be seen as sketchy. I'm pretty sure there's an option in katex to set a time limit, and there probably is one for external urls too; I haven't looked.

And yeah the value of this plugin is pretty low. It came up as a plugin request a while ago, and it was fun to make. Perhaps it's better off remaining as a userplugin. I don't mind if you choose to close this.

Kyuuhachi avatar May 14 '24 05:05 Kyuuhachi

please make sure you validate that you have configured the security options in katex to prevent people from abusing it

lewisakura avatar May 14 '24 10:05 lewisakura

will be closing as too niche. if you'd like to post it in third party plugins, feel free to do so after making sure the security concerns are addressed!

sorry and thank you anyway

Vendicated avatar May 14 '24 23:05 Vendicated