From 5d67695e88f72040222c817785cad7c619001be1 Mon Sep 17 00:00:00 2001 From: Jonatan Asketorp <2598631+k3KAW8Pnf7mkmdSMPHz27@users.noreply.github.com> Date: Mon, 2 Aug 2021 17:06:38 -0400 Subject: [PATCH] Add `unprotect_terms` to the list of modifiers for bracketed patterns (#7960) --- CHANGELOG.md | 1 + src/main/java/org/jabref/logic/formatter/Formatters.java | 4 +++- .../logic/citationkeypattern/BracketedPatternTest.java | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b6e9aa67f6..cd32fdd16bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We added the option to copy the DOI of an entry directly from the context menu copy submenu. [#7826](https://github.com/JabRef/jabref/issues/7826) - We added a fulltext search feature. [#2838](https://github.com/JabRef/jabref/pull/2838) +- We added unprotect_terms to the list of bracketed pattern modifiers [#7826](https://github.com/JabRef/jabref/pull/7960) ### Changed diff --git a/src/main/java/org/jabref/logic/formatter/Formatters.java b/src/main/java/org/jabref/logic/formatter/Formatters.java index a97c3a85235..0eddde42194 100644 --- a/src/main/java/org/jabref/logic/formatter/Formatters.java +++ b/src/main/java/org/jabref/logic/formatter/Formatters.java @@ -29,6 +29,7 @@ import org.jabref.logic.formatter.casechanger.LowerCaseFormatter; import org.jabref.logic.formatter.casechanger.SentenceCaseFormatter; import org.jabref.logic.formatter.casechanger.TitleCaseFormatter; +import org.jabref.logic.formatter.casechanger.UnprotectTermsFormatter; import org.jabref.logic.formatter.casechanger.UpperCaseFormatter; import org.jabref.logic.formatter.minifier.MinifyNameListFormatter; import org.jabref.logic.formatter.minifier.TruncateFormatter; @@ -74,7 +75,8 @@ public static List getOthers() { new UnitsToLatexFormatter(), new EscapeUnderscoresFormatter(), new EscapeAmpersandsFormatter(), - new ShortenDOIFormatter() + new ShortenDOIFormatter(), + new UnprotectTermsFormatter() ); } diff --git a/src/test/java/org/jabref/logic/citationkeypattern/BracketedPatternTest.java b/src/test/java/org/jabref/logic/citationkeypattern/BracketedPatternTest.java index de02294c736..5d84f2c45a1 100644 --- a/src/test/java/org/jabref/logic/citationkeypattern/BracketedPatternTest.java +++ b/src/test/java/org/jabref/logic/citationkeypattern/BracketedPatternTest.java @@ -386,6 +386,13 @@ void expandBracketsWithTestCasesFromRegExpBasedFileFinder() { BracketedPattern.expandBrackets("[author] have published [title] in [journal].", ',', entry, database)); } + @Test + void expandBracketsWithoutProtectiveBracesUsingUnprotectTermsModifier() { + BibEntry bibEntry = new BibEntry() + .withField(StandardField.JOURNAL, "{ACS} Medicinal Chemistry Letters"); + assertEquals("ACS Medicinal Chemistry Letters", BracketedPattern.expandBrackets("[JOURNAL:unprotect_terms]", null, bibEntry, null)); + } + @ParameterizedTest @MethodSource("provideArgumentsForFallback") void expandBracketsWithFallback(String expandResult, String pattern) {