From fe0950d75c87b3a70d6de9efa94c322969c52e18 Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Fri, 31 May 2024 11:56:27 +0200 Subject: [PATCH] pkp/pkp-lib#9946 Do not remove numbers from the beginning of each citation --- classes/citation/CitationListTokenizerFilter.php | 6 ++---- .../classes/citation/CitationListTokenizerFilterTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/classes/citation/CitationListTokenizerFilter.php b/classes/citation/CitationListTokenizerFilter.php index d1b0e16f490..23c6f3b18fe 100644 --- a/classes/citation/CitationListTokenizerFilter.php +++ b/classes/citation/CitationListTokenizerFilter.php @@ -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; } diff --git a/tests/classes/citation/CitationListTokenizerFilterTest.php b/tests/classes/citation/CitationListTokenizerFilterTest.php index c861b83c756..ff75024e345 100644 --- a/tests/classes/citation/CitationListTokenizerFilterTest.php +++ b/tests/classes/citation/CitationListTokenizerFilterTest.php @@ -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));