@luckydraw/cumulus 0.27.36 → 0.27.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1170,15 +1170,30 @@
|
|
|
1170
1170
|
var data;
|
|
1171
1171
|
try {
|
|
1172
1172
|
data = JSON.parse(block.json);
|
|
1173
|
-
} catch (
|
|
1174
|
-
//
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1173
|
+
} catch (_firstErr) {
|
|
1174
|
+
// Claude sometimes outputs real newlines inside JSON string values
|
|
1175
|
+
// instead of \n escape sequences. Fix by escaping newlines within strings.
|
|
1176
|
+
try {
|
|
1177
|
+
var fixed = block.json.replace(
|
|
1178
|
+
/"(?:[^"\\]|\\.)*"/g,
|
|
1179
|
+
function (match) {
|
|
1180
|
+
return match
|
|
1181
|
+
.replace(/\n/g, '\\n')
|
|
1182
|
+
.replace(/\r/g, '\\r')
|
|
1183
|
+
.replace(/\t/g, '\\t');
|
|
1184
|
+
}
|
|
1185
|
+
);
|
|
1186
|
+
data = JSON.parse(fixed);
|
|
1187
|
+
} catch (e) {
|
|
1188
|
+
// Show parse error in a fallback
|
|
1189
|
+
ph.innerHTML =
|
|
1190
|
+
'<pre style="color:#f44;font-size:0.85em;">blex:' +
|
|
1191
|
+
escapeHtml(block.type) +
|
|
1192
|
+
' — invalid JSON: ' +
|
|
1193
|
+
escapeHtml(e.message) +
|
|
1194
|
+
'</pre>';
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1182
1197
|
}
|
|
1183
1198
|
|
|
1184
1199
|
var contentBlock = { type: block.type, id: block.id, data: data };
|