Add TeX plugin
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.
math is pretty scary ngl
but this plugin seems helpful
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
That would be nice, but not really possible until KaTeX implements it; see this issue.
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
have you made sure these are disabled?\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://katex.org/img/khan-academy.png} - 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
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.
please make sure you validate that you have configured the security options in katex to prevent people from abusing it
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