Skip to content

Commit 3795476

Browse files
chore: use template literal on some few places (#2419)
* use template literal on some few places * Update src/Renderer.js Co-authored-by: Tony Brix <tony@brix.ninja> Co-authored-by: Tony Brix <tony@brix.ninja>
1 parent c26c4ab commit 3795476

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

src/Renderer.js

+18-25
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class Renderer {
4242
* @param {string} quote
4343
*/
4444
blockquote(quote) {
45-
return '<blockquote>\n' + quote + '</blockquote>\n';
45+
return `<blockquote>\n${quote}</blockquote>\n`;
4646
}
4747

4848
html(html) {
@@ -57,19 +57,12 @@ export class Renderer {
5757
*/
5858
heading(text, level, raw, slugger) {
5959
if (this.options.headerIds) {
60-
return '<h'
61-
+ level
62-
+ ' id="'
63-
+ this.options.headerPrefix
64-
+ slugger.slug(raw)
65-
+ '">'
66-
+ text
67-
+ '</h'
68-
+ level
69-
+ '>\n';
60+
const id = this.options.headerPrefix + slugger.slug(raw);
61+
return `<h${level} id="${id}">${text}</h${level}>\n`;
7062
}
63+
7164
// ignore IDs
72-
return '<h' + level + '>' + text + '</h' + level + '>\n';
65+
return `<h${level}>${text}</h${level}>\n`;
7366
}
7467

7568
hr() {
@@ -86,7 +79,7 @@ export class Renderer {
8679
* @param {string} text
8780
*/
8881
listitem(text) {
89-
return '<li>' + text + '</li>\n';
82+
return `<li>${text}</li>\n`;
9083
}
9184

9285
checkbox(checked) {
@@ -101,15 +94,15 @@ export class Renderer {
10194
* @param {string} text
10295
*/
10396
paragraph(text) {
104-
return '<p>' + text + '</p>\n';
97+
return `<p>${text}</p>\n`;
10598
}
10699

107100
/**
108101
* @param {string} header
109102
* @param {string} body
110103
*/
111104
table(header, body) {
112-
if (body) body = '<tbody>' + body + '</tbody>';
105+
if (body) body = `<tbody>${body}</tbody>`;
113106

114107
return '<table>\n'
115108
+ '<thead>\n'
@@ -123,37 +116,37 @@ export class Renderer {
123116
* @param {string} content
124117
*/
125118
tablerow(content) {
126-
return '<tr>\n' + content + '</tr>\n';
119+
return `<tr>\n${content}</tr>\n`;
127120
}
128121

129122
tablecell(content, flags) {
130123
const type = flags.header ? 'th' : 'td';
131124
const tag = flags.align
132-
? '<' + type + ' align="' + flags.align + '">'
133-
: '<' + type + '>';
134-
return tag + content + '</' + type + '>\n';
125+
? `<${type} align="${flags.align}">`
126+
: `<${type}>`;
127+
return tag + content + `</${type}>\n`;
135128
}
136129

137130
/**
138131
* span level renderer
139132
* @param {string} text
140133
*/
141134
strong(text) {
142-
return '<strong>' + text + '</strong>';
135+
return `<strong>${text}</strong>`;
143136
}
144137

145138
/**
146139
* @param {string} text
147140
*/
148141
em(text) {
149-
return '<em>' + text + '</em>';
142+
return `<em>${text}</em>`;
150143
}
151144

152145
/**
153146
* @param {string} text
154147
*/
155148
codespan(text) {
156-
return '<code>' + text + '</code>';
149+
return `<code>${text}</code>`;
157150
}
158151

159152
br() {
@@ -164,7 +157,7 @@ export class Renderer {
164157
* @param {string} text
165158
*/
166159
del(text) {
167-
return '<del>' + text + '</del>';
160+
return `<del>${text}</del>`;
168161
}
169162

170163
/**
@@ -196,9 +189,9 @@ export class Renderer {
196189
return text;
197190
}
198191

199-
let out = '<img src="' + href + '" alt="' + text + '"';
192+
let out = `<img src="${href}" alt="${text}"`;
200193
if (title) {
201-
out += ' title="' + title + '"';
194+
out += ` title="${title}"`;
202195
}
203196
out += this.options.xhtml ? '/>' : '>';
204197
return out;

0 commit comments

Comments
 (0)