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:
Patrick Heneise 2017-11-06 15:01:55 +00:00 committed by Rich Trott
parent b55106fcab
commit 94fb298819

View File

@ -499,12 +499,12 @@ function buildToc(lexed, filename, cb) {
depth = tok.depth;
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(' ') +
`* <span class="stability_${tok.stability}">` +
`<a href="#${id}">${tok.text}</a></span>`);
tok.text += '<span><a class="mark" href="#' + id + '" ' +
'id="' + id + '">#</a></span>';
tok.text += `<span><a class="mark" href="#${id}"` +
`id="${id}">#</a></span>`;
});
toc = marked.parse(toc.join('\n'));
@ -518,7 +518,7 @@ function getId(text) {
text = text.replace(/^_+|_+$/, '');
text = text.replace(/^([^a-z])/, '_$1');
if (idCounters.hasOwnProperty(text)) {
text += '_' + (++idCounters[text]);
text += `_${(++idCounters[text])}`;
} else {
idCounters[text] = 0;
}