Merge pull request #28893 from overleaf/mj-linter-brace-check

[web] Allow braces in documentclass options

GitOrigin-RevId: 9675d3fc760a3b7d402c5a9df57a0cf183a1e648
This commit is contained in:
Mathias Jakobsen
2025-10-09 08:05:31 +00:00
committed by Copybot
parent b6d116e957
commit f9d0f7e3ee
2 changed files with 39 additions and 4 deletions
@@ -338,11 +338,20 @@ const readOptionalArgumentWithUnderscores = function (TokeniseResult, k) {
}
let label = ''
let groupDepth = 0
let j, tok
for (j = k + 1; (tok = Tokens[j]); j++) {
if (tok[1] === '{') {
// unclosed label
break
if (label.length === 0) {
// We haven't seen a [ yet, so there is no optional argument
break
}
groupDepth++
} else if (tok[1] === '}') {
groupDepth--
if (groupDepth < 0) {
break
}
} else if (tok[1] === 'Text') {
const str = text.substring(tok[2], tok[3])
label = label + str
@@ -357,6 +366,13 @@ const readOptionalArgumentWithUnderscores = function (TokeniseResult, k) {
break // breaking due to unrecognised token
}
}
if (groupDepth !== 0) {
const missing = groupDepth > 0 ? '{' : '}'
// mismatched braces
const e = new Error(`Unmatched ${missing} in label`)
e.pos = j + 1
return e
}
if (label.length === 0) {
return null