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

use template literal on some few places #2419

Merged
merged 2 commits into from
Apr 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 18 additions & 25 deletions src/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Renderer {
}

blockquote(quote) {
return '<blockquote>\n' + quote + '</blockquote>\n';
return `<blockquote>\n${quote}</blockquote>\n`;
}

html(html) {
Expand All @@ -48,19 +48,12 @@ export class Renderer {

heading(text, level, raw, slugger) {
if (this.options.headerIds) {
return '<h'
+ level
+ ' id="'
+ this.options.headerPrefix
+ slugger.slug(raw)
+ '">'
+ text
+ '</h'
+ level
+ '>\n';
const id = this.options.headerPrefix + slugger.slug(raw);
return `<h${level} id="${id}">${text}</h${level}>\n`;
}

// ignore IDs
return '<h' + level + '>' + text + '</h' + level + '>\n';
return `<h${level}>${text}</h${level}>\n`;
}

hr() {
Expand All @@ -74,7 +67,7 @@ export class Renderer {
}

listitem(text) {
return '<li>' + text + '</li>\n';
return `<li>${text}</li>\n`;
}

checkbox(checked) {
Expand All @@ -86,11 +79,11 @@ export class Renderer {
}

paragraph(text) {
return '<p>' + text + '</p>\n';
return `<p>${text}</p>\n`;
}

table(header, body) {
if (body) body = '<tbody>' + body + '</tbody>';
if (body) body = `<tbody>${body}</tbody>`;

return '<table>\n'
+ '<thead>\n'
Expand All @@ -101,36 +94,36 @@ export class Renderer {
}

tablerow(content) {
return '<tr>\n' + content + '</tr>\n';
return `<tr>\n${content}</tr>\n`;
}

tablecell(content, flags) {
const type = flags.header ? 'th' : 'td';
const tag = flags.align
? '<' + type + ' align="' + flags.align + '">'
: '<' + type + '>';
return tag + content + '</' + type + '>\n';
? `<${type} align="${flags.align}">`
: `<${type}>`;
return tag + content + `</${type}>\n`;
}

// span level renderer
strong(text) {
return '<strong>' + text + '</strong>';
return `<strong>${text}</strong>`;
}

em(text) {
return '<em>' + text + '</em>';
return `<em>${text}</em>`;
}

codespan(text) {
return '<code>' + text + '</code>';
return `<code>${text}</code>`;
}

br() {
return this.options.xhtml ? '<br/>' : '<br>';
}

del(text) {
return '<del>' + text + '</del>';
return `<del>${text}</del>`;
}

link(href, title, text) {
Expand All @@ -152,9 +145,9 @@ export class Renderer {
return text;
}

let out = '<img src="' + href + '" alt="' + text + '"';
let out = `<img src="${href}" alt="${text}"`;
if (title) {
out += ' title="' + title + '"';
out += ` title="${title}"`;
}
out += this.options.xhtml ? '/>' : '>';
return out;
Expand Down