diff --git a/adev/shared-docs/pipeline/shared/marked/extensions/docs-code/format/index.mts b/adev/shared-docs/pipeline/shared/marked/extensions/docs-code/format/index.mts index 88f3fbaed4e..c107addc003 100644 --- a/adev/shared-docs/pipeline/shared/marked/extensions/docs-code/format/index.mts +++ b/adev/shared-docs/pipeline/shared/marked/extensions/docs-code/format/index.mts @@ -96,6 +96,11 @@ export function processForApiLinks(fragment: Element, apiEntries: ApiEntries): v }); } +/** Escapes text that is interpolated into an HTML string. */ +function escapeHtml(text: string): string { + return text.replace(/&/g, '&').replace(//g, '>'); +} + /** Build the header element if a header is provided in the token. */ function buildHeaderElement(token: CodeToken) { let header = ''; @@ -104,7 +109,7 @@ function buildHeaderElement(token: CodeToken) { } if (token.header) { - header += `

${token.header}

`; + header += `

${escapeHtml(token.header)}

`; } if (!header) return '';