From a48c74b2e714e769c0fe714c189ea785990458f8 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Tue, 10 Aug 2021 23:42:46 -0400 Subject: [PATCH] Replace Regex Lookbehind with obnoxious workaround so Safari doesn't break --- shared/naturalcrit/markdown.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 01abc33a7..72783b41a 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -384,8 +384,10 @@ const splitCells = (tableRow, count, prevRow = [])=>{ return ` ${p1}`; } }); + tableRow = ` ${tableRow}`; - const cells = tableRow.split(/(?: \||(?<=\|)\|)(?=[^\|]|$)/g); + // Split into cells. Contents are: no pipes unless escaped. Add any ending pipes; if not don't include ending space + const cells = [...tableRow.matchAll(/(?:[^\|]+(?:\\\|)*)+(?:\|+(?=\|)|(?= \|))/g)].map((x)=>x[0]); let i = 0; // First/last cell in a row cannot be empty if it has no leading/trailing pipe