Jesus they're not BBCode... They're html and bbcode and markdown

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
This commit is contained in:
2025-03-19 00:44:14 +01:00
parent 09b7fe539e
commit 40d251f400
12 changed files with 818 additions and 9 deletions

View File

@@ -1,4 +1,6 @@
/// Utility class to convert BBCode to Markdown for RimWorld mod descriptions
library bbcode_converter;
import 'dart:math' as math;
class BBCodeConverter {
@@ -21,10 +23,10 @@ class BBCodeConverter {
// Fix unclosed tags - RimWorld descriptions often have unclosed tags
final List<String> tagTypes = ['b', 'i', 'color', 'size', 'url', 'code', 'quote'];
for (final tag in tagTypes) {
final openCount = '[${tag}'.allMatches(result).length;
final closeCount = '[/${tag}]'.allMatches(result).length;
final openCount = '[$tag'.allMatches(result).length;
final closeCount = '[/$tag]'.allMatches(result).length;
if (openCount > closeCount) {
result = result + '[/${tag}]' * (openCount - closeCount);
result = result + '[/$tag]' * (openCount - closeCount);
}
}