diff --git a/CHANGELOG.md b/CHANGELOG.md index c68c9635ce7..8489723adc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where the Medline fetcher was only working when JabRef was running from source [#5645](https://github.com/JabRef/jabref/issues/5645) - We fixed some visual issues in the dark theme [#5764](https://github.com/JabRef/jabref/pull/5764) [#5753](https://github.com/JabRef/jabref/issues/5753) - We fixed an issue where non-default previews didn't handle unicode characters. [#5779](https://github.com/JabRef/jabref/issues/5779) +- We fixed an issue where the ampersand character wasn't rendering correctly on previews.[#3840](https://github.com/JabRef/jabref/issues/3840) ### Removed diff --git a/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java b/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java index a30ca70845e..5728839efe9 100644 --- a/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java +++ b/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java @@ -7,7 +7,6 @@ import java.util.Objects; import org.jabref.logic.formatter.bibtexfields.RemoveNewlinesFormatter; -import org.jabref.logic.layout.format.HTMLChars; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.Month; import org.jabref.model.entry.field.Field; @@ -93,13 +92,11 @@ private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) { BibTeXEntry bibTeXEntry = new BibTeXEntry(new Key(bibEntry.getType().getName()), new Key(citeKey)); // Not every field is already generated into latex free fields - HTMLChars latexToHtmlConverter = new HTMLChars(); RemoveNewlinesFormatter removeNewlinesFormatter = new RemoveNewlinesFormatter(); for (Field key : bibEntry.getFieldMap().keySet()) { bibEntry.getField(key) .map(removeNewlinesFormatter::format) .map(LatexToUnicodeAdapter::format) - .map(latexToHtmlConverter::format) .ifPresent(value -> { if (StandardField.MONTH.equals(key)) { // Change month from #mon# to mon because CSL does not support the former format diff --git a/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java b/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java index ecb7a1d6b37..63627b59809 100644 --- a/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java +++ b/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java @@ -130,4 +130,16 @@ void testHandleDiacritics() { String citation = CitationStyleGenerator.generateCitation(entry, CitationStyle.getDefault()); assertEquals(expected, citation); } + + @Test + void testHandleAmpersand() { + String expectedCitation = "[1]B. Smith, B. Jones, and J. Williams, “&TitleTest&” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016.\n"; + BibEntry entry = TestEntry.getTestEntry(); + entry.setField(StandardField.TITLE, "“&TitleTest&”"); + String style = CitationStyle.getDefault().getSource(); + CitationStyleOutputFormat format = CitationStyleOutputFormat.TEXT; + + String actualCitation = CitationStyleGenerator.generateCitation(entry, style, format); + assertEquals(expectedCitation, actualCitation); + } }