From 5ea60a9be5d10b3ff3c47163c6abe209ab7324e3 Mon Sep 17 00:00:00 2001 From: Tomasz Szuba Date: Tue, 28 Sep 2021 14:52:50 +0200 Subject: [PATCH] Escape pipe character `|` in api docs Signed-off-by: Tomasz Szuba --- scripts/api-extractor.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/api-extractor.ts b/scripts/api-extractor.ts index 5314581db2..3d74882b6c 100644 --- a/scripts/api-extractor.ts +++ b/scripts/api-extractor.ts @@ -372,6 +372,18 @@ async function buildDocs({ // This is where we actually write the markdown and where we can hook // in the rendering of our own nodes. class CustomCustomMarkdownEmitter extends CustomMarkdownEmitter { + // Until https://github.com/microsoft/rushstack/issues/2914 gets fixed or we change markdown renderer we need a fix + // to render pipe | character correctly. + protected getEscapedText(text: string): string { + return text + .replace(/\\/g, '\\\\') // first replace the escape character + .replace(/[*#[\]_`~]/g, x => `\\${x}`) // then escape any special characters + .replace(/---/g, '\\-\\-\\-') // hyphens only if it's 3 or more + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/\|/g, '|'); + } /** @override */ protected writeNode( docNode: DocNode,