chktex-log-parser.js 585 B

12345678910111213141516171819202122232425262728
  1. export const ChkTeXParser = {
  2. parse(log) {
  3. const errors = []
  4. const warnings = []
  5. for (const line of log.split('\n')) {
  6. const m = line.match(/^(\S+):(\d+):(\d+): (Error|Warning): (.*)/)
  7. if (m) {
  8. const result = {
  9. file: m[1],
  10. line: m[2],
  11. column: m[3],
  12. level: m[4].toLowerCase(),
  13. message: `${m[4]}: ${m[5]}`,
  14. }
  15. if (result.level === 'error') {
  16. errors.push(result)
  17. } else {
  18. warnings.push(result)
  19. }
  20. }
  21. }
  22. return { errors, warnings }
  23. },
  24. }