|
Lines 36-46
class CitationListTokenizerFilter extends Filter {
|
Link Here
|
|---|
|
| 36 |
function &process(&$input) { |
36 |
function &process(&$input) { |
| 37 |
// The default implementation assumes that raw citations are |
37 |
// The default implementation assumes that raw citations are |
| 38 |
// separated with line endings. |
38 |
// separated with line endings. |
| 39 |
// 1) Remove empty lines and normalize line endings |
39 |
// 1) Remove empty lines and normalize line endings. |
| 40 |
$input = String::regexp_replace('/[\r\n]+/s', "\n", $input); |
40 |
$input = String::regexp_replace('/[\r\n]+/s', "\n", $input); |
| 41 |
// 2) Break up at line endings |
41 |
// 2) Remove trailing/leading line breaks. |
| 42 |
$citations = explode("\n", $input); |
42 |
$input = trim($input, "\n"); |
| 43 |
// 3) Remove numbers from the beginning of each citation |
43 |
// 3) Break up at line endings. |
|
|
44 |
if (empty($input)) { |
| 45 |
$citations = array(); |
| 46 |
} else { |
| 47 |
$citations = explode("\n", $input); |
| 48 |
} |
| 49 |
// 4) Remove numbers from the beginning of each citation. |
| 44 |
foreach($citations as $index => $citation) { |
50 |
foreach($citations as $index => $citation) { |
| 45 |
$citations[$index] = String::regexp_replace('/^\s*[\[#]?[0-9]+[.)\]]?\s*/', '', $citation); |
51 |
$citations[$index] = String::regexp_replace('/^\s*[\[#]?[0-9]+[.)\]]?\s*/', '', $citation); |
| 46 |
} |
52 |
} |