Merge pull request #6035 from overleaf/msm-remove-redundant-bibtex-error

Remove redundant >100 bibtex errors message

GitOrigin-RevId: b2487aaf3b31c469b5780f6d05e4cd124666adf5
This commit is contained in:
Timothée Alby 2021-12-14 14:25:14 +01:00 committed by Copybot
parent 44eca312ff
commit cf0a488a30
2 changed files with 45 additions and 41 deletions

View file

@ -15,7 +15,8 @@ const MESSAGE_LEVELS = {
ERROR: 'error',
}
const parserReducer = function (accumulator, parser) {
const parserReducer = function (maxErrors) {
return function (accumulator, parser) {
const consume = function (logText, regex, process) {
let match
let text = logText
@ -28,7 +29,6 @@ const parserReducer = function (accumulator, parser) {
// Too many log entries can cause browser crashes
// Construct a too many files error from the last match
const maxErrors = 100
if (iterationCount >= maxErrors) {
const level = newEntry.level + 's'
newEntry.message = [
@ -45,7 +45,10 @@ const parserReducer = function (accumulator, parser) {
result.push(newEntry)
text =
match.input.slice(0, match.index) +
match.input.slice(match.index + match[0].length + 1, match.input.length)
match.input.slice(
match.index + match[0].length + 1,
match.input.length
)
}
return [result, text]
}
@ -55,6 +58,7 @@ const parserReducer = function (accumulator, parser) {
const [errors, _remainingText] = consume(text, regex, process)
return [currentErrors.concat(errors), _remainingText]
}
}
export default class BibLogParser {
constructor(text, options) {
@ -174,13 +178,13 @@ export default class BibLogParser {
}
// reduce over the parsers, starting with the log text,
let [allWarnings, remainingText] = this.warningParsers.reduce(
parserReducer,
parserReducer(this.options.maxErrors),
[[], this.text]
)
;[allErrors, remainingText] = this.errorParsers.reduce(parserReducer, [
[],
remainingText,
])
;[allErrors, remainingText] = this.errorParsers.reduce(
parserReducer(this.options.maxErrors),
[[], remainingText]
)
result.warnings = allWarnings
result.errors = allErrors
result.all = allWarnings.concat(allErrors)

View file

@ -646,7 +646,7 @@ App.controller(
}
function processBiber(log) {
const bibLogParser = new BibLogParser(log, {})
const bibLogParser = new BibLogParser(log, { maxErrors: 100 })
const { errors, warnings } = bibLogParser.parse(log, {})
const all = [].concat(errors, warnings)
accumulateResults({ type: 'BibTeX:', all, errors, warnings })