From 084992bb180981d99febe834039bd66fb2fa05dc Mon Sep 17 00:00:00 2001 From: Mystikfluu Date: Sun, 10 Jul 2022 14:09:48 +0200 Subject: [PATCH] further enhance reply filtering --- js/markdown.js | 21 +++++++++++++++++++++ js/posts.js | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/js/markdown.js b/js/markdown.js index 234513a..9130f0b 100644 --- a/js/markdown.js +++ b/js/markdown.js @@ -32,6 +32,11 @@ function filterReplies(text) { return text.replace(textregex,`$1 `) } +/** + * filter out html, as well as render some markdown into html + * @param {string} text text to filter/format + * @return {string} html that represents the filtered text + */ function filterPost(text) { text = htmlesc(text) text = newlineify(text) @@ -44,3 +49,19 @@ function filterPost(text) { return text } + +/** + * filter out html, as well as render some markdown into html, but without mentions + * @param {string} text text to filter/format + * @return {string} html that represents the filtered text + */ +function filterReply(text) { + text = htmlesc(text) + text = newlineify(text) + text = urlify(text) + text = crossout(text) + text = boldify(text) + text = italicify(text) + + return text +} diff --git a/js/posts.js b/js/posts.js index 56aa0f9..9ab3b33 100644 --- a/js/posts.js +++ b/js/posts.js @@ -130,7 +130,7 @@ async function createPost(username,text,time,specialtext,postid,isbot,reply_id) replyA.appendChild(replyAvatar) replyA.appendChild(reply_username_text) replyA.appendChild(spacerTextNode()) - replyA.innerHTML += filterPost(reply_text.replace("\n"," ").substring(0,20)) + replyA.innerHTML += filterReply(reply_text.replace("\n"," ").substring(0,20)) replyA.appendChild(replyBr) replyA.classList.add("no-link-style")