further enhance reply filtering

This commit is contained in:
Mystikfluu 2022-07-10 14:09:48 +02:00
parent 3377f45140
commit 084992bb18
2 changed files with 22 additions and 1 deletions

View File

@ -32,6 +32,11 @@ function filterReplies(text) {
return text.replace(textregex,`<span><a href="/users/$1" class="reply" style="color: pink;">$1</a></span> `)
}
/**
* 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
}

View File

@ -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")