diff --git a/src/printer-markdown.js b/src/printer-markdown.js index 4a6cfe3a6..da68a8719 100644 --- a/src/printer-markdown.js +++ b/src/printer-markdown.js @@ -87,8 +87,8 @@ function genericPrint(path, options, print) { const index = parentNode.children.indexOf(node); const nextNode = parentNode.children[index + 1]; - // special prefix that may cause different meaning - if (nextNode && nextNode.value.match(/^(#{1,6}|>+)|^(-|\+|\*)$/)) { + // leading char that may cause different syntax + if (nextNode && /^>|^([-+*]|#{1,6})$/.test(nextNode.value)) { return node.value === "" ? "" : " "; } @@ -104,15 +104,15 @@ function genericPrint(path, options, print) { prevNode.type === "sentence" && prevNode.children.length > 0 && prevNode.children[prevNode.children.length - 1].type === "word" && - prevNode.children[prevNode.children.length - 1].value.match( - new RegExp(`[^${asciiPunctuationPattern}]$`) + new RegExp(`[^${asciiPunctuationPattern}]$`).test( + prevNode.children[prevNode.children.length - 1].value )) || (nextNode && nextNode.type === "sentence" && nextNode.children.length > 0 && nextNode.children[0].type === "word" && - nextNode.children[0].value.match( - new RegExp(`^[^${asciiPunctuationPattern}]`) + new RegExp(`^[^${asciiPunctuationPattern}]`).test( + nextNode.children[0].value )); const style = hasPrevOrNextWord || getAncestorNode(path, "emphasis") ? "*" : "_";