Request: Delimiter Support for AI-Generated Content in Discourse Math (LaTeX)

Background: This developer forum is powered by software called Discourse. It uses this plugin to display manth formulas…if you know it is active and also know how to put mathematics statements into a reply: Discourse math

It notes:

You can render blocks of maths by wrapping with $

$
\sqrt{(-1)} \; 2^3 \; \sum \; \pi
$

\sqrt{(-1)} \; 2^3 \; \sum \; \pi

How useful is this? That assumes someone is versed in not just LaTeX, but also has the awareness of the forum technology’s requirements - an atypical reply content.


Here is the same as output from ChatGPT, though:

Here is the formula rendered in display mode:

\[
\sqrt{(-1)} \; 2^3 \; \sum \; \pi
\]

A copy of AI output, or pressing the ChatGPT “copy” button to paste here results in unrendered formulae:

[
\sqrt{(-1)} ; 2^3 ; \sum ; \pi
]

AI output text is more readily available, and is probably by 100:1 more desired to be shown here.


In traditional LaTeX, the default way to display mathematics is to enclose it in \[ and \]. This tells LaTeX that you’re starting and ending a block of display math. This is what ChatGPT produces.

On many online forums—especially those using MathJax with a Discourse setup—it’s common to see math written using dollar sign delimiters. For instance:

  • Inline math: $ ... $
  • Display math: $$ ... $$

The key difference is not in the math itself but in the delimiter convention chosen by the platform’s configuration. While both approaches are valid and often supported by MathJax (the dollar sign being the MathJax default - and writing that dollar sign right here as a symbol breaking the rendering), the forum needs AI-output orientation.

It would be an improvement that the MathJax configuration here in the AI-oriented forum accommodates both styles (if possible) or uses a transformation process (even powered by AI), if not simply switching over.


\textbf{OpenAI could also produce just a bit of documentation}

  • so one doesn’t have to discover overrides and parameters and placeholders that can pass through a markdown to HTML library, etc. when developing products rendering their rich AI output.
3 Likes

Post on the linked Topic?

PS I used that plugin to create this output:

(together with GitHub - merefield/discourse-chatbot: An AI bot with RAG capability for Topics and Chat in Discourse, currently powered by OpenAI)

The LLM struggles with the deviation from the standard for sure and once it deviates into LaTex it prefers to stay there.

2 Likes

Did a tiny bit of reading and it turns out CDCK are aware of this issue and might welcome a PR to support LaTeX directly without the non-standard delimeters.

If someone wants to have a go please do.

Or if someone wants to fund this (University?), given I’m a prolific Discourse Plugin writer you can feel free to contact me privately if you’d like to hire me to build it on your behalf.

1 Like