@@ -29,6 +29,7 @@ import org.nsh07.wikireader.data.LanguageData.alpha3CodeToAlpha2CodeMap
2929import org.nsh07.wikireader.data.LanguageData.countryNameToAlpha2CodeMap
3030import org.nsh07.wikireader.data.LanguageData.fifaCodeToAlpha3CodeMap
3131import org.nsh07.wikireader.data.countryFlag
32+ import org.nsh07.wikireader.data.formatToHumanReadable
3233import org.nsh07.wikireader.data.langCodeToName
3334import org.nsh07.wikireader.parser.ReferenceData.refCount
3435import org.nsh07.wikireader.parser.ReferenceData.refList
@@ -704,6 +705,15 @@ fun String.toWikitextAnnotatedString(
704705 append(' .' )
705706 }
706707
708+ currSubstring.startsWith(" {{format price" , true ) -> {
709+ val curr = currSubstring.substringAfter(' |' ).substringBefore(' |' )
710+ append(
711+ if (curr.contains(' .' )) curr.toDoubleOrNull()
712+ ?.formatToHumanReadable() ? : curr.twas()
713+ else curr.toLongOrNull()?.formatToHumanReadable() ? : curr.twas()
714+ )
715+ }
716+
707717 currSubstring.startsWith(" {{for" , true ) -> {
708718 val splitList = currSubstring.substringAfter(' |' ).split(' |' )
709719 if (splitList.size > 1 ) {
@@ -727,6 +737,13 @@ fun String.toWikitextAnnotatedString(
727737 }
728738 }
729739
740+ currSubstring.startsWith(" {{US$" , true ) -> {
741+ if (currSubstring.contains(' |' )) {
742+ val curr = currSubstring.substringAfter(' |' )
743+ append(" US$${curr.twas()} " )
744+ } else append(" US$" )
745+ }
746+
730747 currSubstring.startsWith(" {{hatnote" , ignoreCase = true ) -> {
731748 val curr = currSubstring.substringAfter(' |' ).replace(' \n ' , ' ' )
732749 append(" ''$curr ''" .twas())
@@ -971,7 +988,7 @@ fun String.toWikitextAnnotatedString(
971988 )
972989 }
973990
974- currSubstring.startsWith(" {{unbulleted list" ) -> {
991+ currSubstring.startsWith(" {{unbulleted list" , true ) -> {
975992 val splitList = currSubstring
976993 .substringAfter(' |' , " " )
977994 .splitNotInBraces(' |' )
@@ -982,6 +999,30 @@ fun String.toWikitextAnnotatedString(
982999 append(splitList.twas())
9831000 }
9841001
1002+ listOf (
1003+ " {{bulleted list" ,
1004+ " {{ulist" ,
1005+ " {{blist" ,
1006+ " {{bulleted" ,
1007+ " {{unordered list"
1008+ ).fastAny {
1009+ currSubstring.startsWith(it, true )
1010+ } -> {
1011+ val splitList = currSubstring
1012+ .substringAfter(' |' , " " )
1013+ .splitNotInBraces(' |' )
1014+ .fastMap {
1015+ if (it.trim()
1016+ .matches(" \\ d+=.+" .toRegex(RegexOption .DOT_MATCHES_ALL ))
1017+ )
1018+ it.substringAfter(' =' ).trim()
1019+ else it.trim()
1020+ }
1021+ .joinToString(" \n * " )
1022+
1023+ append(" * $splitList " .twas())
1024+ }
1025+
9851026 currSubstring.startsWith(" {{Transcluded section" , true ) -> {
9861027 val title =
9871028 currSubstring.split(' |' ).filter { it.contains(" source=" ) }
@@ -1043,13 +1084,21 @@ fun String.toWikitextAnnotatedString(
10431084 )
10441085 }
10451086
1046- currSubstring.startsWith(" {{siglo" , true ) -> {
1087+ listOf (" {{siglo" , " {{segle" ).fastAny {
1088+ currSubstring.startsWith(it, true )
1089+ } -> {
10471090 // Spanish/Catalan template for century
10481091 val first = currSubstring.substringAfter(" {{" ).substringBefore(' |' )
10491092 val second = currSubstring.substringAfter(' |' ).substringBefore(' |' )
10501093 append(" $first <small>$second </small>" .twas())
10511094 }
10521095
1096+ currSubstring.startsWith(" {{romanes" , true ) -> {
1097+ // Spanish/Catalan template for roman numerals
1098+ val second = currSubstring.substringAfter(' |' ).substringBefore(' |' )
1099+ append(" <small>$second </small>" .twas())
1100+ }
1101+
10531102 currSubstring.startsWith(" {{tracce" , true ) -> {
10541103 // Italian template for music track lists
10551104 val splitList = currSubstring.substringAfter(' |' )
@@ -1304,5 +1353,5 @@ object ReferenceData {
13041353 val refListCount = mutableMapOf<String , Int >()
13051354 var refTemplate = " {{cite"
13061355 val refTemplates = listOf (" {{cite" , " {{lien" , " {{cita|" )
1307- val infoboxTemplates = listOf (" {{infobox" , " {{taxobox" , " {{Automatic taxobox" )
1356+ val infoboxTemplates = listOf (" {{infobox" , " {{taxobox" , " {{Automatic taxobox" , " {{Картка " )
13081357}
0 commit comments