imdone-core 1.53.14 → 1.53.15
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.
|
@@ -8,16 +8,40 @@ function removeDisplayComments(description) {
|
|
|
8
8
|
return description.replace(/<!--\s*\[([\s\S]*?)\]\s*-->/g, '$1')
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
function escapeCodeBlocks(content) {
|
|
12
|
+
const codeBlockRegex = /(```[\s\S]*?```|`[^`]*`)/g
|
|
13
|
+
let codeBlocks = []
|
|
14
|
+
|
|
15
|
+
// Replace code blocks with unique keys
|
|
16
|
+
content = content.replace(codeBlockRegex, (match) => {
|
|
17
|
+
const key = `__CODE_BLOCK_${codeBlocks.length}__`
|
|
18
|
+
codeBlocks.push(match) // Maintain order
|
|
19
|
+
return key
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
return { content, codeBlocks }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function restoreCodeBlocks(content, codeBlocks) {
|
|
26
|
+
// Restore code blocks in order using stored array
|
|
27
|
+
codeBlocks.forEach((code, index) => {
|
|
28
|
+
content = content.replace(`__CODE_BLOCK_${index}__`, code)
|
|
29
|
+
})
|
|
30
|
+
return content
|
|
31
|
+
}
|
|
32
|
+
|
|
11
33
|
function format(content, data, mustache) {
|
|
12
34
|
const opts = { interpolate: /(?<![`\\])\${([\s\S]+?)}/g }
|
|
13
35
|
|
|
14
36
|
if (mustache) content = removeDisplayComments(content)
|
|
15
37
|
|
|
38
|
+
// Escape code blocks before processing interpolation
|
|
39
|
+
const { content: escapedContent, codeBlocks } = escapeCodeBlocks(content)
|
|
40
|
+
|
|
16
41
|
try {
|
|
17
|
-
content = template(
|
|
42
|
+
content = template(escapedContent, opts)(data)
|
|
18
43
|
} catch (e) {
|
|
19
44
|
console.error(e)
|
|
20
|
-
// content = content.replace(opts.interpolate, `~~\${${e}}~~`)
|
|
21
45
|
}
|
|
22
46
|
|
|
23
47
|
if (mustache) {
|
|
@@ -30,5 +54,7 @@ function format(content, data, mustache) {
|
|
|
30
54
|
}
|
|
31
55
|
}
|
|
32
56
|
|
|
57
|
+
content = restoreCodeBlocks(content, codeBlocks)
|
|
58
|
+
|
|
33
59
|
return content
|
|
34
60
|
}
|