Skip to content

Commit

Permalink
Merge pull request #10002 from bozana/9946-3_4_0
Browse files Browse the repository at this point in the history
#9946 Do not remove numbers from the beginning of each cit…
  • Loading branch information
bozana authored Jun 1, 2024
2 parents 4a0a09e + 7bc8876 commit facf529
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions classes/citation/CitationListTokenizerFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ public function &process(&$input)
} else {
$citations = explode("\n", $input);
}
// 4) Remove numbers from the beginning of each citation.
foreach ($citations as $index => $citation) {
$citations[$index] = PKPString::regexp_replace('/^\s*[\[#]?[0-9]+[.)\]]?\s*/', '', $citation);
}
// 4) Remove whitespace from the beginning and the end of each citation.
$citations = array_map('trim', $citations);

return $citations;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/classes/citation/CitationListTokenizerFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public function testCitationListTokenizerFilter()
$tokenizer = new CitationListTokenizerFilter();
$rawCitationList = "\t1. citation1\n\n2 citation2\r\n 3) citation3\n[4]citation4";
$expectedResult = [
'citation1',
'citation2',
'citation3',
'citation4'
'1. citation1',
'2 citation2',
'3) citation3',
'[4]citation4'
];
self::assertEquals($expectedResult, $tokenizer->process($rawCitationList));

Expand Down

0 comments on commit facf529

Please sign in to comment.