Skip to content

Commit

Permalink
Fix IEEE preview does not display month (JabRef#3239)
Browse files Browse the repository at this point in the history
Make change direct on bibTeXEntry instead of creating a copy of bibEntry
  • Loading branch information
DevSiroukane committed Apr 29, 2018
1 parent 2f022b2 commit 82b05d1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,26 @@ private static class JabRefItemDataProvider implements ItemDataProvider {
/**
* Converts the {@link BibEntry} into {@link CSLItemData}.
*
* Clone bibEntry to make a save changes,
* Change month field from JabRefFormat <code>#mon#</> to ShortName <code>mon</code>
* because CSL does not support JabRefFormat.
*/
private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) {

bibEntry = (BibEntry) bibEntry.clone();

String citeKey = bibEntry.getCiteKeyOptional().orElse("");
BibTeXEntry bibTeXEntry = new BibTeXEntry(new Key(bibEntry.getType()), new Key(citeKey));

// Not every field is already generated into latex free fields
HTMLChars latexToHtmlConverter = new HTMLChars();
RemoveNewlinesFormatter removeNewlinesFormatter = new RemoveNewlinesFormatter();
for (String key : bibEntry.getFieldMap().keySet()) {
if (FieldName.MONTH.equals(key)) {
bibEntry.getFieldMap().put(FieldName.MONTH, bibEntry.getMonth().get().getShortName());
}

bibEntry.getField(key)
.map(removeNewlinesFormatter::format)
.map(latexToHtmlConverter::format)
.ifPresent(value -> bibTeXEntry.addField(new Key(key), new DigitStringValue(value)));
.ifPresent(value -> {
if((FieldName.MONTH.equals(key))){
value = bibEntry.getMonth().get().getShortName();
}
bibTeXEntry.addField(new Key(key), new DigitStringValue(value));
});
}
return BIBTEX_CONVERTER.toItemData(bibTeXEntry);
}
Expand Down

0 comments on commit 82b05d1

Please sign in to comment.