overleaf/services/web/frontend/js/features/pdf-preview/util/chktex-log-parser.js
Alf Eaton 73bc3418a2 Add React version of the PDF preview pane (#5135)
GitOrigin-RevId: fcc88a362c3e97c9fddf85d47c3a83a0a0b89432
2021-10-01 08:03:12 +00:00

28 lines
585 B
JavaScript

export const ChkTeXParser = {
parse(log) {
const errors = []
const warnings = []
for (const line of log.split('\n')) {
const m = line.match(/^(\S+):(\d+):(\d+): (Error|Warning): (.*)/)
if (m) {
const result = {
file: m[1],
line: m[2],
column: m[3],
level: m[4].toLowerCase(),
message: `${m[4]}: ${m[5]}`,
}
if (result.level === 'error') {
errors.push(result)
} else {
warnings.push(result)
}
}
}
return { errors, warnings }
},
}