From cc7987957d1a2576fcca0625e6c21bf5d0e9331e Mon Sep 17 00:00:00 2001 From: Heinrich-XIAO <74563446+Heinrich-XIAO@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:04:48 -0500 Subject: [PATCH] now the breaks work --- src/server/config/setupTranslations.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/server/config/setupTranslations.js b/src/server/config/setupTranslations.js index 261b16b84..c189d9bcd 100644 --- a/src/server/config/setupTranslations.js +++ b/src/server/config/setupTranslations.js @@ -6,11 +6,7 @@ import ejs from "ejs"; import middleware from "i18next-http-middleware"; import { FilterXSS } from 'xss'; import { getDefaultLanguage, setSupportedLanguages } from '../utility/translate.js'; - import { marked } from 'marked'; -marked.use({ - breaks: true -}); import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -222,9 +218,12 @@ function loadTranslationsFolder(folder) { ), news: newsFiles.map(filePath => { const fullPath = path.join(folder, 'news', languageCode, filePath); + console.log(marked.parse((fs.existsSync(fullPath) ? + fs.readFileSync(fullPath) : + fs.readFileSync(path.join(folder, 'news', getDefaultLanguage(), filePath))).toString().replaceAll('\n\n', '\n\n\\\n'))); return marked.parse((fs.existsSync(fullPath) ? fs.readFileSync(fullPath) : - fs.readFileSync(path.join(folder, 'news', getDefaultLanguage(), filePath))).toString()); + fs.readFileSync(path.join(folder, 'news', getDefaultLanguage(), filePath))).toString().replaceAll(/(\r?\n){2}/g, '\n\n\u200B\n')); }).join('\n


\n') }; supportedLanguages.push(languageCode); // Add language to list of supportedLanguages