Skip to content

Commit

Permalink
Add latex2unicode formatter for displaying previews (#5785)
Browse files Browse the repository at this point in the history
* Adds call to LatexToUnicodeAdapter.format() to CSLAdapter

Adds extra map to the string data to handle diacritics

* Adds test to check if latex2unicode is working properly

* Update CHANGELOG.md with fix for unicode characters
  • Loading branch information
jjsfernandez authored and Siedlerchr committed Dec 24, 2019
1 parent cd6f656 commit dfe2d2d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ 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)


### Removed

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import de.undercouch.citeproc.bibtex.BibTeXConverter;
import de.undercouch.citeproc.csl.CSLItemData;
import de.undercouch.citeproc.output.Bibliography;
import org.jabref.model.strings.LatexToUnicodeAdapter;
import org.jbibtex.BibTeXEntry;
import org.jbibtex.DigitStringValue;
import org.jbibtex.Key;
Expand Down Expand Up @@ -97,6 +98,7 @@ private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) {
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,17 @@ void testXslFoFormat() {
String actualCitation = CitationStyleGenerator.generateCitation(entry, style, format);
assertEquals(expectedCitation, actualCitation);
}

@Test
void testHandleDiacritics() {
BibEntry entry = new BibEntry();
entry.setField(StandardField.AUTHOR, "L{\"a}st, First and Doe, Jane");
// if the default citation style changes this has to be modified.
// in this case ä was added to check if it is formatted appropriately
String expected = " <div class=\"csl-entry\">\n" +
" <div class=\"csl-left-margin\">[1]</div><div class=\"csl-right-inline\">F. Läst and J. Doe, .</div>\n" +
" </div>\n";
String citation = CitationStyleGenerator.generateCitation(entry, CitationStyle.getDefault());
assertEquals(expected, citation);
}
}

0 comments on commit dfe2d2d

Please sign in to comment.