Skip to content

Commit e1ca4d6

Browse files
authored
Improve matching of DOIs (#13487)
* Improve matching of DOIs * Add link to PR * Fix if branches
1 parent 1f88ba1 commit e1ca4d6

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
4343
- We added a highlighted diff regarding changes to the Group Tree Structure of a bib file, made outside JabRef. [#11221](https://github.com/JabRef/jabref/issues/11221)
4444
- We added a new setting in the 'Entry Editor' preferences to hide the 'File Annotations' tab when no annotations are available. [#13143](https://github.com/JabRef/jabref/issues/13143)
4545
- We added support for multi-file import across different formats. [#13269](https://github.com/JabRef/jabref/issues/13269)
46+
- We improved the detection of DOIs on the first page of a PDF. [#13487](https://github.com/JabRef/jabref/pull/13487)
4647
- We added support for dark title bar on Windows. [#11457](https://github.com/JabRef/jabref/issues/11457)
4748
- We moved some functionality from the graphical application `jabref` with new command verbs `generate-citation-keys`, `check-consistency`, `fetch`, `search`, `convert`, `generate-bib-from-aux`, `preferences` and `pdf` to the new toolkit. [#13012](https://github.com/JabRef/jabref/pull/13012) [#110](https://github.com/JabRef/jabref/issues/110)
4849
- We merged the 'New Entry', 'Import by ID', and 'New Entry from Plain Text' tools into a single 'Create New Entry' tool. [#8808](https://github.com/JabRef/jabref/issues/8808)

jablib/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.pdfbox.pdmodel.PDDocument;
3232
import org.apache.pdfbox.text.PDFTextStripper;
3333
import org.apache.pdfbox.text.TextPosition;
34+
import org.jspecify.annotations.Nullable;
3435

3536
import static org.jabref.model.strings.StringUtil.isNullOrEmpty;
3637

@@ -576,18 +577,12 @@ Optional<BibEntry> getEntryFromPDFContent(String firstpageContents, String lineS
576577
return Optional.of(entry);
577578
}
578579

579-
private String getDoi(String doi) {
580-
int pos;
581-
if (doi == null) {
582-
pos = curString.indexOf("DOI");
583-
if (pos < 0) {
584-
pos = curString.indexOf(StandardField.DOI.getName());
585-
}
586-
if (pos >= 0) {
587-
return DOI.findInText(curString).map(DOI::asString).orElse(null);
588-
}
580+
private @Nullable String getDoi(@Nullable String currentDoi) {
581+
if (currentDoi != null) {
582+
return currentDoi;
589583
}
590-
return doi;
584+
585+
return DOI.findInText(curString).map(DOI::asString).orElse(null);
591586
}
592587

593588
private String getArXivId(String arXivId) {

0 commit comments

Comments
 (0)