-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Unstable serialization of jabref-entrytype #181
Comments
I assume you have noticed that it is now in alphabetical order. Not sure if BR Oscar |
I am pretty sure the ordering of the output is done by BibtexEntryWriter. Currently, there are three different styles for ordering the serialization. If your preferences differ between your machines, maybe different styles are selected, resulting in a different output. Did you recently reset preferences? As things stand, this is no bug or issue, but the design of jabref. I am very much for using only one serialization format and disallowing customizations, which would fix all this. But from what I can tell, customization is desired. |
I was only referring to the contents within Did not want to open a general discussion as #116. 😇 |
I think, it has to do with different java versions: |
What? 😦 |
@koppor: can you determine which sorting style you use (which of the writing methods get called in BibtexEntryWriter)? Sorting is done via calling Collection.sort() with a See the following code from BibtexEntryWriter: private void writeRequiredFieldsFirstOptionalFieldsSecondRemainingFieldsThird(BibtexEntry entry, Writer out) throws IOException {
// Write header with type and bibtex-key.
out.write('@' + entry.getType().getName() + '{');
HashSet<String> writtenFields = new HashSet<>();
writeKeyField(entry, out);
writtenFields.add(BibtexEntry.KEY_FIELD);
// Write required fields first.
// Thereby, write the title field first.
boolean hasWritten = writeField(entry, out, "title", false);
writtenFields.add("title");
if (entry.getRequiredFields() != null) {
List<String> requiredFields = getRequiredFieldsSorted(entry);
for (String value : requiredFields) {
if (!writtenFields.contains(value)) { // If field appears both in req. and opt. don't repeat.
hasWritten = hasWritten | writeField(entry, out, value, hasWritten);
writtenFields.add(value);
}
}
}
// Then optional fields
if (entry.getOptionalFields() != null) {
List<String> optionalFields = getOptionalFieldsSorted(entry);
for (String value : optionalFields) {
if (!writtenFields.contains(value)) { // If field appears both in req. and opt. don't repeat.
hasWritten = hasWritten | writeField(entry, out, value, hasWritten);
writtenFields.add(value);
}
}
}
// Then write remaining fields in alphabetic order.
TreeSet<String> remainingFields = new TreeSet<>();
for (String key : entry.getAllFields()) {
boolean writeIt = write ? BibtexFields.isWriteableField(key) :
BibtexFields.isDisplayableField(key);
if (!writtenFields.contains(key) && writeIt) {
remainingFields.add(key);
}
}
for (String field : remainingFields) {
hasWritten = hasWritten | writeField(entry, out, field, hasWritten);
}
// Finally, end the entry.
out.write((hasWritten ? Globals.NEWLINE : "") + '}' + Globals.NEWLINE);
} IF it really is a JVM thing, then it is not our fault and we can close this issue! @koppor: Are you really sure? |
Just tested and commit small bib.
I don't know whether that's really an issue, because we expect our users to have the latest Java versions installed. Maybe you can try with your machines and check if JabRef modifies your file, too. I know, that this is not a really MCVE, but close to it 😇. Feel free to strip it down further. The I'm using the default sorting style (reset preferences 😄). But I wonder what this could have to do with the entries in the |
With |
Is this still relevant? |
Minor remark: The file has been recognized as BibLaTeX even though with the |
@koppor I encounters this issue when I open a bibtex file in JabRef v2.7.1, v2.10 and the latest v3.6. The ordering of fields in an entry behaves differently on different versions. That breaks my version control strategy. How to define the ordering of fields? |
I use JabRef on two different machines and I have a customized entry type. The last time, I wanted to check in my file, following diff is shown:
Note the flipped volume,number,series at the very end.
Is the serialization of entry types unstable? Maybe, it changed from the stable to the development version? The cause might be somewhere in
net.sf.jabref.model.entry.CustomEntryType
, but it looks good in the master branch at first sight.The text was updated successfully, but these errors were encountered: