aarkue / tiptap-math-extension

Math Extension for the TipTap Editor
https://aarkue.github.io/tiptap-math-extension/
MIT License
45 stars 8 forks source link

Allow Specifying Math Delimiter #6

Closed aarkue closed 4 months ago

aarkue commented 5 months ago

While $...$ is the most common math delimiter for inline latex math, it should also be possible to use different or maybe even custom delimiters (e.g., \(...\)). This can be in particular useful, as $ is often also used in other context in text (e.g., for the dollar currency).

This is also related to #5, as custom delimiters also apply to block math expressions.

For reference, here are the default delimiters for auto-rendering KaTeX (as inspiration): https://katex.org/docs/autorender.html#api

apbolshakova commented 4 months ago

Lack of delimiter customization limits us - our users widely use "$" characters without having LaTeX in mind and it's challenging for us to separate these cases. It would be great to have such a feature.

aarkue commented 4 months ago

Lack of delimiter customization limits us - our users widely use "$" characters without having LaTeX in mind and it's challenging for us to separate these cases. It would be great to have such a feature.

Thanks for the input @apbolshakova ! This feature is definitely on the short-term roadmap. What would be your preferred delimiter to use instead? I am guessing \( and \) (or \[ and \] for display)? I wonder if it might be enough to allow only those, in addition to $, $$, as possible delimiters to choose from.

aarkue commented 4 months ago

Hi @apbolshakova, specifying the delimiters should now be possible in the newly released 1.3.1 version. For instance, setting the delimiters option to "bracket" uses the \(x_1\) syntax as input rules and for pasting.

Support for more advanced custom delimiters is still WIP, but will be tracked in a separate issue when time comes.

Let me know if you encounter any issues.