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 TeX rendering edge case #670

Closed
andrii-i opened this issue Mar 4, 2024 · 1 comment · Fixed by #675
Closed

Fix TeX rendering edge case #670

andrii-i opened this issue Mar 4, 2024 · 1 comment · Fixed by #675
Labels
bug Something isn't working
Milestone

Comments

@andrii-i
Copy link
Collaborator

andrii-i commented Mar 4, 2024

Description

Some LaTeX markdown returned by OpenAI models is not getting rendered as LaTeX due to the use of replace calls that don't catch repeating symbols in escapeLatexDelimeters function. To fix, use replaceAll calls instead of replace

function escapeLatexDelimiters(text: string) {
return text
.replace('\\(', '\\\\(')
.replace('\\)', '\\\\)')
.replace('\\[', '\\\\[')
.replace('\\]', '\\\\]');
}

Reproduce

Get OpenAI models to return LaTeX.

Screenshot 2024-03-05 at 1 29 57 PM
@andrii-i andrii-i added the bug Something isn't working label Mar 4, 2024
@andrii-i andrii-i added this to the v2.11.1 milestone Mar 4, 2024
@dlqqq dlqqq changed the title Some LaTeX markdown returned by OpenAI models is not getting rendered as LaTeX Fix TeX rendering edge case Mar 4, 2024
@dlqqq
Copy link
Member

dlqqq commented Mar 4, 2024

This issue isn't specific to OpenAI models BTW, it will happen to any model that uses \( or \[ to delimit TeX instead of $ and $$.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants