Skip to content

Commit de9ad59

Browse files
committed
fix #58; unescape dollar backslash curly
1 parent 4878fdc commit de9ad59

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/vite/observable.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export function observable({
104104
if (mode === "md" && !hidden) {
105105
const template = parseTemplate(value);
106106
if (!template.expressions.length && !cell.output) statics.add(cell);
107-
const content = md([stripExpressions(template, value)]);
107+
const content = md([unescapeDollarBackslashCurly(stripExpressions(template, value))]);
108108
const codes = content.querySelectorAll<HTMLElement>("code[class^=language-]");
109109
await Promise.all(Array.from(codes, highlight));
110110
div.appendChild(content);
@@ -248,6 +248,10 @@ function stripExpressions(template: TemplateLiteral, input: string): string {
248248
return String(source);
249249
}
250250

251+
function unescapeDollarBackslashCurly(input: string): string {
252+
return input.replace(/(\$\\*)\\({)/g, "$1$2");
253+
}
254+
251255
/** Returns true if the specified character is preceded by an equals sign, ignoring whitespace. */
252256
function hasPrecedingEquals(input: string, index: number): boolean {
253257
let i = index - 1;

0 commit comments

Comments
 (0)