Special field markers and modifiers
When forming a link or filename, constructs like "veryshorttitle" are sometimes required, but sometimes this type of marker is required for another field, such as [MAINTITLE] or [user_title] etc.
It might be better to use something like modifiers :veryshorttitle, :shorttitle, etc., for any field, rather than just field markers for title, authors, and editors only.
Hello :-)
I am not sure, but I assume the fieldmarkers are hardcoded and only provided for the most used fields. Please correct me, but I believe it is possible to achieve similar functionality than field markers by using Regular Expressions and modifiers. For example, :regex("pattern", "replacement") is your swiss army knive for all types of patterns and in your case specifically, :truncateN might be fitting replacement for [veryshorttitle], which is basically a simple :truncate1. See the section about modifiers in the documentation: https://docs.jabref.org/setup/citationkeypatterns#modifiers. Modifiers can be used with most field names. Also have a look at the regex documentation: https://docs.jabref.org/setup/citationkeypatterns#regular-expressions-regex
For example, a construct like [title:truncate1] will only display the first letter of the corresponding token field, but what if I need to display only the first significant word or three words as "shorttitle"!?
Let there be two books published in the same year with the main title or the title of the series as “Elements of Mathematics” by Nicolas Bourbaki and the usual titles: 1) Functions of a Real Variable; 2) General Topology. When referring to such books, for clarity, you can create the citationkey in the form ("Bourbaki_2004_Elements_Functions" and "Bourbaki_2004_Elements_General").
In the example above, you can use the "verishorttitle" marker to display the first word of the title (Functions or General), but which construct will help you display the first word of the main title or custom title (not including the function words like the, with, etc)?
I'm not sure but an army knife won't work here!
Please provide bibtex/biblatex source data, then I will play around with it. main title and user_title are not official bibtex/biblatex fields, but a custom field, right?
Yes these are custom fields!
About the sources. For example, let them be like this:
@Book{Bamford_1972_Comprehensive_Reaction_V_7_EN,
language = {english},
maintitle = {Comprehensive Chemical Kinetics},
title = {Reaction of Metallic Salts and Complexes, and Oranometallic Compounds},
volume = {7},
year = {1972},
editor = {Bamford, C. H. and Tipper, C. F. H.},
}
@Book{Bamford_1972_Comprehensive_Reactions_V_6_EN,
language = {english},
maintitle = {Comprehensive Chemical Kinetics},
title = {Reactions of Non-Metallic Inorganic Compounds},
volume = {6},
year = {1972},
editor = {Bamford, C. H. and Tipper, C. F. H.},
}
@Book{Bamford_1972_Comprehensive_Decomposition_V_5_EN,
language = {english},
maintitle = {Comprehensive Chemical Kinetics},
title = {Decomposition and Isomerization of Organic Compounds},
volume = {5},
year = {1972},
editor = {Bamford, C. H. and Tipper, C. F. H.},
}
You are right. I haven't found a regex (yet?) that can truncate well, under the condition that content of maintitle is variable and not fixed.
- "maintitle" is not a custom field. It is an optional field for "book" entries in biblatex. I haven't checked for bibtex.
- Under "Files > preferences > linked files > linked file name conventions > file name format pattern", I tried to use
[auth.etal:regex("\\."," & "):regex("\\& etal","et al.")][Organization] ([date]) [MAINTITLE:regex("^\w\b\w\b\w\b.*$", "^\w\b\w\b\w$"]with following entry:
@book{Bamford_1972_Comprehensive_Reaction_V_7_EN,
language = {english},
maintitle = {Comprehensive Chemical Kinetics Are Wonderful Riddles},
title = {Reaction of Metallic Salts and Complexes, and Oranometallic Compounds},
volume = {7},
year = {1972},
editor = {Bamford, C. H. and Tipper, C. F. H.},
}
I test by pressing ALT + F8 (which is Quality > Clean up entries").
Expected outcome: Bamford & Tipper (1972) Comprehensive Chemical Kinetics 👍 Actual outcome: Bamford & Tipper (1972) Comprehensive Chemical Kinetics Are Wonderful Riddles ❌
I think there is an inherent limitation of the :regex("pattern", "replacement") modifier.
For example, given the following file name format pattern: [auth.etal:regex("\\."," & "):regex("\\& etal","et al.")][Organization] ([date]) [MAINTITLE:regex("Comprehensive Chemical Kinetics Are Wonderful Riddle", "Comprehense Cinetics")]
Expected outcome: Bamford & Tipper (1972) Comprehense Cineticss 👍 Actual outcome: Bamford & Tipper (1972) Comprehense Cineticss 👍
TL;DR: Looks like this has to be fixed in JabRef code.
I think, as you suggested, if it is possible, then extending some generic field markers like shorttitle or veryshorttitle to other or even all fields is a good idea.
Hello can i take this issue ? I am a first time contributor
Sure :-) 👍
Welcome to the vibrant world of open-source development with JabRef!
Newcomers, we're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.
In case you encounter failing tests during development, please check our developer FAQs!
Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.
Happy coding! 🚀
Hello i know it is not issue related but I am really struggling to clone the repository. I am always met with this error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly. I have tried all the recommended stuff from StackOverflow and I have tried ssh nothing helps so I am just wondering if anyone has any experience solving this ? Thank you
@Mtjpp Such questions are better asked in our gitter chat: Try reducing the fetch depths while cloning:
git clone --recurse-submodules --depth 10 https://github.com/JabRef/jabref.git JabRef
Let there be two books published in the same year with the main title or the title of the series as “Elements of Mathematics” by Nicolas Bourbaki and the usual titles: 1) Functions of a Real Variable; 2) General Topology. When referring to such books, for clarity, you can create the citationkey in the form ("Bourbaki_2004_Elements_Functions" and "Bourbaki_2004_Elements_General").
Just to understand:
maintitle Elements of Mathematics plus title Functions of a Real Variable should be mapped to Elements_Funtions
and
maintitle Elements of Mathematics plus title General Topology should be mapped to Elements_General.
It might be better to use something like modifiers :veryshorttitle, :shorttitle, etc., for any field, rather than just field markers for title, authors, and editors only.
Just for the record: Our modifiers are listed at https://github.com/JabRef/user-documentation/blob/main/en/finding-sorting-and-cleaning-entries/saveactions.md#save-actions-as-modifiers.
The issue is about the special field markers https://docs.jabref.org/setup/citationkeypatterns#special-field-markers
The issue is about the special field markers https://docs.jabref.org/setup/citationkeypatterns#special-field-markers
And that :veryshorttitle can be used.
-
[USER_CUSTOM_TITLE_FIELD:veryshorttitle] -
[USER_CUSTOM_TITLE_FIELD:shorttitle] -
[USER_CUSTOM_TITLE_FIELD:camel] -
[USER_CUSTOM_TITLE_FIELD:camelN] -
[USER_CUSTOM_TITLE_FIELD:nameIni5](all functions ofauth/edtrshould work here - only thatnameis used as prefix)
Meaning: Add new modifiers: https://docs.jabref.org/setup/citationkeypatterns#modifiers
@NeymanDmitry I went into the code and got more claritiy, how things work. With https://github.com/JabRef/jabref/pull/11967, the escaping is more easiy.
This should be the pattern you are looking for:
[edtr]_[YEAR]_[MAINTITLE:regex("(\w+).*", "$1")]_[TITLE:regex("(\w+).*", "$1")]_V_[VOLUME]_[LANGUAGE:regex("english", "EN"):regex("french", "FR")]
The first "magic ingredient" is $1 backreferencing to th first group in the RegEx. The second "magic ingredient" is to use \w+ as first group. Also not the space * after that.
Implementation notes:
- one can see all methods which could be sued for
name...at https://github.com/JabRef/jabref/blob/60ef28ae5be23ed35cb82824eb40e12b63c01a9f/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java#L351. - to hock into the modifiers, one needs to hock in around https://github.com/JabRef/jabref/blob/60ef28ae5be23ed35cb82824eb40e12b63c01a9f/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java#L586. I think, it is another check for
modifier. Check if the modifier is known (the list is somehow at https://github.com/JabRef/jabref/issues/11367#issuecomment-2412533435). If yes: execute the modifier (parse the currentresultingLabelinto anAuthorList(usingorg.jabref.model.entry.AuthorList#parse) and then pass it to the methods. -- What I mean, hook before https://github.com/JabRef/jabref/blob/60ef28ae5be23ed35cb82824eb40e12b63c01a9f/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java#L589.
Fixed by https://github.com/JabRef/jabref/pull/12067