Skip to content

Commit e108619

Browse files
committed
Convert JavaDoc to Markdown
1 parent bbac0fe commit e108619

File tree

1 file changed

+57
-63
lines changed

1 file changed

+57
-63
lines changed

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

Lines changed: 57 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,69 +9,63 @@
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).
43+
/// - Use them inside `{}` for full form.
44+
/// - A single letter (`v`, `f`, `l`, `j`) abbreviates the part.
45+
/// - Quotes must be escaped as `\"` (not fully supported yet).
46+
///
47+
/// Example:
48+
/// - `"{ll}, {f}."` → `"Joe Doe"` becomes `"Doe, J."`
49+
///
50+
/// Complete example:
51+
///
52+
/// Input:
53+
/// ```
54+
/// Joe Doe and Mary Jane and Bruce Bar and Arthur Kay
55+
/// ```
56+
///
57+
/// Output:
58+
/// ```
59+
/// Doe, J., Jane, M., Bar, B. and Kay, A.
60+
/// ```
61+
///
62+
/// Formatter parameter:
63+
/// ```
64+
/// 1@*@{ll}, {f}.@@2@1@{ll}, {f}.@2@ and {ll}, {f}.@@*@1..-3@{ll}, {f}., @-2@{ll}, {f}.@-1@ and {ll}, {f}.
65+
/// ```
66+
///
67+
/// This is troublesome to write, but it works.
68+
/// For more examples see the test cases.
7569
public class NameFormatter implements LayoutFormatter {
7670

7771
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)