Skip to content

Add TeX plugin#2298

Closed
Kyuuhachi wants to merge 4 commits into
Vendicated:devfrom
Kyuuhachi:tex
Closed

Add TeX plugin#2298
Kyuuhachi wants to merge 4 commits into
Vendicated:devfrom
Kyuuhachi:tex

Conversation

@Kyuuhachi
Copy link
Copy Markdown
Contributor

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.

Comment thread src/plugins/tex/index.tsx Outdated
Comment thread src/plugins/tex/index.tsx Outdated
Comment thread src/plugins/tex/style.css Outdated
@byeoon
Copy link
Copy Markdown
Contributor

byeoon commented Mar 27, 2024

math is pretty scary ngl

but this plugin seems helpful

@waresnew
Copy link
Copy Markdown
Contributor

waresnew commented Mar 28, 2024

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

@Kyuuhachi
Copy link
Copy Markdown
Contributor Author

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

@Vendicated
Copy link
Copy Markdown
Owner

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

@Kyuuhachi
Copy link
Copy Markdown
Contributor Author

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.

@lewisakura
Copy link
Copy Markdown
Collaborator

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

@Vendicated
Copy link
Copy Markdown
Owner

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

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.

6 participants