2016-03-08 08:20:23 -05:00
|
|
|
// Generated by CoffeeScript 1.10.0
|
|
|
|
define(function() {
|
2016-03-08 11:18:02 -05:00
|
|
|
var BibLogParser, LINE_SPLITTER_REGEX, MESSAGE_LEVELS;
|
2016-03-08 08:20:23 -05:00
|
|
|
LINE_SPLITTER_REGEX = /^\[(\d+)].*>\s(INFO|WARN|ERROR)\s-\s(.*)$/;
|
|
|
|
MESSAGE_LEVELS = {
|
|
|
|
"INFO": "info",
|
|
|
|
"WARN": "warning",
|
|
|
|
"ERROR": "error"
|
|
|
|
};
|
2016-03-08 11:18:02 -05:00
|
|
|
BibLogParser = function(text, options) {
|
2016-03-08 08:20:23 -05:00
|
|
|
if (typeof text !== 'string') {
|
2016-03-08 11:18:02 -05:00
|
|
|
throw new Error("BibLogParser Error: text parameter must be a string");
|
2016-03-08 08:20:23 -05:00
|
|
|
}
|
|
|
|
this.text = text.replace(/(\r\n)|\r/g, '\n');
|
2016-03-08 08:56:17 -05:00
|
|
|
this.options = options || {};
|
2016-03-08 08:20:23 -05:00
|
|
|
this.lines = text.split('\n');
|
|
|
|
};
|
|
|
|
(function() {
|
|
|
|
return this.parse = function() {
|
|
|
|
var result;
|
|
|
|
result = {
|
|
|
|
all: [],
|
|
|
|
errors: [],
|
|
|
|
warnings: [],
|
|
|
|
files: [],
|
|
|
|
typesetting: []
|
|
|
|
};
|
|
|
|
this.lines.forEach(function(line) {
|
2016-03-08 08:56:17 -05:00
|
|
|
var _, fileName, fullLine, lineMatch, lineNumber, match, message, messageType, newEntry, realMessage;
|
2016-03-08 08:20:23 -05:00
|
|
|
match = line.match(LINE_SPLITTER_REGEX);
|
|
|
|
if (match) {
|
|
|
|
fullLine = match[0], lineNumber = match[1], messageType = match[2], message = match[3];
|
|
|
|
newEntry = {
|
|
|
|
file: null,
|
|
|
|
level: MESSAGE_LEVELS[messageType] || "INFO",
|
|
|
|
message: message,
|
|
|
|
line: null,
|
|
|
|
raw: fullLine
|
|
|
|
};
|
2016-03-08 09:04:42 -05:00
|
|
|
lineMatch = newEntry.message.match(/^BibTeX subsystem: \/.+\/(\w+\.\w+)_.+, line (\d+), (.+)$/);
|
2016-03-08 08:56:17 -05:00
|
|
|
if (lineMatch && lineMatch.length === 4) {
|
|
|
|
_ = lineMatch[0], fileName = lineMatch[1], lineNumber = lineMatch[2], realMessage = lineMatch[3];
|
|
|
|
newEntry.file = fileName;
|
|
|
|
newEntry.line = lineNumber;
|
|
|
|
newEntry.message = realMessage;
|
|
|
|
}
|
2016-03-08 08:20:23 -05:00
|
|
|
result.all.push(newEntry);
|
|
|
|
switch (newEntry.level) {
|
|
|
|
case 'error':
|
|
|
|
return result.errors.push(newEntry);
|
|
|
|
case 'warning':
|
|
|
|
return result.warnings.push(newEntry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
};
|
2016-03-08 11:18:02 -05:00
|
|
|
}).call(BibLogParser.prototype);
|
|
|
|
BibLogParser.parse = function(text, options) {
|
|
|
|
return new BibLogParser(text, options).parse();
|
2016-03-08 08:20:23 -05:00
|
|
|
};
|
2016-03-08 11:18:02 -05:00
|
|
|
return BibLogParser;
|
2016-03-08 08:20:23 -05:00
|
|
|
});
|