Improving log support in LaTeX parser

This commit is contained in:
Arthur Guiot
2020-09-10 16:24:53 -04:00
parent 874b5748c3
commit d014f4f5a4
+10 -5
View File
@@ -184,19 +184,24 @@ public extension Parser {
}
// Finding Group2
open = 1
index += 1 // skipping `(`
index += 6 // skipping `\\left(`
let endg1 = index
while open > 0 {
guard index < out.count else { return latex }
if out[index] == "(" {
guard index + 6 < out.count else { return latex }
if out[index..<index + 6] == "\\left(" {
open += 1
} else if out[index] == ")" {
index += 5
} else if out[index...index + 6] == "\\right)" {
open -= 1
index += 6
}
index += 1
}
let g2start = out.index(out.startIndex, offsetBy: endg1)
let g2end = out.index(out.startIndex, offsetBy: index - 1)
let g2end = out.index(out.startIndex, offsetBy: index - 7)
guard g2start < g2end else { return latex }
let group2 = out[g2start..<g2end]