From 2a5c2403997fc040e0799b7bc0807d023ff47c46 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 3 Mar 2024 19:36:23 +0200 Subject: [PATCH] Fix for old iOS --- public/scripts/showdown-underscore.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/public/scripts/showdown-underscore.js b/public/scripts/showdown-underscore.js index 1ff3bdabd..78a1adef7 100644 --- a/public/scripts/showdown-underscore.js +++ b/public/scripts/showdown-underscore.js @@ -1,15 +1,20 @@ // Showdown extension that replaces words surrounded by singular underscores with tags export const markdownUnderscoreExt = () => { - if (!canUseNegativeLookbehind()) { - console.log('Showdown-underscore extension: Negative lookbehind not supported. Skipping.'); + try { + if (!canUseNegativeLookbehind()) { + console.log('Showdown-underscore extension: Negative lookbehind not supported. Skipping.'); + return []; + } + + return [{ + type: 'lang', + regex: new RegExp('\\b(?$1', + }]; + } catch (e) { + console.error('Error in Showdown-underscore extension:', e); return []; } - - return [{ - type: 'lang', - regex: /\b(?$1', - }]; }; function canUseNegativeLookbehind() {