Skip to content

Commit 321bdb6

Browse files
committed
Bring back the older regex approach for loading bibtex files
1 parent 6aa45c0 commit 321bdb6

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [0.10.2] - 2023-06-08
4+
5+
- Try to load bib files similar to v0.9.3 because the newer versions are not working for some users (issue #41)
6+
37
## [0.10.1] - 2023-06-08
48

59
- Try to fix citation autocompletion not showing up if a workspace is not loaded

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "pandocciter",
33
"displayName": "Pandoc Citer",
44
"description": "Autocomplete bibtex citations for markdown/pandoc",
5-
"version": "0.10.1",
5+
"version": "0.10.2",
66
"publisher": "notZaki",
77
"license": "MIT",
88
"engines": {

src/components/manager.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,26 @@ export class Manager {
4444

4545
findBib() : void {
4646
let foundFiles: string[] = [];
47+
const activeText = vscode.window.activeTextEditor!.document.getText();
48+
49+
// Re-use the old reg-ex approach in case the yaml parser fails
50+
const bibRegex = /^bibliography:\s* \[(.*)\]/m;
51+
let bibresult = activeText.match(bibRegex);
52+
if (bibresult) {
53+
const bibFiles = bibresult[1].split(',').map(item => item.trim());
54+
for (let i in bibFiles) {
55+
let bibFile = this.stripQuotes(bibFiles[i]);
56+
bibFile = this.resolveBibFile(bibFile, undefined);
57+
this.extension.log(`Looking for .bib file: ${bibFile}`);
58+
this.addBibToWatcher(bibFile);
59+
foundFiles.push(bibFile);
60+
}
61+
}
4762

63+
// This is the newer approach using yaml-js
4864
const docURI = vscode.window.activeTextEditor!.document.uri;
4965
const configuration = vscode.workspace.getConfiguration('PandocCiter', docURI);
5066
const rootFolder = vscode.workspace.getWorkspaceFolder(docURI)?.uri.fsPath;
51-
52-
const activeText = vscode.window.activeTextEditor!.document.getText();
5367
const yamltext = activeText.match(/---\r?\n((.+\r?\n)+)---/gm)
5468
const parsedyaml = yaml.loadAll(yamltext)[0]
5569
if (parsedyaml && parsedyaml.bibliography) {

0 commit comments

Comments
 (0)