tools: fix header escaping regression

quick fix for #22065

Preferred long term fix can be found at:
https://github.com/nodejs/node/pull/22140

PR-URL: https://github.com/nodejs/node/pull/22084
Fixes: https://github.com/nodejs/node/issues/22065
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Sam Ruby 2018-08-02 06:54:30 -04:00
parent f8fda89df1
commit 59f8276a6b
2 changed files with 5 additions and 2 deletions

View File

@ -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 })

View File

@ -198,7 +198,10 @@ function preprocessElements({ filename }) {
heading.children = [{
type: 'text',
value: file.contents.slice(
position.start.offset, position.end.offset),
position.start.offset, position.end.offset)
.replace('&lt;', '<')
.replace('&gt;', '>')
.replace(/\\(.{1})/g, '$1'),
position
}];
}