Fixed regex for Cli mode
This commit is contained in:
parent
ad9c6ce6ef
commit
92fe6db09e
|
@ -29,27 +29,34 @@ class Page {
|
|||
// Split the line in 2 parts, limiter by :
|
||||
$parts = explode(':', $line, 2);
|
||||
|
||||
// Remove all characters except letters and dash -
|
||||
$parts[0] = preg_replace('/[^A-Za-z\-]/', '', $parts[0]);
|
||||
$field = $parts[0]; // title, date, slug
|
||||
$value = isset($parts[1])?$parts[1]:false; // value of title, value of date
|
||||
|
||||
// Lowercase
|
||||
$parts[0] = Text::lowercase($parts[0]);
|
||||
// Remove all characters except letters and dash - from field
|
||||
$field = preg_replace('/[^A-Za-z\-]/', '', $field);
|
||||
|
||||
// Field to lowercase
|
||||
$field = Text::lowercase($field);
|
||||
|
||||
// Check if the current line start the content of the page
|
||||
// We have two breakers, the word content or 3 dash ---
|
||||
if( ($parts[0]==='content') || ($parts[0]==='---') ) {
|
||||
if( ($field==='content') || ($field==='---') ) {
|
||||
$tmp = $lineNumber;
|
||||
break;
|
||||
}
|
||||
|
||||
if( !empty($parts[0]) && !empty($parts[1]) ) {
|
||||
// remove missing dashs -
|
||||
$field = preg_replace('/[^A-Za-z]/', '', $parts[0]);
|
||||
if( !empty($field) && !empty($value) ) {
|
||||
// Remove missing dashs -
|
||||
$field = preg_replace('/[^A-Za-z]/', '', $field);
|
||||
|
||||
// remove empty spaces on borders
|
||||
$value = trim($parts[1]);
|
||||
// Remove <-- and -->
|
||||
$value = preg_replace('/<\-\-/', '', $value);
|
||||
$value = preg_replace('/\-\->/', '', $value);
|
||||
|
||||
// position accept only integers
|
||||
// Remove empty spaces on borders
|
||||
$value = trim($value);
|
||||
|
||||
// Position accepts only integers
|
||||
if ($field=='position') {
|
||||
$value = preg_replace('/[^0-9]/', '', $value);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue