-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Changes from 5 commits
6738711
4d7525e
99c6dd5
cb5a8a3
0255d0f
2f022b2
82b05d1
f548163
eb2ad39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
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 de.undercouch.citeproc.CSL; | ||
import de.undercouch.citeproc.ItemDataProvider; | ||
|
@@ -84,13 +85,22 @@ private static class JabRefItemDataProvider implements ItemDataProvider { | |
* Converts the {@link BibEntry} into {@link CSLItemData}. | ||
*/ | ||
private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) { | ||
|
||
// create a copy of 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)) { | ||
// change month field value from "#mon#" to "mon" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why this hack is necessary at this place. In case a field value is surrounded by
and not
See http://help.jabref.org/en/EntryEditor#field-consistency-checking for an explanation. So, I think, either the wrong method is used to get the month or there is something more wrong on JabRef: All other exports should have difficulties. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually necessary. The problem is that csl can not handle the JabRef special Syntax with the #. Therefore the value of the month field without the # is needed. For export usually a latex formatter is applied which takes care of this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @koppor As CSL is not part of our code we cannot inject instructions that handle #mon# forma. |
||
bibEntry.getFieldMap().put(FieldName.MONTH, bibEntry.getMonth().get().getShortName()); | ||
} | ||
|
||
bibEntry.getField(key) | ||
.map(removeNewlinesFormatter::format) | ||
.map(latexToHtmlConverter::format) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code changes above work but are more complicated than they need to. I think an easier solution is to extract the lambda expression in this line ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not notice that bibEntry and BibTeXEntry are different object. I think we do not need to clone bibEntry anymore. I execute this code and it work.
About https://github.com/JabRef/jabref/blob/master/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java I have no idea what I can do if you help me please. I am not used with test on java yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is also an idea, but I would not make the regex. If you have the field month, I would really get the shortname from the BibEntry then, so value = key.getMonth().getShortName There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very good, we are almost there. Please replace the value assignment line by
Background: the Please push the change to your branch and then we can merge! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just post my last request |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment states the same as it is done in the code. So please "Remove Superfluous Comments" Java by Comparison.
You can also describe, why a clone is generated!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a good comment?
Clone was generated because bibEntry is shared with many objects. So, to be sure that non of this objects may have issue after changing month field. I create a copy to change on it.