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,45 +15,49 @@ const MESSAGE_LEVELS = {
ERROR: 'error',
}
const parserReducer = function (accumulator, parser) {
const consume = function (logText, regex, process) {
let match
let text = logText
const result = []
const re = regex
let iterationCount = 0
while ((match = re.exec(text))) {
iterationCount += 1
const newEntry = process(match)
const parserReducer = function (maxErrors) {
return function (accumulator, parser) {
const consume = function (logText, regex, process) {
let match
let text = logText
const result = []
const re = regex
let iterationCount = 0
while ((match = re.exec(text))) {
iterationCount += 1
const newEntry = process(match)
// 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 = [
'Over',
maxErrors,
level,
'returned. Download raw logs to see full list',
].join(' ')
newEntry.line = undefined
result.unshift(newEntry)
return [result, '']
// Too many log entries can cause browser crashes
// Construct a too many files error from the last match
if (iterationCount >= maxErrors) {
const level = newEntry.level + 's'
newEntry.message = [
'Over',
maxErrors,
level,
'returned. Download raw logs to see full list',
].join(' ')
newEntry.line = undefined
result.unshift(newEntry)
return [result, '']
}
result.push(newEntry)
text =
match.input.slice(0, match.index) +
match.input.slice(
match.index + match[0].length + 1,
match.input.length
)
}
result.push(newEntry)
text =
match.input.slice(0, match.index) +
match.input.slice(match.index + match[0].length + 1, match.input.length)
return [result, text]
}
return [result, text]
}
const [currentErrors, text] = accumulator
const [regex, process] = parser
const [errors, _remainingText] = consume(text, regex, process)
return [currentErrors.concat(errors), _remainingText]
const [currentErrors, text] = accumulator
const [regex, process] = parser
const [errors, _remainingText] = consume(text, regex, process)
return [currentErrors.concat(errors), _remainingText]
}
}
export default class BibLogParser {
@ -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 })