From 3795476d1f152803b42e22dea5a489e2bc32c8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20W=C3=A4rting?= Date: Sat, 2 Apr 2022 23:45:33 +0200 Subject: [PATCH] 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 Co-authored-by: Tony Brix --- src/Renderer.js | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/Renderer.js b/src/Renderer.js index d3aa610c69..7c36a7554e 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -42,7 +42,7 @@ export class Renderer { * @param {string} quote */ blockquote(quote) { - return '
\n' + quote + '
\n'; + return `
\n${quote}
\n`; } html(html) { @@ -57,19 +57,12 @@ export class Renderer { */ heading(text, level, raw, slugger) { if (this.options.headerIds) { - return '' - + text - + '\n'; + const id = this.options.headerPrefix + slugger.slug(raw); + return `${text}\n`; } + // ignore IDs - return '' + text + '\n'; + return `${text}\n`; } hr() { @@ -86,7 +79,7 @@ export class Renderer { * @param {string} text */ listitem(text) { - return '
  • ' + text + '
  • \n'; + return `
  • ${text}
  • \n`; } checkbox(checked) { @@ -101,7 +94,7 @@ export class Renderer { * @param {string} text */ paragraph(text) { - return '

    ' + text + '

    \n'; + return `

    ${text}

    \n`; } /** @@ -109,7 +102,7 @@ export class Renderer { * @param {string} body */ table(header, body) { - if (body) body = '' + body + ''; + if (body) body = `${body}`; return '\n' + '\n' @@ -123,15 +116,15 @@ export class Renderer { * @param {string} content */ tablerow(content) { - return '\n' + content + '\n'; + return `\n${content}\n`; } tablecell(content, flags) { const type = flags.header ? 'th' : 'td'; const tag = flags.align - ? '<' + type + ' align="' + flags.align + '">' - : '<' + type + '>'; - return tag + content + '\n'; + ? `<${type} align="${flags.align}">` + : `<${type}>`; + return tag + content + `\n`; } /** @@ -139,21 +132,21 @@ export class Renderer { * @param {string} text */ strong(text) { - return '' + text + ''; + return `${text}`; } /** * @param {string} text */ em(text) { - return '' + text + ''; + return `${text}`; } /** * @param {string} text */ codespan(text) { - return '' + text + ''; + return `${text}`; } br() { @@ -164,7 +157,7 @@ export class Renderer { * @param {string} text */ del(text) { - return '' + text + ''; + return `${text}`; } /** @@ -196,9 +189,9 @@ export class Renderer { return text; } - let out = '' + text + '' : '>'; return out;