Skip to content

Commit

Permalink
tools: replace string concetation with templates
Browse files Browse the repository at this point in the history
Replace string concatenation in tools/doc/html.js with template
literals.

PR-URL: #16801
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
Patrick Heneise authored and cjihrig committed Nov 6, 2017
1 parent bcd818a commit 422d315
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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;
}
Expand Down

0 comments on commit 422d315

Please sign in to comment.