Open gudzpoz opened 8 months ago
This is probably the result of parsebib using forward-sexp
to find the end of a BibTeX entry, but I'll need to look into it before I can say for sure.
Oh, wait a sec. This is not a normal opening parenthesis, it's a CJK character! I hadn't noticed that right away.
You'll notice that if you have an unclosed ASCII parenthesis, it actually works.
This may actually be a bug in Emacs (bibtex.el
, to be more precise): parsebib uses the syntax table bibtex-braced-string-syntax-table
to during parsing, which turns parentheses ()
into normal punctuation instead of characters that need to be in pairs, which allows it to ignore any unmatched parentheses in field values. However, the (CJK) fullwidth parentheses don't have their syntax class set to punctuation, so parsebib tries to match them, which in cannot.
So arguably, bibtex-braced-string-syntax-table
should deal with non-ASCII parentheses as well, because bibtex-mode
can't handle them either. If I open Failing.bib
in Emacs and then do C-c C-c
, I get the error user-error: Syntactically incorrect BibTeX entry starts here
.
I've created an Emacs bug here: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68477
In the mean time, you should be able to add FULLWIDTH LEFT PARENTHESIS and FULLWIDTH RIGHT PARENTHESIS to bibtex-braced-string-syntax-table
yourself:
(with-eval-after-load 'bibtex
(modify-syntax-entry ?\( "." bibtex-braced-string-syntax-table)
(modify-syntax-entry ?\) "." bibtex-braced-string-syntax-table))
I suspect there will be more non-ASCII parentheses that would need to be added to bibtex-braced-string-syntax-table
, so if any of those are problematic for you as well, you can add them in the same way.
This is only a work-around, of course, but it should help you deal with your issue until a new Emacs version is released with the fix.
(I am using Spacemacs and have tons of customization, but I assume this is irrelevant? If the following is not enough to reproduce the issue, I will try again in a fresh install / vanilla emacs.)
Reproducing Steps
Evaluation results:
Expecting behavior
The parser should treat full-width characters as normal text instead of syntactic elements.
P.S. Both
Failing.bib
andPassing.bib
pass validation bybiber
(viabiber --tool -V Failing.bib
/biber --tool -V Passing.bib
).