diff --git a/CHANGELOG.md b/CHANGELOG.md index aba978308e2..9ab6ce7ec3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed a bug where spaces are trimmed when highlighting differences in the Entries merge dialog. [koppor#371](https://github.com/koppor/jabref/issues/371) - We fixed several bugs regarding the manual and the autosave of library files that sometimes lead to exceptions or data loss. [#9067](https://github.com/JabRef/jabref/pull/9067), [#8448](https://github.com/JabRef/jabref/issues/8484), [#8746](https://github.com/JabRef/jabref/issues/8746), [#6684](https://github.com/JabRef/jabref/issues/6684), [#6644](https://github.com/JabRef/jabref/issues/6644), [#6102](https://github.com/JabRef/jabref/issues/6102), [#6002](https://github.com/JabRef/jabref/issues/6000) - We fixed an issue where applied save actions on saving the library file would lead to the dialog "The libary has been modified by another program" popping up [#4877](https://github.com/JabRef/jabref/issues/4877) +- We fixed an issue where title case didn't capitalize words after en-dash characters [#9068] - We fixed an issue where JabRef would not exit when a connection to a LibreOffice document was established previously and the document is still open [#9075](https://github.com/JabRef/jabref/issues/9075) ### Removed diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/Word.java b/src/main/java/org/jabref/logic/formatter/casechanger/Word.java index bf5eee51bb6..dbc162fc8a5 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/Word.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/Word.java @@ -17,11 +17,13 @@ public final class Word { * Set containing common lowercase function words */ public static final Set SMALLER_WORDS; + public static final Set DASHES; private final char[] chars; private final boolean[] protectedChars; static { Set smallerWords = new HashSet<>(); + Set dashes = new HashSet<>(); // Articles smallerWords.addAll(Arrays.asList("a", "an", "the")); @@ -30,10 +32,20 @@ public final class Word { // Conjunctions smallerWords.addAll(Arrays.asList("and", "but", "for", "nor", "or", "so", "yet")); + // Dashes + dashes.addAll(Arrays.asList( + '-', '~', '⸗', '〰', '᐀', '֊', '־', '‐', '‑', '‒', + '–', '—', '―', '⁓', '⁻', '₋', '−', '⸺', '⸻', + '〜', '゠', '︱', '︲', '﹘', '﹣', '-' + )); + + // unmodifiable for thread safety + DASHES = dashes; + // unmodifiable for thread safety SMALLER_WORDS = smallerWords.stream() - .map(word -> word.toLowerCase(Locale.ROOT)) - .collect(Collectors.toUnmodifiableSet()); + .map(word -> word.toLowerCase(Locale.ROOT)) + .collect(Collectors.toUnmodifiableSet()); } public Word(char[] chars, boolean[] protectedChars) { @@ -77,7 +89,7 @@ public void toLowerCase() { public void toUpperFirst() { for (int i = 0; i < chars.length; i++) { if (!protectedChars[i]) { - chars[i] = (i == 0) ? + chars[i] = (i == 0 || DASHES.contains(chars[i - 1])) ? Character.toUpperCase(chars[i]) : Character.toLowerCase(chars[i]); } diff --git a/src/test/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatterTest.java b/src/test/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatterTest.java index 8d3cfe97d9e..20ebb96648f 100644 --- a/src/test/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatterTest.java @@ -45,6 +45,18 @@ private static Stream testData() { "bibliographic software. a comparison."), Arguments.of("Bibliographic Software. {A COMPARISON.}", "bibliographic software. {A COMPARISON.}"), + Arguments.of("--Test~Ing Dash--Like Characters", + "--test~ing dash--like characters"), + Arguments.of("-⸗Test⸗Ing Dash〰Like Cha᐀᐀Racters", + "-⸗test⸗ing dash〰like cha᐀᐀racters"), + Arguments.of("︲︲Test־Ing Dash⁓⁓Like Characters", + "︲︲test־ing dash⁓⁓like characters"), + Arguments.of("⁻⁻Test−Ing Dash⸻Like Characters", + "⁻⁻test−ing dash⸻like characters"), + Arguments.of("--Test〰Ing M-U~L゠T︱I⁓P︲L--~~︲E Dash⸻-Like Characters", + "--test〰ing M-u~l゠t︱i⁓p︲l--~~︲e dASH⸻-likE charACTErs"), + Arguments.of("Kinetic Studies on Enzyme-Catalyzed Reactions: Oxidation of Glucose, Decomposition of Hydrogen Peroxide and Their Combination", + "kinetic studies on enzyme-catalyzed reactions: oxidation of glucose, decomposition of hydrogen peroxide and their combination"), Arguments.of("{BPMN} Conformance in Open Source Engines", new TitleCaseFormatter().getExampleInput())); } diff --git a/src/test/java/org/jabref/logic/importer/fileformat/IsiImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/IsiImporterTest.java index f0b385f74d4..b77c78660d2 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/IsiImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/IsiImporterTest.java @@ -213,7 +213,7 @@ public void testImportEntriesWOS() throws IOException, URISyntaxException { assertEquals(Optional.of("Optical waveguides in Sn2P2S6 by low fluence MeV He+ ion implantation"), second.getField(StandardField.TITLE)); - assertEquals(Optional.of("Journal of Physics-condensed Matter"), first.getField(StandardField.JOURNAL)); + assertEquals(Optional.of("Journal of Physics-Condensed Matter"), first.getField(StandardField.JOURNAL)); } @Test