Skip to content

Commit 7362b68

Browse files
committed
Fix #4021 Parse nested @string in bibtex
1 parent 6c98c64 commit 7362b68

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/providers/completer/citation.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,20 @@ export class Citation implements IProvider {
263263
}
264264
const abbreviations: {[key: string]: string} = {}
265265
ast.content.filter(bibtexParser.isStringEntry).forEach((entry: bibtexParser.StringEntry) => {
266-
abbreviations[entry.abbreviation] = entry.value.content
266+
// @string{string1 = "Proceedings of the "}
267+
// @string{string2 = string1 # "Foo"}
268+
if (typeof entry.value.content === 'string') {
269+
abbreviations[entry.abbreviation] = entry.value.content
270+
} else {
271+
abbreviations[entry.abbreviation] =
272+
(entry.value.content as (bibtexParser.AbbreviationValue | bibtexParser.TextStringValue)[]).map(subEntry => {
273+
if (bibtexParser.isAbbreviationValue(subEntry)) {
274+
return abbreviations[subEntry.content] ?? `undefined @string "${subEntry.content}"`
275+
} else {
276+
return subEntry.content
277+
}
278+
}).join('')
279+
}
267280
})
268281
ast.content
269282
.filter(bibtexParser.isEntry)

0 commit comments

Comments
 (0)