🔧 Development
G Gabriel Silva Dec 11, 2024

How to Add LaTeX Render Support to the Main Textarea Editor?

Hi everyone! 👋

I’m currently working on a project that requires adding LaTeX rendering support to the posts Textarea. I was considering using Waterhole and was wondering if it’s feasible to integrate something like KaTeX to parse and render LaTeX expressions directly within the editor.

Has anyone attempted something similar? If so, could you share your approach or any tips? Specifically, I’m looking for guidance on:

  1. Extending or customizing the Textarea Editor to recognize LaTeX syntax.
  2. Integrating KaTeX (or similar libraries) for real-time or post-submission rendering.
  3. Handling edge cases or potential performance concerns.

Any advice, examples, or pointers to relevant documentation would be greatly appreciated!

Thanks in advance for your help! 🚀

⁨2⁩ ⁨Comments⁩

Toby Toby Waterhole Founder Dec 13, 2024

Hi @Gabriel Silva, welcome to the community and thanks for your question!

Waterhole's server-side text formatting is powered by the s9e\TextFormatter library and there doesn't seem to be a LaTeX plugin available out of the box unfortunately!

In theory, you probably need to implement your own TextFormatter plugin to recognise LaTeX between certain delimiters, and either parse it on the server-side with something like php-latex, or output it in a certain tag that can then be rendered on the client-side by something like KaTeX.

The Formatting docs contain more information about how to interact with Waterhole's instance of TextFormatter.

In reply to Toby Toby

Hello @Toby, thanks for the welcome and your reply.

I'll try the front-end approach with the delimiters that you mentioned.

I come back here when I have more info.

Best!!