Skip to content

Commit

Permalink
chore: use template literal on some few places (#2419)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
jimmywarting and UziTech committed Apr 2, 2022
1 parent c26c4ab commit 3795476
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions src/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Renderer {
* @param {string} quote
*/
blockquote(quote) {
return '<blockquote>\n' + quote + '</blockquote>\n';
return `<blockquote>\n${quote}</blockquote>\n`;
}

html(html) {
Expand All @@ -57,19 +57,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 @@ -86,7 +79,7 @@ export class Renderer {
* @param {string} text
*/
listitem(text) {
return '<li>' + text + '</li>\n';
return `<li>${text}</li>\n`;
}

checkbox(checked) {
Expand All @@ -101,15 +94,15 @@ export class Renderer {
* @param {string} text
*/
paragraph(text) {
return '<p>' + text + '</p>\n';
return `<p>${text}</p>\n`;
}

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

return '<table>\n'
+ '<thead>\n'
Expand All @@ -123,37 +116,37 @@ export class Renderer {
* @param {string} content
*/
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
* @param {string} text
*/
strong(text) {
return '<strong>' + text + '</strong>';
return `<strong>${text}</strong>`;
}

/**
* @param {string} text
*/
em(text) {
return '<em>' + text + '</em>';
return `<em>${text}</em>`;
}

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

br() {
Expand All @@ -164,7 +157,7 @@ export class Renderer {
* @param {string} text
*/
del(text) {
return '<del>' + text + '</del>';
return `<del>${text}</del>`;
}

/**
Expand Down Expand Up @@ -196,9 +189,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

2 comments on commit 3795476

@vercel
Copy link

@vercel vercel bot commented on 3795476 Apr 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

markedjs – ./

markedjs-markedjs-legacy.vercel.app
markedjs-git-master-markedjs-legacy.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 3795476 Apr 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.