mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #1245 from AnessZurba:tex-or-pdf
GitOrigin-RevId: 096f7e5bb581c3984db8dc74e7a4c525de862cce
This commit is contained in:
commit
2a2bb3f064
2 changed files with 40 additions and 0 deletions
|
@ -88,6 +88,23 @@ const getEntryText = (state: EditorState, node: SyntaxNodeRef): string => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle the texorpdfstring command
|
||||||
|
if (
|
||||||
|
token.type.name === 'Command' &&
|
||||||
|
token.node.firstChild?.firstChild != null
|
||||||
|
) {
|
||||||
|
let command = token.node.firstChild.firstChild
|
||||||
|
let commandName = state.doc.sliceString(command.from + 1, command.to)
|
||||||
|
let textArguments = token.node.firstChild.getChildren('TextArgument')
|
||||||
|
if (commandName == 'texorpdfstring' && textArguments.length >= 2) {
|
||||||
|
let pdfstring = textArguments[1]
|
||||||
|
titleParts.push(
|
||||||
|
state.doc.sliceString(pdfstring.from + 1, pdfstring.to - 1)
|
||||||
|
)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Only add text from leaf nodes
|
// Only add text from leaf nodes
|
||||||
if (token.node.firstChild) {
|
if (token.node.firstChild) {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -449,6 +449,29 @@ describe('CodeMirror LaTeX-FileOutline', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('for labels using texorpdfstring', function () {
|
||||||
|
let view: EditorView, content: string[]
|
||||||
|
beforeEach(function () {
|
||||||
|
content = [
|
||||||
|
'\\section{The \\texorpdfstring{function $f(x) = x^2$}{function f(x) = x^2}: Properties of \\texorpdfstring{$x$}{x}.}',
|
||||||
|
]
|
||||||
|
view = makeView(content)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should use the text argument as title', function () {
|
||||||
|
const outline = getOutline(view)
|
||||||
|
expect(outline).to.deep.equal([
|
||||||
|
{
|
||||||
|
from: 0,
|
||||||
|
to: 113,
|
||||||
|
title: 'The function f(x) = x^2: Properties of x.',
|
||||||
|
line: 1,
|
||||||
|
level: SECTION_LEVEL,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('for ill-formed \\def command', function () {
|
describe('for ill-formed \\def command', function () {
|
||||||
let view: EditorView, content: string[]
|
let view: EditorView, content: string[]
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
Loading…
Reference in a new issue