From 810db1819d1874a5a0a170ac3d28cb2e5433278c Mon Sep 17 00:00:00 2001 From: Rafael Tavares <26308880+Rafatcb@users.noreply.github.com> Date: Wed, 31 Jan 2024 19:28:02 -0300 Subject: [PATCH] Remove unnecessary escapes --- index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index f025845..6a13bb0 100644 --- a/index.js +++ b/index.js @@ -16,9 +16,9 @@ module.exports = function(md, options) { try { if (options.stripListLeaders) { if (options.listUnicodeChar) - output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, options.listUnicodeChar + ' $1'); + output = output.replace(/^([\s\t]*)([*\-+]|\d+\.)\s+/gm, options.listUnicodeChar + ' $1'); else - output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, '$1'); + output = output.replace(/^([\s\t]*)([*\-+]|\d+\.)\s+/gm, '$1'); } if (options.gfm) { output = output @@ -57,14 +57,14 @@ module.exports = function(md, options) { // Remove HTML tags .replace(htmlReplaceRegex, '') // Remove setext-style headers - .replace(/^[=\-]{2,}\s*$/g, '') + .replace(/^[=-]{2,}\s*$/g, '') // Remove footnotes? - .replace(/\[\^.+?\](\: .*?$)?/g, '') + .replace(/\[\^.+?\](: .*?$)?/g, '') .replace(/\s{0,2}\[.*?\]: .*?$/g, '') // Remove images - .replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? '$1' : '') + .replace(/!\[(.*?)\][[(].*?[\])]/g, options.useImgAltText ? '$1' : '') // Remove inline links - .replace(/\[([^\]]*?)\][\[\(].*?[\]\)]/g, options.replaceLinksWithURL ? '$2' : '$1') + .replace(/\[([^\]]*?)\][[(].*?[\])]/g, options.replaceLinksWithURL ? '$2' : '$1') // Remove blockquotes .replace(/^(\n)?\s{0,3}>\s?/gm, '$1') // .replace(/(^|\n)\s{0,3}>\s?/g, '\n\n') @@ -73,7 +73,7 @@ module.exports = function(md, options) { // Remove atx-style headers .replace(/^(\n)?\s{0,}#{1,6}\s*( (.+))? +#+$|^(\n)?\s{0,}#{1,6}\s*( (.+))?$/gm, '$1$3$4$6') // Remove * emphasis - .replace(/([\*]+)(\S)(.*?\S)??\1/g, '$2$3') + .replace(/([*]+)(\S)(.*?\S)??\1/g, '$2$3') // Remove _ emphasis. Unlike *, _ emphasis gets rendered only if // 1. Either there is a whitespace character before opening _ and after closing _. // 2. Or _ is at the start/end of the string.