'use strict'; const Posts = require(__dirname+'/../db-models/posts.js') , greentextRegex = /^>[^>].+/gm , redtextRegex = /^<[^<].+/gm , boldRegex = /==.+==/gm , italicRegex = /__.+__/gm , linkRegex = /https?\:\/\/[^\s]+/g , spoilerRegex = /\|.+\|/gm; module.exports = (board, thread, text) => { //redtext text = text.replace(redtextRegex, (match) => { const red = match.substring(1); return `<${red}`; }); //greentext text = text.replace(greentextRegex, (match) => { const green = match.substring(1); return `>${green}`; }); //links text = text.replace(linkRegex, (match) => { return `${match}`; }); //bold text = text.replace(boldRegex, (match) => { const bold = match.substring(2, match.length-2); return `${bold}`; }); //italic text = text.replace(italicRegex, (match) => { const italic = match.substring(2, match.length-2); return `${italic}`; }); //spoilers text = text.replace(spoilerRegex, (match) => { const spoiler = match.substring(1, match.length-1); return `${spoiler}`; }); return text; }