removeStrayBraces static method
Implementation
static String removeStrayBraces(String tex) {
var numLefts = tex.count('{') - tex.count(r'\{') + tex.count(r'\\{');
var numRights = tex.count('}') - tex.count(r'\}') + tex.count(r'\\}');
while (numRights > numLefts) {
tex = '{' + tex;
numLefts++;
}
while (numLefts > numRights) {
tex = tex + '}';
numRights++;
}
return tex;
}