cogentapps / chat-with-gpt

An open-source ChatGPT app with a voice

Home Page:https://www.chatwithgpt.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Markdown Rendering Issue with Special Characters

sanjeevneo opened this issue · comments

Description:

I had trouble with the application when displaying specific special characters in the Markdown output. The $ character, typically used for inline mathematical expressions in LaTeX and Markdown, caused formatting problems in the text. Also, I noticed that sometimes the text turned red, possibly a syntax error or an unclosed tag in the Markdown. This could be because of certain unpaired characters.

Expected Behavior:

I expect special characters like $ should be correctly displayed in the output without causing subsiquent formatting issues.

Actual Behavior:

When a $ character is present in the text, it causes formatting issues because it maybe being interpreted as the start or end of a mathematical expression.

Steps to Reproduce:

  1. Input a text that includes a $ character.
  2. Observe the output. The $ character causes formatting issues.

Suggested Solution:

A potential solution could be to escape the $ character in the output.

Here is a sample code snippet:

this.content = value.replace(/\$/g, '\\$');

Additional Context:

A comprehensive approach may be required to eliminate other such issues like the red text caused by unclosed tags. A viable solution is to use a Markdown parsing library to close all Markdown formatting constructs and accurately parse the text.

Good catch. I’ve made math syntax an option, disabled by default for now. This seems to fix the issue you describe with dollars.

Good catch. I’ve made math syntax an option, disabled by default for now. This seems to fix the issue you describe with dollars.

Appreciate your rapid response and the effective handling of the issue. I've just tried it and the issue with the $ character is not present anymore.

However, a separate issue has emerged, possibly new or unnoticed previously, related to newlines and inconsistencies in table or code block creation. Could these be symptomatic of a broader issue with the Markdown parser? Thank you for your continuous support.