Bibtex citation highlighting not fully functional (Fix proposed)
Describe the bug
As you can see on the screenshot below, not all @'s are yellow and not all references are red, which means that the highlighting does not cover all use cases identified in the Pandoc documentation.

Expected behavior
In using the Scope Inspector tool on the bugged citation, the textmate scopes should be punctuation.definition.bibtex or support.function.text.markdown.notes.bibtex.key but it's not.
Versions
- OS: [Linux]
- VS Code Version: [the last one]
- Extension Version: [the last one]
How to fix it This bug is easy to fix:
- Open
/syntaxes/notes.tmLanguage.json - Go in the scope
"name": "text.markdown.notes.bibtex", - Replace match value by
"match": "[\\[|\\;]?(\\s?\\-?@)(.*?)(?=$|[\\;\\s\\r\\n\\]{},~#%\\\\'\"=\\(\\)])
This solution is inspired from this extension. You can test this regex here.
The result after the fix

Here is also a proposal to fix the definitions of the cases discussed above:
- Open
src/BibTeXCitations.ts - Replace the regex line 10 by this one :
static _rxBibTeXInNote = /(?<= |,|^|\[|\[-|;|-)@[\p{L}\d\-_]+(?!\(.\S\))/giu; - Open
src/test/jest/extension.test.ts - Add these unit tests bellow at the line 224
// inside brackets with name supression and semicolumn separator
expect(("some [;-@reference]".match(rx) || [])[0]).toEqual("@reference")
// inside brackets with name supression and preceded by space
expect(("some [ -@reference]".match(rx) || [])[0]).toEqual("@reference")
// inside brackets with name supression and preceded by space and semicolumn separator
expect(("some [; -@reference]".match(rx) || [])[0]).toEqual("@reference")
// inside brackets and preceded by space
expect(("some [ @reference]".match(rx) || [])[0]).toEqual("@reference")
// inside brackets and preceded by space and semicolumn separator
expect(("some [; @reference]".match(rx) || [])[0]).toEqual("@reference")
// inside brackets
expect(("some [@reference]".match(rx) || [])[0]).toEqual("@reference")
// inside brackets and preceded by semicolumn separator
expect(("some [;@reference]".match(rx) || [])[0]).toEqual("@reference")
Hey, sorry, terribly busy with moving and work right now. Anyone able to turn the proposal into a PR? If not, will get to when I can, just swamped right now..
Okay, no worries, I'll do a PR.