Merge pull request #14934 from overleaf/revert-14926-revert-14121-bg-best-allow-underscore-in-hyperref-labels
Revert "Revert "allow underscore in hyperref labels"" GitOrigin-RevId: f7b2dd418fa9c0940b778604ed08eccab78f97d2
This commit is contained in:
+50
@@ -444,6 +444,56 @@ describe('LatexLinter', function () {
|
||||
assert.equal(errors.length, 0)
|
||||
})
|
||||
|
||||
it('should accept a plain hyperref command', function () {
|
||||
const { errors } = Parse('\\hyperref{http://www.overleaf.com/}')
|
||||
assert.equal(errors.length, 0)
|
||||
})
|
||||
|
||||
it('should accept a hyperref command with underscores in the url ', function () {
|
||||
const { errors } = Parse('\\hyperref{http://www.overleaf.com/my_page.html}')
|
||||
assert.equal(errors.length, 0)
|
||||
})
|
||||
|
||||
it('should accept a hyperref command with category, name and text arguments ', function () {
|
||||
const { errors } = Parse(
|
||||
'\\hyperref{http://www.overleaf.com/}{category}{name}{text}'
|
||||
)
|
||||
assert.equal(errors.length, 0)
|
||||
})
|
||||
|
||||
it('should accept an underscore in a hyperref label', function () {
|
||||
const { errors } = Parse('\\hyperref[foo_bar]{foo bar}')
|
||||
assert.equal(errors.length, 0)
|
||||
})
|
||||
|
||||
it('should reject a $ in a hyperref label', function () {
|
||||
const { errors } = Parse('\\hyperref[foo$bar]{foo bar}')
|
||||
assert.equal(errors.length, 1)
|
||||
})
|
||||
|
||||
it('should reject an unclosed hyperref label', function () {
|
||||
const { errors } = Parse('\\hyperref[foo_bar{foo bar}')
|
||||
assert.equal(errors.length, 2)
|
||||
assert.equal(errors[0].text, 'invalid hyperref label')
|
||||
assert.equal(errors[1].text, 'unexpected close group }')
|
||||
})
|
||||
|
||||
it('should accept a hyperref command without an optional argument', function () {
|
||||
const { errors } = Parse('{\\hyperref{hello}}')
|
||||
assert.equal(errors.length, 0)
|
||||
})
|
||||
|
||||
it('should accept a hyperref command without an optional argument and multiple other arguments', function () {
|
||||
const { errors } = Parse('{\\hyperref{}{}{fig411}}')
|
||||
assert.equal(errors.length, 0)
|
||||
})
|
||||
|
||||
it('should accept a hyperref command without an optional argument in an unclosed group', function () {
|
||||
const { errors } = Parse('{\\hyperref{}{}{fig411}')
|
||||
assert.equal(errors.length, 1)
|
||||
assert.equal(errors[0].text, 'unclosed group {')
|
||||
})
|
||||
|
||||
// %novalidate
|
||||
// %begin novalidate
|
||||
// %end novalidate
|
||||
|
||||
Reference in New Issue
Block a user