breakUpTexStrings static method
Implementation
static List<String> breakUpTexStrings(String texString,
List<String> subStringToIsolate, Map<String, Color> texToColorMap) {
var texStrings = texString.splitWithContent(RegExp('{{(.*?)}}'));
var patterns = [
for (var ss in [...texToColorMap.keys, ...subStringToIsolate])
'(${RegExp.escape(ss)})'
];
var pattern = patterns.join('|');
var pieces = <String>[];
if (pattern.isNotEmpty) {
var regex = RegExp(pattern);
for (var s in texStrings) {
pieces.addAll(s.splitWithContent(regex));
}
} else {
pieces = texStrings;
}
return [
for (var p in pieces)
if (p.isNotEmpty) p
];
}