Skip to content

Commit

Permalink
tools: use template literals
Browse files Browse the repository at this point in the history
PR-URL: #15956
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
sarahmeyer authored and BridgeAR committed Oct 8, 2017
1 parent b08ae3a commit 28a5fd0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const DOC_CREATED_REG_EXP = /<!--\s*introduced_in\s*=\s*v([0-9]+)\.([0-9]+)\.([0
// customized heading without id attribute
const renderer = new marked.Renderer();
renderer.heading = function(text, level) {
return '<h' + level + '>' + text + '</h' + level + '>\n';
return `<h${level}>${text}</h${level}>\n`;
};
marked.setOptions({
renderer: renderer
Expand Down Expand Up @@ -107,7 +107,7 @@ function loadGtoc(cb) {
if (err) return cb(err);

data = marked(data).replace(/<a href="(.*?)"/gm, function(a, m) {
return '<a class="nav-' + toID(m) + '" href="' + m + '"';
return `<a class="nav-${toID(m)}" href="${m}"`;
});
return cb(null, data);
});
Expand Down Expand Up @@ -152,7 +152,7 @@ function render(opts, cb) {
template = template.replace(/__TOC__/g, toc);
template = template.replace(
/__GTOC__/g,
gtocData.replace('class="nav-' + id, 'class="nav-' + id + ' active')
gtocData.replace(`class="nav-${id}`, `class="nav-${id} active`)
);

if (opts.analytics) {
Expand Down Expand Up @@ -500,8 +500,8 @@ function buildToc(lexed, filename, cb) {
const realFilename = path.basename(realFilenames[0], '.md');
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>');
`* <span class="stability_${tok.stability}">` +
`<a href="#${id}">${tok.text}</a></span>`);
tok.text += '<span><a class="mark" href="#' + id + '" ' +
'id="' + id + '">#</a></span>';
});
Expand Down

0 comments on commit 28a5fd0

Please sign in to comment.