Skip to content

Commit 08f1eb0

Browse files
authored
Fix formatting in configuration-intro (#1742)
Restrict replacing curly brackets in the `md` to `mdx` conversion to comments in `js` codeblocks.
1 parent 92ddb62 commit 08f1eb0

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

web/platform/utils/md_to_mdx.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,18 @@ function closeList(inList: boolean, processedLines: string[]): boolean {
299299

300300
function escapeHtml(line: string): string {
301301
const htmlTagPattern = /^[<\s][^>]*>/g;
302-
return htmlTagPattern.test(line)
303-
? line
304-
: line
305-
.replace(/</g, "&lt;")
306-
.replace(/>/g, "&gt;")
307-
.replace(/{/g, "[")
308-
.replace(/}/g, "]");
302+
303+
if (htmlTagPattern.test(line)) {
304+
return line;
305+
}
306+
307+
let escapedLine = line.replace(/</g, "&lt;").replace(/>/g, "&gt;");
308+
309+
if (escapedLine.includes("//") || escapedLine.includes("/*")) {
310+
escapedLine = escapedLine.replace(/{/g, "[").replace(/}/g, "]");
311+
}
312+
313+
return escapedLine;
309314
}
310315

311316
export async function transformMarkdownToMdx(

0 commit comments

Comments
 (0)