Remove the nbsp change, as it is not necessary

This commit is contained in:
gingerBill
2026-01-19 19:30:37 +00:00
parent 093f088396
commit 85b3251105

View File

@@ -263,7 +263,7 @@ xml_decode_entity :: proc(entity: string) -> (decoded: [2]rune, rune_count: int,
// escape_html escapes special characters like '&' to become '&'.
// It escapes only 6 different characters: & ' < > " and non-breaking space.
// It escapes only 5 different characters: & ' < > and "
@(require_results)
escape_html :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (output: string, was_allocation: bool) {
/*
@@ -272,21 +272,19 @@ escape_html :: proc(s: string, allocator := context.allocator, loc := #caller_lo
< -> &lt;
> -> &gt;
" -> &#34; // &#34; is shorter than &quot;
0x6a -> &nbsp;
*/
b := transmute([]byte)s
extra_bytes_needed := 0
for c in b {
for c, i in b {
switch c {
case '&': extra_bytes_needed += 4
case '\'': extra_bytes_needed += 4
case '<': extra_bytes_needed += 3
case '>': extra_bytes_needed += 3
case '"': extra_bytes_needed += 4
case 0xa0: extra_bytes_needed += 5
}
}
@@ -309,7 +307,6 @@ escape_html :: proc(s: string, allocator := context.allocator, loc := #caller_lo
case '<': x = "&lt;"
case '>': x = "&gt;"
case '"': x = "&#34;"
case 0xa0: x = "&nbsp;"
}
if x != "" {
copy(t[w:], x)