The LaTeX math syntax within the Markdown text editor doesn't seem to be recognized #14530

Closed
opened 2026-02-21 19:17:40 -05:00 by yindo · 4 comments
Owner

Originally created by @BigdataQIJI on GitHub (Jun 10, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.4.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Image
The LaTeX math syntax within the Markdown text editor doesn't seem to be recognized
for example : \mathsf { P } { < } 0 . 0 5 can not be recognized

✔️ Expected Behavior

the Markdown text editor should support the LaTeX math syntax

Actual Behavior

No response

Originally created by @BigdataQIJI on GitHub (Jun 10, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.4.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ![Image](https://github.com/user-attachments/assets/54917dc0-acd7-4bc5-8a9b-93c8c0bfaf29) The LaTeX math syntax within the Markdown text editor doesn't seem to be recognized for example : $\mathsf { P } { < } 0 . 0 5 $ can not be recognized ### ✔️ Expected Behavior the Markdown text editor should support the LaTeX math syntax ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:17:40 -05:00
yindo closed this issue 2026-02-21 19:17:40 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 10, 2025):

Hi @BigdataQIJI! I'm Dosu and I’m helping the dify team.

Dify's Markdown editor uses the remark-math plugin with the singleDollarTextMath option set to false, which means single dollar signs ($...$) are not recognized as math delimiters—only double dollar signs ($$...$$) are processed as math blocks. This is why your example with single dollar signs isn't rendered as expected. You can work around this by using double dollar signs for inline math, like $$\mathsf { P } { < } 0 . 0 5 $$ instead of $...$ reference.

If you want single dollar support, the code would need to be changed to set singleDollarTextMath: true in the remark-math plugin config. There are no Docker or environment settings that control this—it's set at build time in the frontend code reference.

Let me know if you need more details on where to make this change in the code!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jun 10, 2025): <!-- Greeting --> Hi @BigdataQIJI! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> Dify's Markdown editor uses the `remark-math` plugin with the `singleDollarTextMath` option set to `false`, which means single dollar signs (`$...$`) are not recognized as math delimiters—only double dollar signs (`$$...$$`) are processed as math blocks. This is why your example with single dollar signs isn't rendered as expected. You can work around this by using double dollar signs for inline math, like `$$\mathsf { P } { < } 0 . 0 5 $$` instead of `$...$` [reference](https://github.com/langgenius/dify/blob/c439e8203853b62218b178421a85585f8a90cc94/web/app/components/base/markdown/index.tsx). If you want single dollar support, the code would need to be changed to set `singleDollarTextMath: true` in the `remark-math` plugin config. There are no Docker or environment settings that control this—it's set at build time in the frontend code [reference](https://github.com/langgenius/dify/blob/c439e8203853b62218b178421a85585f8a90cc94/web/app/components/base/markdown/index.tsx). Let me know if you need more details on where to make this change in the code! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/9f3631fe-f536-43b6-9c84-777a83146f65?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/9f3631fe-f536-43b6-9c84-777a83146f65?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/9f3631fe-f536-43b6-9c84-777a83146f65?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/9f3631fe-f536-43b6-9c84-777a83146f65?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/9f3631fe-f536-43b6-9c84-777a83146f65?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/9f3631fe-f536-43b6-9c84-777a83146f65?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/9f3631fe-f536-43b6-9c84-777a83146f65?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/20860)
Author
Owner

@BigdataQIJI commented on GitHub (Jun 10, 2025):

@dosu but i try this text:$\mathsf { P } { < } 0 . 0 5 $ , output:mathsfP>0.05 the keyword mathsf can not be recognized
these key words can not be recognized : \textcircled、\mathrm、\mathsf 、\bullet

@BigdataQIJI commented on GitHub (Jun 10, 2025): @dosu but i try this text:$$\mathsf { P } { < } 0 . 0 5 $$ , output:mathsfP>0.05 the keyword mathsf can not be recognized these key words can not be recognized : \textcircled、\mathrm、\mathsf 、\bullet
Author
Owner

@dosubot[bot] commented on GitHub (Jun 10, 2025):

KaTeX (used by Dify for LaTeX rendering) supports \mathsf, \mathrm, and \bullet, so these should work if the syntax is correct. However, \textcircled is not supported by KaTeX as of version 0.16.x—this is a known limitation and not specific to Dify. If \mathsf, \mathrm, or \bullet are not rendering, double-check your syntax (e.g., use \mathsf{P < 0.05} without extra spaces or braces). For \textcircled, there isn’t a direct workaround in KaTeX; you might try alternatives like using Unicode circled letters or different notation. Dify does not filter or block these commands—support is inherited directly from KaTeX and rehype-katex defaults, and there’s no Dify-level config to extend this support without updating KaTeX itself reference.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jun 10, 2025): <!-- Answer --> KaTeX (used by Dify for LaTeX rendering) supports \mathsf, \mathrm, and \bullet, so these should work if the syntax is correct. However, \textcircled is not supported by KaTeX as of version 0.16.x—this is a known limitation and not specific to Dify. If \mathsf, \mathrm, or \bullet are not rendering, double-check your syntax (e.g., use $$\mathsf{P < 0.05}$$ without extra spaces or braces). For \textcircled, there isn’t a direct workaround in KaTeX; you might try alternatives like using Unicode circled letters or different notation. Dify does not filter or block these commands—support is inherited directly from KaTeX and rehype-katex defaults, and there’s no Dify-level config to extend this support without updating KaTeX itself [reference](https://github.com/langgenius/dify/blob/0f3d4d0b6e65bcf1892316f1b6e4274e24f80e71/web/package.json). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/2fc754b6-d320-426e-ae87-9ee9ac97d6fa?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2fc754b6-d320-426e-ae87-9ee9ac97d6fa?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2fc754b6-d320-426e-ae87-9ee9ac97d6fa?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2fc754b6-d320-426e-ae87-9ee9ac97d6fa?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2fc754b6-d320-426e-ae87-9ee9ac97d6fa?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2fc754b6-d320-426e-ae87-9ee9ac97d6fa?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2fc754b6-d320-426e-ae87-9ee9ac97d6fa?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/20860)
Author
Owner

@hfeng5211 commented on GitHub (Jun 18, 2025):

What considerations led to setting the default rendering of formulas with a single dollar sign to false? We know that the content output by LLMs highly adheres to the Markdown format, so inline formulas should be very common. Why not set the default to true?

@hfeng5211 commented on GitHub (Jun 18, 2025): What considerations led to setting the default rendering of formulas with a single dollar sign to false? We know that the content output by LLMs highly adheres to the Markdown format, so inline formulas should be very common. Why not set the default to true?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#14530