diff --git a/helpers/markdown.js b/helpers/markdown.js
index 50781923..a0e100ce 100644
--- a/helpers/markdown.js
+++ b/helpers/markdown.js
@@ -1,62 +1,57 @@
'use strict';
const Posts = require(__dirname+'/../db-models/posts.js')
- , quoteRegex = /^>>\d+/g
- , greentextRegex = /^>[^>].+/g
- , redtextRegex = /^<[^<].+/g
- , boldRegex = /==.+==/g
- , italicRegex = /__.+__/g
- , spoilerRegex = /\|.+\|/g;
+ , quoteRegex = /^>>\d+$/gm
+ , greentextRegex = /^>[^>].+$/gm
+ , redtextRegex = /^<[^<].+$/gm
+ , boldRegex = /==.+==/gm
+ , italicRegex = /__.+__/gm
+ , linkRegex = /https?\:\/\/[^\s]+/g
+ , spoilerRegex = /\|.+\|/gm;
module.exports = (board, thread, text) => {
- const lines = text.split('\n')
-
- for(let j = 0; j < lines.length; j++) {
- //replace quotes
- const quote = lines[j].match(quoteRegex);
- if (quote) {
- const quotenum = quote[0].substring(2);
- lines[j] = lines[j].replace(quote[0], `>>${quotenum}`);
- continue;
- }
- //replace greentexts
- const greentext = lines[j].match(greentextRegex);
- if (greentext) {
- const green = greentext[0].substring(1);
- lines[j] = lines[j].replace(greentext[0], `>${green}`);
- continue;
- }
- //replace redtexts
- const redtext = lines[j].match(redtextRegex);
- if (redtext) {
- const red = redtext[0].substring(1);
- 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');
+ //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}`;
+ });
+
+ //quotes
+ text = text.replace(quoteRegex, (match) => {
+ const quotenum = match.substring(2);
+ return `>>${quotenum}`;
+ });
+
+ //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;
}
diff --git a/static/css/style.css b/static/css/style.css
index 97b60b3e..5a6d4c3d 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -204,8 +204,8 @@ input textarea {
}
.post-container:target, .op:target {
- outline: 1px dashed blue;
- outline-offset: -1px;
+ background-color: #d6bad0;
+ border-color: #ba9dbf;
}
.post-container.op {