diff --git a/helpers/markdown.js b/helpers/markdown.js
index e73558af..50781923 100644
--- a/helpers/markdown.js
+++ b/helpers/markdown.js
@@ -3,7 +3,10 @@
const Posts = require(__dirname+'/../db-models/posts.js')
, quoteRegex = /^>>\d+/g
, greentextRegex = /^>[^>].+/g
- , redtextRegex = /^<[^<].+/g;
+ , redtextRegex = /^<[^<].+/g
+ , boldRegex = /==.+==/g
+ , italicRegex = /__.+__/g
+ , spoilerRegex = /\|.+\|/g;
module.exports = (board, thread, text) => {
@@ -31,6 +34,27 @@ module.exports = (board, thread, text) => {
lines[j] = lines[j].replace(redtext[0], `<${red}`);
continue;
}
+ //replace bolds
+ const boldtext = lines[j].match(boldRegex);
+ if (boldtext) {
+ const bold = boldtext[0].substring(2, boldtext[0].length-2);
+ lines[j] = lines[j].replace(boldtext[0], `${bold}`);
+ continue;
+ }
+ //replace italics
+ const italictext = lines[j].match(italicRegex);
+ if (italictext) {
+ const italic = italictext[0].substring(2, italictext[0].length-2);
+ lines[j] = lines[j].replace(italictext[0], `${italic}`);
+ continue;
+ }
+ //replace spoilers
+ const spoilertext = lines[j].match(spoilerRegex);
+ if (spoilertext) {
+ const spoiler = spoilertext[0].substring(1, spoilertext[0].length-1);
+ lines[j] = lines[j].replace(spoilertext[0], `${spoiler}`);
+ continue;
+ }
}
return lines.join('\n');
diff --git a/models/forms/make-post.js b/models/forms/make-post.js
index f2589032..b85f4e24 100644
--- a/models/forms/make-post.js
+++ b/models/forms/make-post.js
@@ -11,7 +11,7 @@ const uuidv4 = require('uuid/v4')
, simpleMarkdown = require(__dirname+'/../../helpers/markdown.js')
, sanitize = require('sanitize-html')
, sanitizeOptions = {
- allowedTags: [ 'span', 'a' ],
+ allowedTags: [ 'span', 'a', 'code', 'em', 'strong' ],
allowedAttributes: {
'a': [ 'href', 'class' ],
'span': [ 'class' ]
@@ -162,6 +162,8 @@ module.exports = async (req, res, numFiles) => {
'thread': req.body.thread || null,
'password': req.body.password || '',
'userId': userId,
+ 'email': req.body.email || '',
+ 'ip': ip,
'files': files,
'salt': !req.body.thread ? salt : '',
'reports': []