Skip to content

Commit 9474f5a

Browse files
jjsfernandeztobiasdiez
authored andcommitted
Fix "&" on previews (#5786)
* Removes unnecessary escape on HTMLChars * Reverts change on HTMLChars.java and removes HTML formatting from the CSL adapter. * Adds test to check for ampersand handling
1 parent 371a863 commit 9474f5a

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
1818
- 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)
1919
- 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)
2020
- We fixed an issue where non-default previews didn't handle unicode characters. [#5779](https://github.com/JabRef/jabref/issues/5779)
21+
- We fixed an issue where the ampersand character wasn't rendering correctly on previews.[#3840](https://github.com/JabRef/jabref/issues/3840)
2122

2223

2324
### Removed

src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.util.Objects;
88

99
import org.jabref.logic.formatter.bibtexfields.RemoveNewlinesFormatter;
10-
import org.jabref.logic.layout.format.HTMLChars;
1110
import org.jabref.model.entry.BibEntry;
1211
import org.jabref.model.entry.Month;
1312
import org.jabref.model.entry.field.Field;
@@ -93,13 +92,11 @@ private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) {
9392
BibTeXEntry bibTeXEntry = new BibTeXEntry(new Key(bibEntry.getType().getName()), new Key(citeKey));
9493

9594
// Not every field is already generated into latex free fields
96-
HTMLChars latexToHtmlConverter = new HTMLChars();
9795
RemoveNewlinesFormatter removeNewlinesFormatter = new RemoveNewlinesFormatter();
9896
for (Field key : bibEntry.getFieldMap().keySet()) {
9997
bibEntry.getField(key)
10098
.map(removeNewlinesFormatter::format)
10199
.map(LatexToUnicodeAdapter::format)
102-
.map(latexToHtmlConverter::format)
103100
.ifPresent(value -> {
104101
if (StandardField.MONTH.equals(key)) {
105102
// Change month from #mon# to mon because CSL does not support the former format

src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,16 @@ void testHandleDiacritics() {
130130
String citation = CitationStyleGenerator.generateCitation(entry, CitationStyle.getDefault());
131131
assertEquals(expected, citation);
132132
}
133+
134+
@Test
135+
void testHandleAmpersand() {
136+
String expectedCitation = "[1]B. Smith, B. Jones, and J. Williams, “&TitleTest&” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016.\n";
137+
BibEntry entry = TestEntry.getTestEntry();
138+
entry.setField(StandardField.TITLE, "“&TitleTest&”");
139+
String style = CitationStyle.getDefault().getSource();
140+
CitationStyleOutputFormat format = CitationStyleOutputFormat.TEXT;
141+
142+
String actualCitation = CitationStyleGenerator.generateCitation(entry, style, format);
143+
assertEquals(expectedCitation, actualCitation);
144+
}
133145
}

0 commit comments

Comments
 (0)