From ef576edcac0adf9bbfa616c0b7dfa5c2da9a0751 Mon Sep 17 00:00:00 2001 From: NoScripter Date: Tue, 16 Apr 2019 15:16:27 +0800 Subject: [PATCH] refactor: use positive lookahead in RegExp Since negative lookbehind is relatively new(which got accepted in ECMAScript in 2018) and only v8 and node.js behind v9 without a flag support it, it's more convenient and compatible to use positive lookahead instead. ref: https://stackoverflow.com/questions/641407/javascript-negative-lookbehind-equivalent --- lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index ce9d62d..98399b9 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -14,7 +14,7 @@ exports.escapePipesInTables = str => { let line = lines[i]; if (/^\s*\|.*?\|\s*$/.test(line)) { - lines[i] = line.replace(/(? { + lines[i] = line.replace(/(?:[^`])`((?:\\`|[^`])+)`(?!`)/g, m => { return m.replace(/\s*\|\s*/g, '\\|'); }); }