From 255654d3925cc38a33b5b8454b0dbacb13f79754 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Thu, 2 Aug 2018 06:54:30 -0400 Subject: [PATCH 1/5] doc: fix header escaping regression fixes #22065 --- tools/doc/generate.js | 2 +- tools/doc/html.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 99dce4122a0733..f2e3e8a1649985 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -67,9 +67,9 @@ fs.readFile(filename, 'utf8', (er, input) => { const content = unified() .use(markdown) + .use(html.preprocessText) .use(json.jsonAPI, { filename }) .use(html.firstHeader) - .use(html.preprocessText) .use(html.preprocessElements, { filename }) .use(html.buildToc, { filename }) .use(remark2rehype, { allowDangerousHTML: true }) diff --git a/tools/doc/html.js b/tools/doc/html.js index f2be43a38b5d91..bafebe35bcfa65 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -198,7 +198,8 @@ function preprocessElements({ filename }) { heading.children = [{ type: 'text', value: file.contents.slice( - position.start.offset, position.end.offset), + position.start.offset, position.end.offset) + .replace(/\\./g, (match) => match[1]), position }]; } From d0d6ef760c0441babf1c937c3e1d70275ad56cdd Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Thu, 2 Aug 2018 07:00:09 -0400 Subject: [PATCH 2/5] appease linter --- tools/doc/html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/doc/html.js b/tools/doc/html.js index bafebe35bcfa65..c637ccf5523559 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -199,7 +199,7 @@ function preprocessElements({ filename }) { type: 'text', value: file.contents.slice( position.start.offset, position.end.offset) - .replace(/\\./g, (match) => match[1]), + .replace(/\\.{1}/g, (match) => match[1]), position }]; } From 925f0eb1f98ed419eb6367fe195d88b5e72ea9e8 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Thu, 2 Aug 2018 12:36:05 -0400 Subject: [PATCH 3/5] replace function with capture and backreference --- tools/doc/html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/doc/html.js b/tools/doc/html.js index c637ccf5523559..d94ed8fcb56f57 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -199,7 +199,7 @@ function preprocessElements({ filename }) { type: 'text', value: file.contents.slice( position.start.offset, position.end.offset) - .replace(/\\.{1}/g, (match) => match[1]), + .replace(/\\(.{1})/g, '$1') position }]; } From 4c6e3e09c8f771ae2833ce4b17030b35de740624 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Thu, 2 Aug 2018 23:54:38 -0400 Subject: [PATCH 4/5] add back in missing comma (DOH!) --- tools/doc/html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/doc/html.js b/tools/doc/html.js index d94ed8fcb56f57..f7c08779a71efa 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -199,7 +199,7 @@ function preprocessElements({ filename }) { type: 'text', value: file.contents.slice( position.start.offset, position.end.offset) - .replace(/\\(.{1})/g, '$1') + .replace(/\\(.{1})/g, '$1'), position }]; } From e956f6b7b66d342ecc32147a3d193bf3b5248ada Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Tue, 7 Aug 2018 12:15:27 -0400 Subject: [PATCH 5/5] squash: quick fix for < and > Preferred long term fix can be found at: https://github.com/nodejs/node/pull/22140 --- tools/doc/html.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/doc/html.js b/tools/doc/html.js index f7c08779a71efa..d65a4b323aef36 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -199,6 +199,8 @@ function preprocessElements({ filename }) { type: 'text', value: file.contents.slice( position.start.offset, position.end.offset) + .replace('<', '<') + .replace('>', '>') .replace(/\\(.{1})/g, '$1'), position }];