Skip to content

Conversation

ServeurpersoCom
Copy link
Collaborator

So inline and block equations are converted before KaTeX rendering, enabling proper display of model-generated LaTeX in the WebUI:

  • Added a dedicated remarkMathJaxDelimiters plugin that rewrites MathJax bracket delimiters into KaTeX-friendly dollar math while limiting the normalization to text nodes so code blocks and other literals remain untouched.

  • Wired the new plugin into the existing Markdown processor ahead of remark-math and dropped the prior global string replace, keeping the established remark/rehype pipeline intact while still rendering centered and inline equations correctly.

Missing stage in #16505 because of KaTeX

Close #16598

@ServeurpersoCom
Copy link
Collaborator Author

Raw default output for many model :
LaTeX-Inline
LaTeX-Centered

Result with this PR :

KaTeX-vs-MathJax.mp4

@ServeurpersoCom ServeurpersoCom force-pushed the mathjax-style-delimiters branch from 35ee04c to 99957e3 Compare October 16, 2025 04:15
@ServeurpersoCom ServeurpersoCom marked this pull request as draft October 16, 2025 04:42
…iters

So inline and block equations are converted before KaTeX rendering,
enabling proper display of model-generated LaTeX in the WebUI
@ServeurpersoCom ServeurpersoCom force-pushed the mathjax-style-delimiters branch from 99957e3 to 877f0bd Compare October 16, 2025 04:51
@ServeurpersoCom
Copy link
Collaborator Author

Sorry for the spam : I had two versions coexisting in my Git history, so I reverted to the simple version that works on its own, without the remark plugin.

@ServeurpersoCom ServeurpersoCom marked this pull request as ready for review October 16, 2025 04:54
@ggerganov
Copy link
Member

This patch renders correctly mathematical expressions on my end.

Just a minor note - probably the "Show raw LLM output" option should not be located in the "Reasoning" tab. And the name should be shortened to just "Show raw LLM output".

image

@ServeurpersoCom
Copy link
Collaborator Author

ServeurpersoCom commented Oct 16, 2025

I realized it and told Alek on discord:D
Sans titre
Because we should group all the debug options into a dedicated developer section, since we’re going to add toolcall debugging soon.
And also "Custom JSON parameters to send to the API. Must be valid JSON format." -> Debug or Developer...
And eventually, the “Advanced” section could be renamed to “Sampling.”
And current "Sampler" inside "Sampling"
What do you think?

@ServeurpersoCom
Copy link
Collaborator Author

Settings layout : #16607

@srogmann
Copy link
Contributor

Hi @ServeurpersoCom , in #16508 there are test-samples in https://github.com/ggml-org/llama.cpp/pull/16508/files#diff-22e3b93a74a89292e31a9c73b38e1e011c26b28f0715369f30f5a8d1090ea750 .

@ServeurpersoCom
Copy link
Collaborator Author

ServeurpersoCom commented Oct 16, 2025

Hi @ServeurpersoCom , in #16508 there are test-samples in https://github.com/ggml-org/llama.cpp/pull/16508/files#diff-22e3b93a74a89292e31a9c73b38e1e011c26b28f0715369f30f5a8d1090ea750 .

I’ll take a look at your test samples: that seems like a really good idea.

Take a look at my proposal: it’s much simpler now, just one function. Implementing it as a remark plugin was making things more complex.

The remark MathJax plugin rewrites the Markdown AST too aggressively, replacing whole subtrees and risking broken output whenever nested markup or edge cases appear. A simple regex-based pre-normalization that converts math delimiters before parsing avoids all that complexity, it lets the standard remark-math plugin do the job safely. Fewer moving parts mean less maintenance, fewer bugs, and the same rendering quality without the AST surgery.

@allozaur allozaur merged commit 683fa6b into ggml-org:master Oct 16, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misc. bug: Svelte WebUI Improve default LaTeX rendering

4 participants