From 38b70e23020ef98b8da0abf674d67893c30e1e25 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 21 Nov 2024 20:18:23 +0100 Subject: [PATCH 1/3] Update Gradle Wrapper from 8.11 to 8.11.1 (#12218) Signed-off-by: gradle-update-robot Co-authored-by: gradle-update-robot --- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 82dd18b2043..eb1a55be0e1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=57dafb5c2622c6cc08b993c85b7c06956a2f53536432a30ead46166dbca0f1e9 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip +distributionSha256Sum=f397b287023acdba1e9f6fc5ea72d22dd63669d59ed4a289a29b1a76eee151c6 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From 4f8ece31e7d8f5feb74f02c3e8eff0d6dcfbbd6e Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 23 Nov 2024 07:22:09 +0100 Subject: [PATCH 2/3] move check for invalid characters to linked files editor (#12219) * move check for invalid characters to linked files editor Fixes #12212 some cleanup * fix checkstyle * restore switch * set working dir path * checkstyle * add test * fix import --- .../gui/fieldeditors/LinkedFilesEditor.java | 2 +- .../LinkedFilesEditorViewModel.java | 60 +------------------ .../LinkedFileEditDialogViewModel.java | 39 ++++++++++-- .../org/jabref/logic/util/io/FileUtil.java | 11 ++-- .../LinkedFileEditDialogViewModelTest.java | 55 +++++++++++++++++ 5 files changed, 95 insertions(+), 72 deletions(-) create mode 100644 src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java index ea30f18d3c9..96c00de9f3b 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java @@ -287,7 +287,7 @@ public Parent getNode() { @FXML private void addNewFile() { - dialogService.showCustomDialogAndWait(new LinkedFileEditDialog()).ifPresent(newLinkedFile -> { + dialogService.showCustomDialogAndWait(new LinkedFileEditDialog()).filter(file -> !file.isEmpty()).ifPresent(newLinkedFile -> { viewModel.addNewLinkedFile(newLinkedFile); }); } diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java index 540e5603d36..4cd947b2287 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java @@ -4,7 +4,6 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URL; -import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -32,7 +31,6 @@ import org.jabref.gui.linkedfile.AttachFileFromURLAction; import org.jabref.gui.preferences.GuiPreferences; import org.jabref.gui.util.BindingsHelper; -import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.bibtex.FileFieldWriter; import org.jabref.logic.importer.FulltextFetchers; import org.jabref.logic.importer.util.FileFieldParser; @@ -40,7 +38,6 @@ import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.BackgroundTask; import org.jabref.logic.util.TaskExecutor; -import org.jabref.logic.util.io.FileNameCleaner; import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; @@ -107,19 +104,6 @@ public static LinkedFile fromFile(Path file, List fileDirectories, Externa return new LinkedFile("", relativePath, suggestedFileType.getName()); } - public LinkedFileViewModel fromFile(Path file, ExternalApplicationsPreferences externalApplicationsPreferences) { - List fileDirectories = databaseContext.getFileDirectories(preferences.getFilePreferences()); - - LinkedFile linkedFile = fromFile(file, fileDirectories, externalApplicationsPreferences); - return new LinkedFileViewModel( - linkedFile, - entry, - databaseContext, - taskExecutor, - dialogService, - preferences); - } - private List parseToFileViewModel(String stringValue) { return FileFieldParser.parse(stringValue).stream() .map(linkedFile -> new LinkedFileViewModel( @@ -140,41 +124,6 @@ public ListProperty filesProperty() { return files; } - public void addNewFile() { - Path workingDirectory = databaseContext.getFirstExistingFileDir(preferences.getFilePreferences()) - .orElse(preferences.getFilePreferences().getWorkingDirectory()); - - FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() - .withInitialDirectory(workingDirectory) - .build(); - - List fileDirectories = databaseContext.getFileDirectories(preferences.getFilePreferences()); - List selectedFiles = dialogService.showFileOpenDialogAndGetMultipleFiles(fileDialogConfiguration); - - for (Path fileToAdd : selectedFiles) { - if (FileUtil.detectBadFileName(fileToAdd.toString())) { - String newFilename = FileNameCleaner.cleanFileName(fileToAdd.getFileName().toString()); - - boolean correctButtonPressed = dialogService.showConfirmationDialogAndWait(Localization.lang("File \"%0\" cannot be added!", fileToAdd.getFileName()), - Localization.lang("Illegal characters in the file name detected.\nFile will be renamed to \"%0\" and added.", newFilename), - Localization.lang("Rename and add")); - - if (correctButtonPressed) { - Path correctPath = fileToAdd.resolveSibling(newFilename); - try { - Files.move(fileToAdd, correctPath); - addNewLinkedFile(correctPath, fileDirectories); - } catch (IOException ex) { - LOGGER.error("Error moving file", ex); - dialogService.showErrorDialogAndWait(ex); - } - } - } else { - addNewLinkedFile(fileToAdd, fileDirectories); - } - } - } - public void addNewLinkedFile(LinkedFile linkedFile) { files.add(new LinkedFileViewModel( linkedFile, @@ -185,22 +134,17 @@ public void addNewLinkedFile(LinkedFile linkedFile) { preferences)); } - private void addNewLinkedFile(Path correctPath, List fileDirectories) { - LinkedFile newLinkedFile = fromFile(correctPath, fileDirectories, preferences.getExternalApplicationsPreferences()); - addNewLinkedFile(newLinkedFile); - } - @Override public void bindToEntry(BibEntry entry) { super.bindToEntry(entry); - if ((entry != null) && preferences.getEntryEditorPreferences().autoLinkFilesEnabled()) { + if (preferences.getEntryEditorPreferences().autoLinkFilesEnabled()) { LOGGER.debug("Auto-linking files for entry {}", entry); BackgroundTask> findAssociatedNotLinkedFiles = BackgroundTask .wrap(() -> findAssociatedNotLinkedFiles(entry)) .onSuccess(list -> { if (!list.isEmpty()) { - LOGGER.debug("Found non-associated files:", list); + LOGGER.debug("Found non-associated files: {}", list); files.addAll(list); } }); diff --git a/src/main/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModel.java b/src/main/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModel.java index cd31283742c..82863bc6c5b 100644 --- a/src/main/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModel.java +++ b/src/main/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModel.java @@ -1,7 +1,9 @@ package org.jabref.gui.linkedfile; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; +import java.nio.file.Files; import java.nio.file.Path; import java.util.Optional; import java.util.regex.Pattern; @@ -22,15 +24,22 @@ import org.jabref.gui.frame.ExternalApplicationsPreferences; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.FilePreferences; +import org.jabref.logic.l10n.Localization; +import org.jabref.logic.util.io.FileNameCleaner; import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.LinkedFile; +import com.google.common.annotations.VisibleForTesting; import com.tobiasdiez.easybind.EasyBind; import com.tobiasdiez.easybind.optional.ObservableOptionalValue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LinkedFileEditDialogViewModel extends AbstractViewModel { + private static final Logger LOGGER = LoggerFactory.getLogger(LinkedFileEditDialogViewModel.class); + private static final Pattern REMOTE_LINK_PATTERN = Pattern.compile("[a-z]+://.*"); private final StringProperty link = new SimpleStringProperty(""); private final StringProperty description = new SimpleStringProperty(""); @@ -86,13 +95,31 @@ public void openBrowseDialog() { .withInitialFileName(fileName) .build(); - dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(path -> { - // Store the directory for next time: - filePreferences.setWorkingDirectory(path); - link.set(relativize(path)); + dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(this::checkForBadFileNameAndAdd); + } - setExternalFileTypeByExtension(link.getValueSafe()); - }); + @VisibleForTesting + void checkForBadFileNameAndAdd(Path fileToAdd) { + if (FileUtil.detectBadFileName(fileToAdd.toString())) { + String newFilename = FileNameCleaner.cleanFileName(fileToAdd.getFileName().toString()); + + boolean correctButtonPressed = dialogService.showConfirmationDialogAndWait(Localization.lang("File \"%0\" cannot be added!", fileToAdd.getFileName()), + Localization.lang("Illegal characters in the file name detected.\nFile will be renamed to \"%0\" and added.", newFilename), + Localization.lang("Rename and add")); + + if (correctButtonPressed) { + Path correctPath = fileToAdd.resolveSibling(newFilename); + try { + Files.move(fileToAdd, correctPath); + link.set(relativize(correctPath)); + filePreferences.setWorkingDirectory(correctPath); + setExternalFileTypeByExtension(link.getValueSafe()); + } catch (IOException ex) { + LOGGER.error("Error moving file", ex); + dialogService.showErrorDialogAndWait(ex); + } + } + } } public void setValues(LinkedFile linkedFile) { diff --git a/src/main/java/org/jabref/logic/util/io/FileUtil.java b/src/main/java/org/jabref/logic/util/io/FileUtil.java index 3240e64034f..5ddb734d8ce 100644 --- a/src/main/java/org/jabref/logic/util/io/FileUtil.java +++ b/src/main/java/org/jabref/logic/util/io/FileUtil.java @@ -576,13 +576,10 @@ public static String shortenFileName(String fileName, Integer maxLength) { numCharsBeforeEllipsis = Math.min(numCharsBeforeEllipsis, name.length()); numCharsAfterEllipsis = Math.min(numCharsAfterEllipsis, name.length() - numCharsBeforeEllipsis); - StringBuilder result = new StringBuilder(); - result.append(name, 0, numCharsBeforeEllipsis) - .append(ELLIPSIS) - .append(name.substring(name.length() - numCharsAfterEllipsis)) - .append(extension); - - return result.toString(); + return name.substring(0, numCharsBeforeEllipsis) + + ELLIPSIS + + name.substring(name.length() - numCharsAfterEllipsis) + + extension; } public static boolean isCharLegal(char c) { diff --git a/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java b/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java new file mode 100644 index 00000000000..d19c5d9cbb0 --- /dev/null +++ b/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java @@ -0,0 +1,55 @@ +package org.jabref.gui.linkedfile; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.TreeSet; + +import javafx.collections.FXCollections; + +import org.jabref.gui.DialogService; +import org.jabref.gui.externalfiletype.ExternalFileTypes; +import org.jabref.gui.frame.ExternalApplicationsPreferences; +import org.jabref.gui.preferences.GuiPreferences; +import org.jabref.logic.FilePreferences; +import org.jabref.model.database.BibDatabaseContext; +import org.jabref.model.entry.LinkedFile; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.Answers; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +class LinkedFileEditDialogViewModelTest { + private final GuiPreferences preferences = mock(GuiPreferences.class, Answers.RETURNS_DEEP_STUBS); + private final FilePreferences filePreferences = mock(FilePreferences.class, Answers.RETURNS_DEEP_STUBS); + private final BibDatabaseContext bibDatabaseContext = mock(BibDatabaseContext.class); + private final DialogService dialogService = mock(DialogService.class); + private final ExternalApplicationsPreferences externalApplicationsPreferences = mock(ExternalApplicationsPreferences.class); + + @BeforeEach + void setup() { + when(externalApplicationsPreferences.getExternalFileTypes()).thenReturn(FXCollections.observableSet(new TreeSet<>(ExternalFileTypes.getDefaultExternalFileTypes()))); + when(preferences.getExternalApplicationsPreferences()).thenReturn(externalApplicationsPreferences); + when(preferences.getFilePreferences()).thenReturn(filePreferences); + } + + @Test + void badFilenameCharWillBeReplacedByUnderscore(@TempDir Path tempDir) throws Exception { + + Path invalidFile = tempDir.resolve("?invalid.pdf"); + Files.createFile(invalidFile); + when(dialogService.showConfirmationDialogAndWait(any(), any(), any())).thenReturn(true); + + LinkedFileEditDialogViewModel viewModel = new LinkedFileEditDialogViewModel(new LinkedFile("", "", ""), bibDatabaseContext, dialogService, externalApplicationsPreferences, filePreferences); + + viewModel.checkForBadFileNameAndAdd(invalidFile); + + LinkedFile expectedFile = new LinkedFile("", tempDir.resolve("_invalid.pdf").toString(), "PDF"); + assertEquals(expectedFile, viewModel.getNewLinkedFile()); + } +} From de81430c1472920304c8348207ee2af9ec525822 Mon Sep 17 00:00:00 2001 From: Subhramit Basu Bhowmick Date: Sun, 24 Nov 2024 14:55:19 +0530 Subject: [PATCH 3/3] [OO] Major performance improvements & fixes (#12221) * Transform \n->

, reduce LibreOffice API calls, improve documentation * Remove unnecessary regex transform, improve trailing regex match * Fix tests * Minor fix - comment --- .../oocsltext/CSLCitationOOAdapter.java | 15 ---- .../openoffice/oocsltext/CSLFormatUtils.java | 15 +++- .../oocsltext/CSLUpdateBibliography.java | 2 - .../oocsltext/CSLFormatUtilsTest.java | 80 ++++++------------- 4 files changed, 36 insertions(+), 76 deletions(-) diff --git a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java index 865806947f3..e9c611f02ec 100644 --- a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java +++ b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java @@ -69,7 +69,6 @@ public void insertCitation(XTextCursor cursor, CitationStyle selectedStyle, List OOText ooText = OOFormat.setLocaleNone(OOText.fromString(formattedCitation)); insertReferences(cursor, entries, ooText, selectedStyle.isNumericStyle()); - cursor.collapseToEnd(); } /** @@ -119,7 +118,6 @@ public void insertInTextCitation(XTextCursor cursor, CitationStyle selectedStyle } OOText ooText = OOFormat.setLocaleNone(OOText.fromString(finalText)); insertReferences(cursor, List.of(currentEntry), ooText, selectedStyle.isNumericStyle()); - cursor.collapseToEnd(); } } @@ -131,9 +129,6 @@ public void insertEmpty(XTextCursor cursor, CitationStyle selectedStyle, List entries, OOText CSLReferenceMark mark = markManager.createReferenceMark(entries); mark.insertReferenceIntoOO(document, cursor, ooText, !preceedingSpaceExists, false); - // Move the cursor to the end of the inserted text - cursor.collapseToEnd(); - markManager.setUpdateRequired(isNumericStyle); readAndUpdateExistingMarks(); - cursor.collapseToEnd(); } /** diff --git a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java index 1ac64172287..525a1803be5 100644 --- a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java +++ b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java @@ -72,6 +72,15 @@ public static String transformHTML(String html) { // Clean up any remaining span tags html = html.replaceAll("]*>", ""); + // Convert line breaks to paragraph breaks + html = html.replaceAll("[\n\r]+", "

"); + + // Remove leading paragraph tags (preserving any whitespaces after them for indentation) + html = html.replaceAll("^\\s*

\\s*

", ""); + + // Remove extra trailing paragraph tags when there are multiple (keeping one) + html = html.replaceAll("(?:

\\s*

\\s*){2,}$", "

"); + return html; } @@ -113,9 +122,9 @@ public static String generateAlphanumericCitation(List entries, BibDat /** * Method to update citation number of a bibliographic entry (to be inserted in the list of references). - * By default, citeproc-java ({@link org.jabref.logic.citationstyle.CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography} always start the numbering of a list of citations with "1". - * If a citation doesn't correspond to the first cited entry, the number should be changed to the relevant current citation number. - * If an entries has been cited before, the colder number should be reused. + * By default, citeproc-java ({@link org.jabref.logic.citationstyle.CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography} always starts the numbering of a list of citations with "1". + * If a citation doesn't correspond to the first cited entry, the number should be changed to the appropriate current citation number. + * The numbers should be globally unique. If an entry has been cited before, the older citation number corresponding to it should be reused. * The number can be enclosed in different formats, such as "1", "1.", "1)", "(1)" or "[1]". *

* Precondition: Use ONLY with numeric citation styles.

diff --git a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLUpdateBibliography.java b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLUpdateBibliography.java index 107974934b4..732db3899ec 100644 --- a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLUpdateBibliography.java +++ b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLUpdateBibliography.java @@ -101,9 +101,7 @@ private void populateCSLBibTextSection(XTextDocument doc, // Use CSLCitationOOAdapter to insert the bibliography cslAdapter.insertBibliography(cursor, citationStyle, entries, bibDatabaseContext, bibEntryTypesManager); - LOGGER.debug("Bibliography inserted using CSLCitationOOAdapter"); - cursor.collapseToEnd(); LOGGER.debug("CSL bibliography section population completed"); } } diff --git a/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java b/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java index 57e054027fa..69df8bb42f1 100644 --- a/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java +++ b/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java @@ -159,114 +159,94 @@ static Stream ooHTMLTransformFromRawBibliography() { // Non-numeric, parentheses, commas, full stops, slashes, hyphens, colons, italics Arguments.of( - " Smith, B., Jones, B., & Williams, J. (2016). Title of the test entry. BibTeX Journal, 34(3), 45–67. https://doi.org/10.1001/bla.blubb\n", + " Smith, B., Jones, B., & Williams, J. (2016). Title of the test entry. BibTeX Journal, 34(3), 45–67. https://doi.org/10.1001/bla.blubb

", STYLE_LIST.stream().filter(e -> "American Psychological Association 7th edition".equals(e.getTitle())).findAny().get() ), // Numeric type "[1]", brackets, newlines Arguments.of( - " \n" + - " [1] B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016, doi: 10.1001/bla.blubb.\n" + - " \n", + " [1] B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016, doi: 10.1001/bla.blubb.

", STYLE_LIST.stream().filter(e -> "IEEE".equals(e.getTitle())).findAny().get() ), // Numeric type "1." Arguments.of( - " \n" + - " 1. Smith, B., Jones, B., Williams, J.: Title of the test entry. BibTeX Journal. 34, 45–67 (2016). https://doi.org/10.1001/bla.blubb.\n" + - " \n", + " 1. Smith, B., Jones, B., Williams, J.: Title of the test entry. BibTeX Journal. 34, 45–67 (2016). https://doi.org/10.1001/bla.blubb.

", STYLE_LIST.stream().filter(e -> "Springer - Lecture Notes in Computer Science".equals(e.getTitle())).findAny().get() ), Arguments.of( - " Smith, Bill, Bob Jones, and Jeff Williams. 2016. “Title of the Test Entry.” Edited by Phil Taylor. BibTeX Journal 34 (3): 45–67. https://doi.org/10.1001/bla.blubb.\n", + " Smith, Bill, Bob Jones, and Jeff Williams. 2016. “Title of the Test Entry.” Edited by Phil Taylor. BibTeX Journal 34 (3): 45–67. https://doi.org/10.1001/bla.blubb.

", STYLE_LIST.stream().filter(e -> "Chicago Manual of Style 17th edition (author-date)".equals(e.getTitle())).findAny().get() ), // Semicolons Arguments.of( - " \n" + - " 1. Smith B, Jones B, Williams J. Title of the test entry. Taylor P, editor. BibTeX Journal [Internet]. 2016 Jul;34(3):45–67. Available from: https://github.com/JabRef\n" + - " \n", + " 1. Smith B, Jones B, Williams J. Title of the test entry. Taylor P, editor. BibTeX Journal [Internet]. 2016 Jul;34(3):45–67. Available from: https://github.com/JabRef

", STYLE_LIST.stream().filter(e -> "Vancouver".equals(e.getTitle())).findAny().get() ), Arguments.of( - " \n" + - " 1. Smith, B., Jones, B. & Williams, J. Title of the test entry. BibTeX Journal 34, 45–67 (2016).\n" + - " \n", + " 1. Smith, B., Jones, B. & Williams, J. Title of the test entry. BibTeX Journal 34, 45–67 (2016).

", STYLE_LIST.stream().filter(e -> "Nature".equals(e.getTitle())).findAny().get() ), Arguments.of( - " \n" + - " 1. Smith B, Jones B, Williams J. Title of the test entry. Taylor P, ed. BibTeX Journal. 2016;34(3):45-67. doi:10.1001/bla.blubb\n" + - " \n", + " 1. Smith B, Jones B, Williams J. Title of the test entry. Taylor P, ed. BibTeX Journal. 2016;34(3):45-67. doi:10.1001/bla.blubb

", STYLE_LIST.stream().filter(e -> "American Medical Association 11th edition".equals(e.getTitle())).findAny().get() ), // Small-caps Arguments.of( - " Smith, B., Jones, B., Williams, J. (2016) Title of the test entry Taylor, P. (ed.). BibTeX Journal, 34(3), pp. 45–67.\n", + " Smith, B., Jones, B., Williams, J. (2016) Title of the test entry Taylor, P. (ed.). BibTeX Journal, 34(3), pp. 45–67.

", STYLE_LIST.stream().filter(e -> "De Montfort University - Harvard".equals(e.getTitle())).findAny().get() ), // Underlines Arguments.of( - " Smith, Bill, Bob Jones, and Jeff Williams. “Title of the test entry.” Ed. Phil Taylor. BibTeX Journal 34.3 (2016): 45–67. .\n", + " Smith, Bill, Bob Jones, and Jeff Williams. “Title of the test entry.” Ed. Phil Taylor. BibTeX Journal 34.3 (2016): 45–67. .

", STYLE_LIST.stream().filter(e -> "Modern Language Association 7th edition (underline)".equals(e.getTitle())).findAny().get() ), // Non-breaking spaces Arguments.of( - " Smith, Bill, Bob Jones, & Jeff Williams, “Title of the test entry,” BibTeX Journal, 2016, vol. 34, no. 3, pp. 45–67.\n", + " Smith, Bill, Bob Jones, & Jeff Williams, “Title of the test entry,” BibTeX Journal, 2016, vol. 34, no. 3, pp. 45–67.

", STYLE_LIST.stream().filter(e -> "Histoire & Mesure (Français)".equals(e.getTitle())).findAny().get() ), // Numeric with a full stop - "1." Arguments.of( - " \n" + - " 1. Smith, B., Jones, B. and Williams, J. 2016. Title of the test entry. BibTeX Journal. 34: 45–67.\n" + - " \n", + " 1. Smith, B., Jones, B. and Williams, J. 2016. Title of the test entry. BibTeX Journal. 34: 45–67.

", STYLE_LIST.stream().filter(e -> "The Journal of Veterinary Medical Science".equals(e.getTitle())).findAny().get() ), // Bold text, bold numeric with a full stop - "1." Arguments.of( - " \n" + - " 1. Smith B, Jones B, Williams J. Title of the test entry. BibTeX Journal 2016 ; 34 : 45–67.\n" + - " \n", + " 1. Smith B, Jones B, Williams J. Title of the test entry. BibTeX Journal 2016 ; 34 : 45–67.

", STYLE_LIST.stream().filter(e -> "Acta Orthopædica Belgica".equals(e.getTitle())).findAny().get() ), // Naked numeric - "1" Arguments.of( - " \n" + - " 1 Smith Bill, Jones Bob, Williams Jeff. Title of the test entry. BibTeX Journal 2016;34(3):45–67. Doi: 10.1001/bla.blubb.\n" + - " \n", + " 1 Smith Bill, Jones Bob, Williams Jeff. Title of the test entry. BibTeX Journal 2016;34(3):45–67. Doi: 10.1001/bla.blubb.

", STYLE_LIST.stream().filter(e -> "Acta Anaesthesiologica Taiwanica".equals(e.getTitle())).findAny().get() ), // Numeric in parentheses - "(1)" Arguments.of( - " \n" + - " (1) Smith, B.; Jones, B.; Williams, J. Title of the Test Entry. BibTeX Journal 2016, 34 (3), 45–67. https://doi.org/10.1001/bla.blubb.\n" + - " \n", + " (1) Smith, B.; Jones, B.; Williams, J. Title of the Test Entry. BibTeX Journal 2016, 34 (3), 45–67. https://doi.org/10.1001/bla.blubb.

", STYLE_LIST.stream().filter(e -> "American Chemical Society".equals(e.getTitle())).findAny().get() ), // Numeric with right parenthesis - "1)" Arguments.of( - " \n" + - " 1) Smith B., Jones B., Williams J., BibTeX Journal, 34, 45–67 (2016).\n" + - " \n", + " 1) Smith B., Jones B., Williams J., BibTeX Journal, 34, 45–67 (2016).

", STYLE_LIST.stream().filter(e -> "Chemical and Pharmaceutical Bulletin".equals(e.getTitle())).findAny().get() ), // Numeric in superscript - "1" Arguments.of( - " 1 B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal 34(3), 45–67 (2016).\n", + " 1 B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal 34(3), 45–67 (2016).

", STYLE_LIST.stream().filter(e -> "American Institute of Physics 4th edition".equals(e.getTitle())).findAny().get() ) ); @@ -521,55 +501,43 @@ static Stream updateSingleNumericCitation() { // Type: "[1]" Arguments.of( - " \n" + - " [3] B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016, doi: 10.1001/bla.blubb.\n" + - " \n", + " [3] B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016, doi: 10.1001/bla.blubb.

", STYLE_LIST.stream().filter(e -> "IEEE".equals(e.getTitle())).findAny().get() ), // Type: "1." Arguments.of( - " \n" + - " 3. Smith, B., Jones, B. and Williams, J. 2016. Title of the test entry. BibTeX Journal. 34: 45–67.\n" + - " \n", + " 3. Smith, B., Jones, B. and Williams, J. 2016. Title of the test entry. BibTeX Journal. 34: 45–67.

", STYLE_LIST.stream().filter(e -> "The Journal of Veterinary Medical Science".equals(e.getTitle())).findAny().get() ), - // Type:"1." + // Type: "1." Arguments.of( - " \n" + - " 3. Smith B, Jones B, Williams J. Title of the test entry. BibTeX Journal 2016 ; 34 : 45–67.\n" + - " \n", + " 3. Smith B, Jones B, Williams J. Title of the test entry. BibTeX Journal 2016 ; 34 : 45–67.

", STYLE_LIST.stream().filter(e -> "Acta Orthopædica Belgica".equals(e.getTitle())).findAny().get() ), // Type: "1" Arguments.of( - " \n" + - " 3 Smith Bill, Jones Bob, Williams Jeff. Title of the test entry. BibTeX Journal 2016;34(3):45–67. Doi: 10.1001/bla.blubb.\n" + - " \n", + " 3 Smith Bill, Jones Bob, Williams Jeff. Title of the test entry. BibTeX Journal 2016;34(3):45–67. Doi: 10.1001/bla.blubb.

", STYLE_LIST.stream().filter(e -> "Acta Anaesthesiologica Taiwanica".equals(e.getTitle())).findAny().get() ), // Type: "(1)" Arguments.of( - " \n" + - " (3) Smith, B.; Jones, B.; Williams, J. Title of the Test Entry. BibTeX Journal 2016, 34 (3), 45–67. https://doi.org/10.1001/bla.blubb.\n" + - " \n", + " (3) Smith, B.; Jones, B.; Williams, J. Title of the Test Entry. BibTeX Journal 2016, 34 (3), 45–67. https://doi.org/10.1001/bla.blubb.

", STYLE_LIST.stream().filter(e -> "American Chemical Society".equals(e.getTitle())).findAny().get() ), // Type: "1)" Arguments.of( - " \n" + - " 3) Smith B., Jones B., Williams J., BibTeX Journal, 34, 45–67 (2016).\n" + - " \n", + " 3) Smith B., Jones B., Williams J., BibTeX Journal, 34, 45–67 (2016).

", STYLE_LIST.stream().filter(e -> "Chemical and Pharmaceutical Bulletin".equals(e.getTitle())).findAny().get() ), // Type: "1" Arguments.of( - " 3 B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal 34(3), 45–67 (2016).\n", + " 3 B. Smith, B. Jones, and J. Williams, “Title of the test entry,” BibTeX Journal 34(3), 45–67 (2016).

", STYLE_LIST.stream().filter(e -> "American Institute of Physics 4th edition".equals(e.getTitle())).findAny().get() ) );