mangiucugna / json_repair

A python module to repair invalid JSON, commonly used to parse the output of LLMs
https://pypi.org/project/json-repair/
MIT License
826 stars 48 forks source link

[Bug]: Handling LaTeX inside a string #74

Closed sreeramcoder closed 2 weeks ago

sreeramcoder commented 2 weeks ago

Version of the library

https://mangiucugna.github.io/json_repair/

Describe the bug

I see the issue in the demo link. If the json contains a string with LaTeX expressions, the backslash is removed (backslash is needed for LaTeX). Instead it is recommended to escape the backslash.

How to reproduce

For input { "content": [ { "topic_text": " $$\mathrm{F}_1$$ and $$\mathrm{F}_2$$." } ] } , output is { "content": [ { "topic_text": " $$mathrm{F}_1$$ and $$mathrm{F}_2$$." } ] }

Expected behavior

The expected output is { "content": [ { "topic_text": " $$\\mathrm{F}_1$$ and $$\\mathrm{F}_2$$." } ] }

mangiucugna commented 2 weeks ago

I have release 0.29.7 and also reloaded the demo site. Thanks for reporting