mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
tools: use template literals
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
b08ae3a8e4
commit
28a5fd0528
1 file changed
+5
-5
+5
-5
@@ -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
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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) {
|
||||
@@ -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>';
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user