diff --git a/CHANGELOG.md b/CHANGELOG.md index 880b7b43b26..9a0cfc8b3ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Fixed +- We fixed an issue where author names with tilde accents (for example ñ) were marked as "Names are not in the standard BibTex format" [#8071](https://github.com/JabRef/jabref/issues/8071) - We fixed an issue where the possibility to generate a subdatabase from an aux file was writing empty files when called from the commandline [#9115](https://github.com/JabRef/jabref/issues/9115), [forum#3516](https://discourse.jabref.org/t/export-subdatabase-from-aux-file-on-macos-command-line/3516) - We fixed the display of issue, number, eid and pages fields in the entry preview. [#8607](https://github.com/JabRef/jabref/pull/8607), [#8372](https://github.com/JabRef/jabref/issues/8372), [Koppor#514](https://github.com/koppor/jabref/issues/514), [forum#2390](https://discourse.jabref.org/t/unable-to-edit-my-bibtex-file-that-i-used-before-vers-5-1/2390), [forum#3462](https://discourse.jabref.org/t/jabref-5-6-need-help-with-export-from-jabref-to-microsoft-word-entry-preview-of-apa-7-not-rendering-correctly/3462) - We fixed the page ranges checker to detect article numbers in the pages field (used at [Check Integrity](https://docs.jabref.org/finding-sorting-and-cleaning-entries/checkintegrity)). [#8607](https://github.com/JabRef/jabref/pull/8607) diff --git a/src/main/java/org/jabref/logic/importer/AuthorListParser.java b/src/main/java/org/jabref/logic/importer/AuthorListParser.java index bc4835c92f2..41acfd2a503 100644 --- a/src/main/java/org/jabref/logic/importer/AuthorListParser.java +++ b/src/main/java/org/jabref/logic/importer/AuthorListParser.java @@ -447,7 +447,7 @@ private Token getToken() { if (c == '\\') { currentBackslash = tokenEnd; } - if ((bracesLevel == 0) && ((",;~-".indexOf(c) != -1) || Character.isWhitespace(c))) { + if ((bracesLevel == 0) && ((",;-".indexOf(c) != -1) || Character.isWhitespace(c))) { break; } tokenEnd++; diff --git a/src/main/java/org/jabref/logic/util/strings/HTMLUnicodeConversionMaps.java b/src/main/java/org/jabref/logic/util/strings/HTMLUnicodeConversionMaps.java index 587f7197218..86973053a09 100644 --- a/src/main/java/org/jabref/logic/util/strings/HTMLUnicodeConversionMaps.java +++ b/src/main/java/org/jabref/logic/util/strings/HTMLUnicodeConversionMaps.java @@ -762,6 +762,7 @@ public class HTMLUnicodeConversionMaps { {"119978", "Oscr", "$\\mathcal{O}$"}, // script capital O -- possibly use \mathscr {"119984", "Uscr", "$\\mathcal{U}$"}, // script capital U -- possibly use \mathscr {"120598", "", "$\\epsilon$"}, // mathematical italic epsilon U+1D716 -- requires amsmath + {"120599", "", "{{\\˜{n}}}"}, // n with tide }; // List of combining accents @@ -888,7 +889,6 @@ public class HTMLUnicodeConversionMaps { // Manual corrections LATEX_HTML_CONVERSION_MAP.put("AA", "Å"); // Overwritten by Å which is less supported LATEX_UNICODE_CONVERSION_MAP.put("AA", "Å"); // Overwritten by Ångstrom symbol - LATEX_UNICODE_CONVERSION_MAP.put("'n", "ń"); // Manual additions // Support relax to the extent that it is simply removed diff --git a/src/main/java/org/jabref/logic/util/strings/RtfCharMap.java b/src/main/java/org/jabref/logic/util/strings/RtfCharMap.java index 46f49f37bfc..393f9685ffb 100644 --- a/src/main/java/org/jabref/logic/util/strings/RtfCharMap.java +++ b/src/main/java/org/jabref/logic/util/strings/RtfCharMap.java @@ -4,7 +4,7 @@ public class RtfCharMap { - private HashMap rtfMap = new HashMap<>(); + private final HashMap rtfMap = new HashMap<>(); public RtfCharMap() { put("`a", "\\'e0"); diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatterTest.java index 81997715f25..64f14737bb9 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatterTest.java @@ -1,7 +1,11 @@ package org.jabref.logic.formatter.bibtexfields; +import java.util.stream.Stream; + import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -9,52 +13,28 @@ public class HtmlToUnicodeFormatterTest { private HtmlToUnicodeFormatter formatter; + private static Stream data() { + return Stream.of( + Arguments.of("abc", "abc"), + Arguments.of("åäö", "åäö"), + Arguments.of("í", "í"), + Arguments.of("Ε", "Ε"), + Arguments.of("ä", "ä"), + Arguments.of("ä", "ä"), + Arguments.of("ä", "ä"), + Arguments.of("ñ", "ñ"), + Arguments.of("aaa", "

aaa

"), + Arguments.of("bread & butter", "bread & butter")); + } + @BeforeEach public void setUp() { formatter = new HtmlToUnicodeFormatter(); } - @Test - public void formatWithoutHtmlCharactersReturnsSameString() { - assertEquals("abc", formatter.format("abc")); - } - - @Test - public void formatMultipleHtmlCharacters() { - assertEquals("åäö", formatter.format("åäö")); - } - - @Test - public void formatCombinedAccent() { - assertEquals("í", formatter.format("í")); - } - - @Test - public void testBasic() { - assertEquals("aaa", formatter.format("aaa")); - } - - @Test - public void testUmlauts() { - assertEquals("ä", formatter.format("ä")); - assertEquals("ä", formatter.format("ä")); - assertEquals("ä", formatter.format("ä")); - } - - @Test - public void testGreekLetter() { - assertEquals("Ε", formatter.format("Ε")); - } - - @Test - public void testHTMLRemoveTags() { - assertEquals("aaa", formatter.format("

aaa

")); - } - - @Test - public void formatExample() { - assertEquals("bread & butter", formatter.format(formatter.getExampleInput())); + @ParameterizedTest + @MethodSource("data") + void testFormatterWorksCorrectly(String expected, String input) { + assertEquals(expected, formatter.format(input)); } } - - diff --git a/src/test/java/org/jabref/logic/importer/AuthorListParserTest.java b/src/test/java/org/jabref/logic/importer/AuthorListParserTest.java index 7c765d283f9..1ec4e02879c 100644 --- a/src/test/java/org/jabref/logic/importer/AuthorListParserTest.java +++ b/src/test/java/org/jabref/logic/importer/AuthorListParserTest.java @@ -25,7 +25,8 @@ private static Stream data() { Arguments.of("de la Vallée Poussin, Jean Charles Gabriel", new Author("Jean Charles Gabriel", "J. C. G.", "de la", "Vallée Poussin", null)), Arguments.of("de la Vallée Poussin, J. C. G.", new Author("J. C. G.", "J. C. G.", "de la", "Vallée Poussin", null)), Arguments.of("{K}ent-{B}oswell, E. S.", new Author("E. S.", "E. S.", null, "{K}ent-{B}oswell", null)), - Arguments.of("Uhlenhaut, N Henriette", new Author("N Henriette", "N. H.", null, "Uhlenhaut", null)) + Arguments.of("Uhlenhaut, N Henriette", new Author("N Henriette", "N. H.", null, "Uhlenhaut", null)), + Arguments.of("Nu{\\~{n}}ez, Jose", new Author("Jose", "J.", null, "Nu{\\~{n}}ez", null)) ); } diff --git a/src/test/java/org/jabref/logic/integrity/PersonNamesCheckerTest.java b/src/test/java/org/jabref/logic/integrity/PersonNamesCheckerTest.java index e6ed2c2b743..b64900e6122 100644 --- a/src/test/java/org/jabref/logic/integrity/PersonNamesCheckerTest.java +++ b/src/test/java/org/jabref/logic/integrity/PersonNamesCheckerTest.java @@ -29,48 +29,35 @@ public void setUp() throws Exception { checkerb = new PersonNamesChecker(database); } - @Test - public void validNameFirstnameAuthor() throws Exception { - assertEquals(Optional.empty(), checker.checkValue("Kolb, Stefan")); + @ParameterizedTest + @MethodSource("provideValidNames") + public void validNames(String name) { + assertEquals(Optional.empty(), checker.checkValue(name)); } - @Test - public void validNameFirstnameAuthors() throws Exception { - assertEquals(Optional.empty(), checker.checkValue("Kolb, Stefan and Harrer, Simon")); - } + private static Stream provideValidNames() { + return Stream.of( + "Kolb, Stefan", // single [Name, Firstname] + "Kolb, Stefan and Harrer, Simon", // multiple [Name, Firstname] + "Stefan Kolb", // single [Firstname Name] + "Stefan Kolb and Simon Harrer", // multiple [Firstname Name] - @Test - public void validFirstnameNameAuthor() throws Exception { - assertEquals(Optional.empty(), checker.checkValue("Stefan Kolb")); - } + "M. J. Gotay", // second name in front - @Test - public void validFirstnameNameAuthors() throws Exception { - assertEquals(Optional.empty(), checker.checkValue("Stefan Kolb and Simon Harrer")); + "{JabRef}", // corporate name in brackets + "{JabRef} and Stefan Kolb", // mixed corporate name with name + "{JabRef} and Kolb, Stefan", + + "hugo Para{\\~n}os" // tilde in name + ); } @Test - public void complainAboutPersonStringWithTwoManyCommas() throws Exception { + public void complainAboutPersonStringWithTwoManyCommas() { assertEquals(Optional.of("Names are not in the standard BibTeX format."), checker.checkValue("Test1, Test2, Test3, Test4, Test5, Test6")); } - @Test - public void doNotComplainAboutSecondNameInFront() throws Exception { - assertEquals(Optional.empty(), checker.checkValue("M. J. Gotay")); - } - - @Test - public void validCorporateNameInBrackets() throws Exception { - assertEquals(Optional.empty(), checker.checkValue("{JabRef}")); - } - - @Test - public void validCorporateNameAndPerson() throws Exception { - assertEquals(Optional.empty(), checker.checkValue("{JabRef} and Stefan Kolb")); - assertEquals(Optional.empty(), checker.checkValue("{JabRef} and Kolb, Stefan")); - } - @ParameterizedTest @MethodSource("provideCorrectFormats") public void authorNameInCorrectFormatsShouldNotComplain(String input) { @@ -84,13 +71,19 @@ public void authorNameInIncorrectFormatsShouldComplain(String input) { } private static Stream provideCorrectFormats() { - return Stream.of("", "Knuth", "Donald E. Knuth and Kurt Cobain and A. Einstein"); + return Stream.of( + "", + "Knuth", + "Donald E. Knuth and Kurt Cobain and A. Einstein"); } private static Stream provideIncorrectFormats() { - return Stream.of(" Knuth, Donald E. ", - "Knuth, Donald E. and Kurt Cobain and A. Einstein", - ", and Kurt Cobain and A. Einstein", "Donald E. Knuth and Kurt Cobain and ,", - "and Kurt Cobain and A. Einstein", "Donald E. Knuth and Kurt Cobain and"); + return Stream.of( + " Knuth, Donald E. ", + "Knuth, Donald E. and Kurt Cobain and A. Einstein", + ", and Kurt Cobain and A. Einstein", + "Donald E. Knuth and Kurt Cobain and ,", + "and Kurt Cobain and A. Einstein", + "Donald E. Knuth and Kurt Cobain and"); } }