Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: replace string concetation with template literals #16801

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])}`;
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Nov 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit (this can be done by whoever will land the PR): parentheses seem redundant now, this can simply be:

    text += `_${++idCounters[text]}`;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed this comment while landing. Doesn't seem worth force-pushing or doing an additional commit at this point to me, although if someone opens a PR for it, sure, I'm OK with that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
idCounters[text] = 0;
}
Expand Down