Parse links in the comments

Co-Authored-By: Samantaz Fox <coding@samantaz.fr>
This commit is contained in:
ChunkyProgrammer
2024-04-10 21:31:39 -04:00
parent de2287963f
commit fbf07e18aa
3 changed files with 22 additions and 10 deletions

View File

@@ -7,7 +7,19 @@ private def copy_string(str : String::Builder, iter : Iterator, count : Int) : I
cp = iter.next
break if cp.is_a?(Iterator::Stop)
str << cp.chr
if cp == 0x26 # Ampersand (&)
str << "&amp;"
elsif cp == 0x27 # Single quote (')
str << "&#39;"
elsif cp == 0x22 # Double quote (")
str << "&quot;"
elsif cp == 0x3C # Less-than (<)
str << "&lt;"
elsif cp == 0x3E # Greater than (>)
str << "&gt;"
else
str << cp.chr
end
# A codepoint from the SMP counts twice
copied += 1 if cp > 0xFFFF