Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
osyrisrblx committed Jun 23, 2024
1 parent a5af3f6 commit 9593ab4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/LuauRenderer/nodes/fields/renderInterpolatedStringPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ 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,
)
.replace(/(\r\n?|\n)/g, "\\$1");
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
.replace(/(\r\n?|\n)/g, "\\$1")
);
}

0 comments on commit 9593ab4

Please sign in to comment.