Skip to content

Commit

Permalink
Add modifier to truncate a BibTex key
Browse files Browse the repository at this point in the history
  • Loading branch information
k3KAW8Pnf7mkmdSMPHz27 committed May 5, 2020
1 parent 7cb7ea6 commit 6ae850a
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ static String applyModifiers(final String label, final List<String> parts, final
}
}
resultingLabel = abbreviateSB.toString();
} else if (modifier.matches("truncate[\\d]+")) {
// Truncate by keeping the first N characters and remove trailing white spaces.
int N = Integer.parseInt(modifier.substring(8));
N = Math.min(N, resultingLabel.length());
resultingLabel = resultingLabel.substring(0, N).stripTrailing();
} else {
Optional<Formatter> formatter = Formatters.getFormatterForModifier(modifier);
if (formatter.isPresent()) {
Expand Down

0 comments on commit 6ae850a

Please sign in to comment.