fix: list item whitespace in html to plain text

This commit is contained in:
relikd
2025-07-21 13:57:30 +02:00
parent f65c5b9546
commit 6ef23ef599

View File

@@ -51,8 +51,8 @@
if (last != '\n') { if (last != '\n') {
[result appendString:@"\n"]; [result appendString:@"\n"];
} }
if (order > 0) [result appendFormat:@" %d. ", order++]; if (order > 0) [result appendFormat:@" %d. ", order++];
else [result appendString:@""]; else [result appendString:@" • "];
} }
} else { } else {
// append text inbetween tags // append text inbetween tags
@@ -74,7 +74,10 @@
// collapsing multiple horizontal whitespaces (\h) into one (the first one) // collapsing multiple horizontal whitespaces (\h) into one (the first one)
[[NSRegularExpression regularExpressionWithPattern:@"(\\h)[\\h]+" options:0 error:nil] [[NSRegularExpression regularExpressionWithPattern:@"(\\h)[\\h]+" options:0 error:nil]
replaceMatchesInString:result options:0 range:NSMakeRange(0, result.length) withTemplate:@"$1"]; replaceMatchesInString:result options:0 range:NSMakeRange(0, result.length) withTemplate:@"$1"];
return [result stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
NSMutableCharacterSet *cs = NSMutableCharacterSet.whitespaceAndNewlineCharacterSet;
[cs removeCharactersInString:@" "]; // used for "li"
return [result stringByTrimmingCharactersInSet:cs];
} }