Skip to content

Commit

Permalink
now the breaks work
Browse files Browse the repository at this point in the history
  • Loading branch information
Heinrich-XIAO committed Sep 25, 2024
1 parent 9b52ce6 commit cc79879
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/server/config/setupTranslations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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<br><br><br>\n')
};
supportedLanguages.push(languageCode); // Add language to list of supportedLanguages
Expand Down

0 comments on commit cc79879

Please sign in to comment.