Skip to content

Fix IEEE preview does not display month #3983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 2, 2018
12 changes: 11 additions & 1 deletion src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
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.FieldName;
import org.jabref.model.entry.Month;

import de.undercouch.citeproc.CSL;
import de.undercouch.citeproc.ItemDataProvider;
Expand Down Expand Up @@ -82,6 +84,9 @@ private static class JabRefItemDataProvider implements ItemDataProvider {

/**
* Converts the {@link BibEntry} into {@link CSLItemData}.
*
* Change month field from JabRefFormat <code>#mon#</> to ShortName <code>mon</code>
* because CSL does not support JabRefFormat.
*/
private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) {
String citeKey = bibEntry.getCiteKeyOptional().orElse("");
Expand All @@ -94,7 +99,12 @@ private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) {
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().map(Month::getShortName).orElse(value);
}
bibTeXEntry.addField(new Key(key), new DigitStringValue(value));
});
}
return BIBTEX_CONVERTER.toItemData(bibTeXEntry);
}
Expand Down