diff --git a/src/LuauRenderer/nodes/fields/renderInterpolatedStringPart.ts b/src/LuauRenderer/nodes/fields/renderInterpolatedStringPart.ts index b44aade..f246820 100644 --- a/src/LuauRenderer/nodes/fields/renderInterpolatedStringPart.ts +++ b/src/LuauRenderer/nodes/fields/renderInterpolatedStringPart.ts @@ -2,15 +2,11 @@ import luau from "LuauAST"; import { RenderState } from "LuauRenderer"; export function renderInterpolatedStringPart(state: RenderState, node: luau.InterpolatedStringPart) { - // escape braces and newlines, but do not touch braces within unicode escape codes return ( node.text - .replace( - /(\\u{[0-9A-Fa-f]+})|([{}])/g, - (_, unicodeEscape: string | undefined, brace: string | undefined) => unicodeEscape ?? "\\" + brace, - ) - // captures a CR with optionally an LF after it - // or just an LF on its own + // escape braces, but do not touch braces within unicode escape codes + .replace(/(\\u{[a-fA-F0-9]+})|([{}])/g, (_, unicodeEscape, brace) => unicodeEscape ?? "\\" + brace) + // escape newlines, captures a CR with optionally an LF after it or just an LF on its own .replace(/(\r\n?|\n)/g, "\\$1") ); }