Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Dollar Sign Handling in Markdown #13178

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

Riddhimaan-Senapati
Copy link
Contributor

@Riddhimaan-Senapati Riddhimaan-Senapati commented Feb 4, 2025

Summary

Fix Dollar Sign Handling in Markdown, fixes #13149.

Problem

Regular text containing dollar signs (e.g., currency values like "$29 and $199") was being incorrectly interpreted as LaTeX math expressions, causing rendering issues in the markdown output.

Solution

Added the singleDollarTextMath: false option to the RemarkMath plugin configuration. This ensures that:

  • Single dollar signs ($) are treated as regular text characters
  • Only double dollar signs ($$) or explicit LaTeX delimiters ([...] and (...)) will trigger math expression rendering

Impact

  • Currency values and other text containing dollar signs will now display correctly
  • LaTeX math expressions continue to work as expected when properly delimited

Screenshots

Before After
Screenshot 2025-02-04 084542 Screenshot 2025-02-04 084822

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working labels Feb 4, 2025
@Riddhimaan-Senapati
Copy link
Contributor Author

Riddhimaan-Senapati commented Feb 4, 2025

@tomoyuki28jp @rainchen @iwaim @gijigae @crazywoola Can anyone of you review my PR? Excited to begin contributing to the repo.

@crazywoola
Copy link
Member

crazywoola commented Feb 4, 2025

image image

Still got this output and there are 2 lint errors.

Unexpected parentheses around single function argument having a body with no curly braces.
Unexpected parentheses around single function argument having a body with no curly braces.

@Riddhimaan-Senapati
Copy link
Contributor Author

@crazywoola I updated the PR, turns out the issue was not in the preprocessing but the rendering. I have simply added the singleDollarTextMath: false option to the RemarkMath plugin configuration. I also used npm install, and for some reason it updated the yarn.lock file as well so that's where most of the changes are coming from. But other than that, it is a one-line change.

But now can you test it again, I am having some issues from my end testing it.

@Riddhimaan-Senapati Riddhimaan-Senapati changed the title fix: improve LaTeX equation rendering in markdown preprocessing fix: Dollar Sign Handling in Markdown Feb 4, 2025
@crazywoola
Copy link
Member

@crazywoola I updated the PR, turns out the issue was not in the preprocessing but the rendering. I have simply added the singleDollarTextMath: false option to the RemarkMath plugin configuration. I also used npm install, and for some reason it updated the yarn.lock file as well so that's where most of the changes are coming from. But other than that, it is a one-line change.

But now can you test it again, I am having some issues from my end testing it.

You can revert the yarn.lock. Please leave it to us to update the lockfile. :)

@crazywoola crazywoola mentioned this pull request Feb 5, 2025
5 tasks
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 5, 2025
@crazywoola crazywoola merged commit 55ce361 into langgenius:main Feb 5, 2025
5 checks passed
@Riddhimaan-Senapati Riddhimaan-Senapati deleted the fix_chat_output branch February 5, 2025 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eg. "$10 and $20" in ouput results in canvas formatting bug
2 participants