Open
Conversation
The interpreter was incorrectly handling JSON responses from LLMs when the content contained double quotes or backslashes. The issue was: 1. The code was calling sanitizeJsonString() before attempting JSON.parse(), which could corrupt already-valid JSON containing escaped characters 2. The post-processing only handled newline escapes (\n) but not over-escaped quotes (\") or backslashes (\\) Changes: - Try direct JSON.parse() first, only fall back to sanitization on failure - Add unescapeContent() helper that properly handles over-escaped sequences - Process responses to convert \\" to " and \\\\ to \ after parsing This fixes the bug where content like 'export no_proxy="$NO_PROXY"' was being incorrectly output as 'export no_proxy=\"$NO_PROXY\"'.
8aafa91 to
96b893d
Compare
111b0ac to
96b893d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
issue
when using interpreter to optimize markdown content, if
\backslash or characters to be escaped are present, the output from LLM is not correctly escaped. e.g.:Input content from web page:
Output content from LLM:
You can reproduce this with this page: https://telegra.ph/obsidian-clipper-interpret-issue-reproduction-12-15
with this template:
interpret-test-clipper.json
or simply use this prompt for the content:
Basically this issue is provider- and model- agnostic, I tested this with most of the popular models including:
(as per my test,
google/gemini-2.5-flash-liteis the best model in this scenario, fast and good enough)solution
I tried to fix this issue with Claude Opus 4.5, and it was fixed in just one shot—worked really well. I reviewed the code and verified it by building, installing it in my browser, and testing it on hundreds of web pages.
Hence this PR.
You can also try the built extention here:
obsidian-web-clipper-0.12.0-chrome.zip