Skip to content

Commit

Permalink
#9946 Do not remove numbers from the beginning of each citation
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed May 31, 2024
1 parent b2819aa commit fe0950d
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 @@ -55,10 +55,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] = preg_replace('/^\s*[\[#]?[0-9]+[.)\]]?\s*/u', '', $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 fe0950d

Please sign in to comment.