tools: replace string concetation with templates
Replace string concatenation in tools/doc/html.js with template literals. PR-URL: https://github.com/nodejs/node/pull/16801 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
b55106fcab
commit
94fb298819
@ -499,12 +499,12 @@ function buildToc(lexed, filename, cb) {
|
|||||||
|
|
||||||
depth = tok.depth;
|
depth = tok.depth;
|
||||||
const realFilename = path.basename(realFilenames[0], '.md');
|
const realFilename = path.basename(realFilenames[0], '.md');
|
||||||
const id = getId(realFilename + '_' + tok.text.trim());
|
const id = getId(`${realFilename}_${tok.text.trim()}`);
|
||||||
toc.push(new Array((depth - 1) * 2 + 1).join(' ') +
|
toc.push(new Array((depth - 1) * 2 + 1).join(' ') +
|
||||||
`* <span class="stability_${tok.stability}">` +
|
`* <span class="stability_${tok.stability}">` +
|
||||||
`<a href="#${id}">${tok.text}</a></span>`);
|
`<a href="#${id}">${tok.text}</a></span>`);
|
||||||
tok.text += '<span><a class="mark" href="#' + id + '" ' +
|
tok.text += `<span><a class="mark" href="#${id}"` +
|
||||||
'id="' + id + '">#</a></span>';
|
`id="${id}">#</a></span>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
toc = marked.parse(toc.join('\n'));
|
toc = marked.parse(toc.join('\n'));
|
||||||
@ -518,7 +518,7 @@ function getId(text) {
|
|||||||
text = text.replace(/^_+|_+$/, '');
|
text = text.replace(/^_+|_+$/, '');
|
||||||
text = text.replace(/^([^a-z])/, '_$1');
|
text = text.replace(/^([^a-z])/, '_$1');
|
||||||
if (idCounters.hasOwnProperty(text)) {
|
if (idCounters.hasOwnProperty(text)) {
|
||||||
text += '_' + (++idCounters[text]);
|
text += `_${(++idCounters[text])}`;
|
||||||
} else {
|
} else {
|
||||||
idCounters[text] = 0;
|
idCounters[text] = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user