-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Citation key, make it possible for an empty field to fall back to a custom field #7111
Comments
This should be possible at least to define a fallback
@k3KAW8Pnf7mkmdSMPHz27 Do you know if it's possible to define a fallback field? |
You are referring to
It would be better if it supported fields/bracketed expressions as well, yup. You might be able to workaround the issue using the replace regular expression feature with an empty string. I am not familiar enough with regex and the
I like the idea ``
I'd recommend jabref/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java Lines 549 to 553 in b0af521
Is the (current) replacement modifier.
As far as I know, no =/ |
Yes, eprint or even doi. I don't like the [year] field because new articles tend to have both a preprint and a reprint with different [year]. When I update the reprint info from a preprint, the year changes, which then messes up the bibtex key and the pdf file names. I then decided to use eprint instead of year which is unique and persistent. I do have my personal workaround via regex. However, I suppose that in the current version you can do regex replace only once. I would be already happy if it was allowed to add several regex replacement rules. |
Nice! Might be that others can use this meanwhile.
Agreed. |
@k3KAW8Pnf7mkmdSMPHz27 Hi, I am interested in this issue. Where can I get started and What is the expected behavior of citation key generation? Thank you. |
Hello @SuXiChangZhen, thank you for your interest! Pretty much all approaches start with the "alternative text modifier" as described above, jabref/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java Lines 549 to 553 in b0af521
It is listed as the last modifier in the JabRef documentation. There isn't necessarily one "right" answer to this issue. The code is old and has a few violations against good coding principles making it harder to deal with it. Mostly I'd advise against trying to refactor the whole jabref/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java Lines 195 to 220 in 807f85e
so that
can parse and expand whatever is between the parentheses, i.e., make the same type of call as in jabref/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyGenerator.java Line 195 in 807f85e
Does that sort of make sense? You are also free to solve it in some completely different way.
I am not sure that I understand your question. The bracketed patterns were originally intended to create a citation key from bibentries by accessing its fields, (e.g., |
Thank you for your advice. I think I understand the need. I will make a pr soon. |
Nowadays, most articles from online database already have their unique identifiers.
I personally prefer to use [authorsAlpha][eprint] as the default pattern for citation key.
It expands the default [author][year] pattern (the information of [year] is already contained in [eprint]); moreover, it automatically avoid duplicate keys.
However, it is not compatible with old articles with no [eprint] field. So I hope that when [eprint] is empty, it automatically falls back to [year]. Currently JabRef has the feature to replace an empty field with a custom string, which is actually not informative at all and thus not practical. Also when [author] is empty then [editor] is automatically used. So why not make this available to all empty fields with customizable fallback field? The syntax may be simply [eprint:[year]].
The text was updated successfully, but these errors were encountered: