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 MylesBorins committed Oct 17, 2017
1 parent b43fed4 commit 97cf4f1
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 @@ -15,7 +15,7 @@ const DOC_CREATED_REG_EXP = /<!--\s*introduced_in\s*=\s*v([0-9]+)\.([0-9]+)\.([0
// customized heading without id attribute
var 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 @@ -85,7 +85,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 @@ -130,7 +130,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 @@ -448,8 +448,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 97cf4f1

Please sign in to comment.