[-- Attachment #1: Type: text/plain, Size: 264 bytes --] I was just interacting with one of the org-roam-bibtex developers about org-cite. He noted that citekeys can only start with an underscore or alpha character. Is that a necessary restriction? He, it turns out, mostly has keys of the form '2020-DOE-ABC". Bruce [-- Attachment #2: Type: text/html, Size: 480 bytes --]
"Bruce D'Arcus" <bdarcus@gmail.com> writes:
> I was just interacting with one of the org-roam-bibtex developers about
> org-cite.
>
> He noted that citekeys can only start with an underscore or alpha character.
>
> Is that a necessary restriction?
>
> He, it turns out, mostly has keys of the form '2020-DOE-ABC".
It is not a necessary restriction.
What do you suggest as the first character? Underscore, and
alphanumeric? So keys would need to:
- start with _ or alnum
- end with _ or alnum
- optionally contain any alnum or symbol among #$%&+./:<>?_~-
Regards,
On Sun, May 16, 2021 at 7:29 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote: > > "Bruce D'Arcus" <bdarcus@gmail.com> writes: > > > I was just interacting with one of the org-roam-bibtex developers about > > org-cite. > > > > He noted that citekeys can only start with an underscore or alpha character. > > > > Is that a necessary restriction? > > > > He, it turns out, mostly has keys of the form '2020-DOE-ABC". > > It is not a necessary restriction. > > What do you suggest as the first character? Underscore, and > alphanumeric? I think so; yes. > So keys would need to: > > - start with _ or alnum > - end with _ or alnum > - optionally contain any alnum or symbol among #$%&+./:<>?_~- I'm not super sure of the details around, for example, bibtex, but this post seems to be helpful to check against for the details? https://tex.stackexchange.com/questions/388500/what-is-valid-as-a-biblatex-entry-key/388652#388652 Bruce
"Bruce D'Arcus" <bdarcus@gmail.com> writes: > I'm not super sure of the details around, for example, bibtex, but > this post seems to be helpful to check against for the details? > > https://tex.stackexchange.com/questions/388500/what-is-valid-as-a-biblatex-entry-key/388652#388652 Oh my! You're reviving a 6 years old thread[¹]! Basically, current syntax is inherited from a previous citation specification allowing shortcuts: @key instead of [cite:@key]. Since these shortcuts do not exist anymore, we don't need to be so careful about characters allowed in a key. The only one being dangerous is the semicolon, since it is used to separate keys in a citation reference. Closing square bracket could also be problematic if it is not paired properly. So, to be on a safe side, anything beside space, semicolon and square brackets are fine. However, allowing anything means some keys will not be compatible with some bibliography formats. For example, I doubt BibTeX would appreciate a percent character in a key. OTOH, we can put the burden of the user's shoulders. So... let's get liberal and say a key must match: (rx "@" (one-or-more (any word "-.:?!`'/*@+|()<>&_^$#%&~"))) Nothing bad could happen, right? [¹] https://lists.gnu.org/archive/html/emacs-orgmode/2015-03/msg00131.html -- Nicolas Goaziou
On Sun, May 16, 2021 at 8:55 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote: > Oh my! You're reviving a 6 years old thread[¹]! 6 years in the TeX world is the blink of an eye! > ... we can put the burden of the user's shoulders. > > So... let's get liberal and say a key must match: > > (rx "@" (one-or-more (any word "-.:?!`'/*@+|()<>&_^$#%&~"))) > > Nothing bad could happen, right? Probably not. As you say, you can put the burden on the user, and can always tighten it later if something comes up. Bruce
On Sun, May 16 2021, Nicolas Goaziou wrote: > However, allowing anything means some keys will not be compatible with > some bibliography formats. For example, I doubt BibTeX would appreciate > a percent character in a key. Careful, trying to find out the details of BibTeX's file format is a quest that I think no-one has ever returned from. :D I have a comment in =parsebib.el= saying that BibTeX allows $ ^ and & in entry keys, despite the fact that those characters are special in TeX... The regexp =parsebib.el= uses for entry keys is this: "[^\"@\\#%',={} \t\n\f]+" Mind you, I have no idea if BibTeX really rejects all these characters (well, I'm pretty sure about the white space... :D ), but even if they are acceptable, they probably don't occur much in the wild. At least I'm not aware of any user complaints since the time I added support for $^&, which was four years ago, > So... let's get liberal and say a key must match: > > (rx "@" (one-or-more (any word "-.:?!`'/*@+|()<>&_^$#%&~"))) > > Nothing bad could happen, right? On a scale of 1 to 10, 1 being getting an error message and having to go online to find out what it means, and 10 being the total and utter destruction of our solar system, I doubt it'll exceed 1. -- Joost Kremers Life has its moments
Hello,
Joost Kremers <joostkremers@fastmail.fm> writes:
> On Sun, May 16 2021, Nicolas Goaziou wrote:
>
>> So... let's get liberal and say a key must match:
>>
>> (rx "@" (one-or-more (any word "-.:?!`'/*@+|()<>&_^$#%&~")))
>>
>> Nothing bad could happen, right?
>
> On a scale of 1 to 10, 1 being getting an error message and having to go online
> to find out what it means, and 10 being the total and utter destruction of our
> solar system, I doubt it'll exceed 1.
What a relief! Thanks.
I changed the syntax for key to the regexp above. I even added curly
brackets. Now, the following is a valid key:
@{🕮}
I then cleaned-up a bit the branch, and rebased on top of master.
Regards,
--
Nicolas Goaziou