From d792e4064b8585625f699d917c2bf049d6fa0c44 Mon Sep 17 00:00:00 2001 From: Maksim Eltyshev Date: Sat, 30 Aug 2025 17:28:23 +0200 Subject: [PATCH] fix: Handle markdown-to-text errors gracefully --- client/src/utils/markdown-to-text.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/src/utils/markdown-to-text.js b/client/src/utils/markdown-to-text.js index 822ed855..25a5c66a 100644 --- a/client/src/utils/markdown-to-text.js +++ b/client/src/utils/markdown-to-text.js @@ -8,10 +8,15 @@ import transform from '@diplodoc/transform'; import plugins from '../configs/markdown-plugins'; export default (markdown) => { - const tokens = transform(markdown, { - plugins, - tokens: true, - }); + let tokens; + try { + tokens = transform(markdown, { + plugins, + tokens: true, + }); + } catch (error) { + return error.toString(); + } return tokens .flatMap((token) => {