From 16c0e6ce895874a6232eb85b52a9283162909b7d Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Wed, 26 Jun 2024 13:03:22 +0200 Subject: [PATCH] pkp/citationStyleLanguage#120 prefixes and suffixes in the DOI and URL citation element should not be linked --- CitationStyleLanguagePlugin.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CitationStyleLanguagePlugin.php b/CitationStyleLanguagePlugin.php index 3b6e55b..45b7d3f 100644 --- a/CitationStyleLanguagePlugin.php +++ b/CitationStyleLanguagePlugin.php @@ -583,7 +583,15 @@ public function getCitation(PKPRequest $request, Submission $submission, string $additionalMarkup = [ 'DOI' => [ 'function' => function ($item, $renderedValue) { - return '' . $renderedValue . ''; + $prefixPattern = '/.*DOI:/i'; + if (preg_match($prefixPattern, $renderedValue, $prefixMatches)) { + $renderedValue = preg_replace($prefixPattern, '', $renderedValue); + } + $suffixPattern = '#'.$item->DOI.'(.*)$#'; + if (preg_match($suffixPattern, $renderedValue, $suffixMatches)) { + $renderedValue = str_replace($suffixMatches[1], '', $renderedValue); + } + return $prefixMatches[0] . '' . $renderedValue . '' . $suffixMatches[1]; }, 'affixes' => true ], @@ -591,7 +599,7 @@ public function getCitation(PKPRequest $request, Submission $submission, string 'function' => function ($item, $renderedValue) { return '' . $renderedValue . ''; }, - 'affixes' => true + 'affixes' => false ], ];