mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
[MIRROR] Ports Nebula's Discord Webhook Integration
This commit is contained in:
@@ -509,3 +509,23 @@ proc/TextPreview(var/string,var/len=40)
|
||||
var/charcount = count - length_char(text)
|
||||
var/list/chars_to_add[max(charcount + 1, 0)]
|
||||
return text + jointext(chars_to_add, char)
|
||||
|
||||
//Readds quotes and apostrophes to HTML-encoded strings
|
||||
/proc/readd_quotes(var/t)
|
||||
var/list/repl_chars = list(""" = "\"","'" = "'")
|
||||
for(var/char in repl_chars)
|
||||
var/index = findtext(t, char)
|
||||
while(index)
|
||||
t = copytext(t, 1, index) + repl_chars[char] + copytext(t, index+5)
|
||||
index = findtext(t, char)
|
||||
return t
|
||||
|
||||
// Rips out paper HTML but tries to keep it semi-readable.
|
||||
/proc/paper_html_to_plaintext(paper_text)
|
||||
paper_text = replacetext(paper_text, "<hr>", "-----")
|
||||
paper_text = replacetext(paper_text, "<li>", "- ") // This makes ordered lists turn into unordered but fixing that is too much effort.
|
||||
paper_text = replacetext(paper_text, "</li>", "\n")
|
||||
paper_text = replacetext(paper_text, "<p>", "\n")
|
||||
paper_text = replacetext(paper_text, "<br>", "\n")
|
||||
paper_text = strip_html_properly(paper_text) // Get rid of everything else entirely.
|
||||
return paper_text
|
||||
|
||||
Reference in New Issue
Block a user