Skip to content

Commit

Permalink
pkp#120 prefixes and suffixes in the DOI and URL citation element sho…
Browse files Browse the repository at this point in the history
…uld not be linked
  • Loading branch information
bozana committed Jun 26, 2024
1 parent 187a40b commit 16c0e6c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CitationStyleLanguagePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,15 +583,23 @@ public function getCitation(PKPRequest $request, Submission $submission, string
$additionalMarkup = [
'DOI' => [
'function' => function ($item, $renderedValue) {
return '<a href="https://doi.org/' . $item->DOI . '">' . $renderedValue . '</a>';
$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] . '<a href="https://doi.org/' . $item->DOI . '">' . $renderedValue . '</a>' . $suffixMatches[1];
},
'affixes' => true
],
'URL' => [
'function' => function ($item, $renderedValue) {
return '<a href="' . $item->URL . '">' . $renderedValue . '</a>';
},
'affixes' => true
'affixes' => false
],
];

Expand Down

0 comments on commit 16c0e6c

Please sign in to comment.