Skip to content

Commit adba478

Browse files
committed
Merge branch 'main' of https://github.com/JabRef/jabref into reformat-again
# Conflicts: # .jbang/CheckoutPR.java # .jbang/CloneJabRef.java # jablib/src/main/java/org/jabref/logic/layout/format/NameFormatter.java
2 parents 3aa77ac + 53acc92 commit adba478

File tree

6 files changed

+60
-67
lines changed

6 files changed

+60
-67
lines changed

.jbang/CheckoutPR.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
////usr/bin/env jbang "$0" "$@" ; exit $?
2+
13
import java.io.File;
24
import java.util.List;
35
import java.util.Optional;
@@ -15,8 +17,6 @@
1517
import org.kohsuke.github.GitHubBuilder;
1618
import org.kohsuke.github.PagedIterator;
1719

18-
/// usr/bin/env jbang "$0" "$@" ; exit $?
19-
2020
//JAVA 21+
2121
//RUNTIME_OPTIONS --enable-native-access=ALL-UNNAMED
2222

.jbang/CloneJabRef.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
13
import java.nio.file.Files;
24
import java.nio.file.Path;
35

4-
/// usr/bin/env jbang "$0" "$@" ; exit $?
5-
66
//JAVA 21+
77
//RUNTIME_OPTIONS --enable-native-access=ALL-UNNAMED
88

.jbang/JabKitLauncher.java

100644100755
File mode changed.

.jbang/JabLsLauncher.java

100644100755
File mode changed.

.jbang/JabSrvLauncher.java

100644100755
File mode changed.

jablib/src/main/java/org/jabref/logic/layout/format/NameFormatter.java

Lines changed: 56 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,69 +9,62 @@
99
import org.jabref.logic.layout.LayoutFormatter;
1010
import org.jabref.model.entry.AuthorList;
1111

12-
/**
13-
* This layout formatter uses the Bibtex name.format$ method and provides ultimate flexibility:
14-
* <p>
15-
* The formatter needs a parameter to be passed in that follows the following format:
16-
*
17-
* <code>&lt;case1>@&lt;range11>@"&lt;format>"@&lt;range12>@"&lt;format>"@&lt;range13>...@@
18-
* <p>
19-
* &lt;case2>@&lt;range21>@...</code> and so on.
20-
* <p>
21-
* Individual cases are separated by @@ and items in a case by @.
22-
* <p>
23-
* Cases are just integers or the character * and will tell the formatter to apply the following formats if there are
24-
* less or equal authors given to it. The cases must be in strict increasing order with the * in the last position.
25-
* <p>
26-
* For instance:
27-
* <p>
28-
* case1 = 2
29-
* case2 = 3
30-
* case3 = *
31-
* <p>
32-
* Ranges are either &lt;integer>..&lt;integer>, &lt;integer> or the character * using a 1 based index for indexing
33-
* authors from the given authorlist. Integer indexes can be negative to denote them to start from
34-
* the end of the list where -1 is the last author.
35-
* <p>
36-
* For instance with an authorlist of "Joe Doe and Mary Jane and Bruce Bar and Arthur Kay":
37-
* <p>
38-
* 1..3 will affect Joe, Mary and Bruce
39-
* <p>
40-
* 4..4 will affect Arthur
41-
* <p>
42-
* * will affect all of them
43-
* <p>
44-
* 2..-1 will affect Mary, Bruce and Arthur
45-
* <p>
46-
* The &lt;format> uses the Bibtex formatter format:
47-
* <p>
48-
* The four letter v, f, l, j indicate the name parts von, first, last, jr which
49-
* are used within curly braces. A single letter v, f, l, j indicates that the name should be abbreviated.
50-
* To put a quote in the format string quote it using \" (mh. this doesn't work yet)
51-
* <p>
52-
* I give some examples but would rather point you to the bibtex documentation.
53-
* <p>
54-
* "{ll}, {f}." Will turn "Joe Doe" into "Doe, J."
55-
* <p>
56-
* Complete example:
57-
* <p>
58-
* To turn:
59-
* <p>
60-
* "Joe Doe and Mary Jane and Bruce Bar and Arthur Kay"
61-
* <p>
62-
* into
63-
* <p>
64-
* "Doe, J., Jane, M., Bar, B. and Kay, A."
65-
* <p>
66-
* you would use
67-
* <p>
68-
* 1@*@{ll}, {f}.@@2@1@{ll}, {f}.@2@ and {ll}, {f}.@@*@1..-3@{ll}, {f}., @-2@{ll}, {f}.@-1@ and {ll}, {f}.
69-
* <p>
70-
* Yeah this is trouble-some to write, but should work.
71-
* <p>
72-
* For more examples see the test-cases.
73-
*
74-
*/
12+
/// This layout formatter uses the BibTeX `name.format$` method and provides ultimate flexibility.
13+
///
14+
/// The formatter needs a parameter with the following format:
15+
///
16+
/// ```
17+
/// <case1>@<range11>@"<format>"@<range12>@"<format>"@<range13>...@@
18+
/// <case2>@<range21>@...
19+
///```
20+
///
21+
/// Individual cases are separated by `@@` and items in a case by `@`.
22+
///
23+
/// Cases are just integers or the character `*` and tell the formatter to apply the following formats
24+
/// if there are less or equal authors given.
25+
/// The cases must be in strictly increasing order with `*` in the last position.
26+
///
27+
/// Example:
28+
/// - `case1 = 2`
29+
/// - `case2 = 3`
30+
/// - `case3 = *`
31+
///
32+
/// Ranges are either `<integer>..<integer>`, `<integer>` or `*` (using a 1-based index).
33+
/// Negative integers start from the end (`-1` = last author).
34+
///
35+
/// Example with `Joe Doe and Mary Jane and Bruce Bar and Arthur Kay`:
36+
/// - `1..3` → Joe, Mary, Bruce
37+
/// - `4..4` → Arthur
38+
/// - `*` → all authors
39+
/// - `2..-1` → Mary, Bruce, Arthur
40+
///
41+
/// The `<format>` uses the BibTeX formatter syntax:
42+
/// - The letters `v`, `f`, `l`, `j` indicate name parts (von, first, last, jr). Use them inside `{}` for full form.
43+
/// - A single letter (`v`, `f`, `l`, `j`) abbreviates the part.
44+
/// - Quotes must be escaped as `\"` (not fully supported yet).
45+
///
46+
/// Example:
47+
/// - `"{ll},{f}."` → `"Joe Doe"` becomes `"Doe, J."`
48+
///
49+
/// Complete example:
50+
///
51+
/// Input:
52+
/// ```
53+
/// Joe Doe and Mary Jane and Bruce Bar and Arthur Kay
54+
///```
55+
///
56+
/// Output:
57+
/// ```
58+
/// Doe, J., Jane, M., Bar, B. and Kay, A.
59+
///```
60+
///
61+
/// Formatter parameter:
62+
/// ```
63+
/// 1@*@{ll},{f}.@@2@1@{ll},{f}.@2@ and {ll},{f}.@@*@1..-3@{ll},{f}., @-2@{ll},{f}.@-1@ and {ll},{f}.
64+
///```
65+
///
66+
/// This is troublesome to write, but it works.
67+
/// For more examples see the test cases.
7568
public class NameFormatter implements LayoutFormatter {
7669

7770
public static final String DEFAULT_FORMAT = "1@*@{ff }{vv }{ll}{, jj}@@*@1@{ff }{vv }{ll}{, jj}@*@, {ff }{vv }{ll}{, jj}";

0 commit comments

Comments
 (0)