Skip to content

Commit 5bd49bf

Browse files
harii55koppor
andauthored
Reformat BibTex in Show BibTex Source (#13761)
* fix(ui): format BibTeX shown in import dialog source view * Add CHANGELOG.md entry --------- Co-authored-by: Oliver Kopp <[email protected]>
1 parent b8eeb2c commit 5bd49bf

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
7373
- We improved JabRef's internal document viewer. It now allows text section, searching and highlighting of search terms and page rotation [#13193](https://github.com/JabRef/jabref/pull/13193).
7474
- When importing a PDF, there is no empty entry column shown in the multi merge dialog. [#13132](https://github.com/JabRef/jabref/issues/13132)
7575
- We added a progress dialog to the "Check consistency" action and progress output to the corresponding cli command. [#12487](https://github.com/JabRef/jabref/issues/12487)
76+
- The BibTeX source is now formatted using the JabRef style at the import inspection dialog. [#13015](https://github.com/JabRef/jabref/issues/13015)
7677
- We made the `check-consistency` command of the toolkit always return an exit code; 0 means no issues found, a non-zero exit code reflects any issues, which allows CI to fail in these cases [#13328](https://github.com/JabRef/jabref/issues/13328).
7778
- We changed the validation error dialog for overriding the default file directories to a confirmation dialog for saving other preferences under the library properties. [#13488](https://github.com/JabRef/jabref/pull/13488)
7879
- We made the copy sub menu on the context menu consistent with the copy sub menu at "Edit". [#13280](https://github.com/JabRef/jabref/pull/13280)

jabgui/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ public String getSourceString(BibEntry entry) {
125125
BibWriter bibWriter = new BibWriter(writer, OS.NEWLINE);
126126
FieldWriter fieldWriter = FieldWriter.buildIgnoreHashes(preferences.getFieldPreferences());
127127
try {
128-
new BibEntryWriter(fieldWriter, entryTypesManager).write(entry, bibWriter, selectedDb.getValue().getMode());
128+
// Force reformatting so the displayed BibTeX is consistently formatted
129+
new BibEntryWriter(fieldWriter, entryTypesManager).write(entry, bibWriter, selectedDb.getValue().getMode(), true);
129130
} catch (IOException ioException) {
130-
return "";
131+
// In case of error, fall back to the original parsed serialization if available
132+
return entry.getParsedSerialization();
131133
}
132134
return writer.toString();
133135
}

0 commit comments

Comments
 (0)