diff --git a/lib/SitePattern.php b/lib/SitePattern.php new file mode 100644 index 0000000..b5ae16b --- /dev/null +++ b/lib/SitePattern.php @@ -0,0 +1,48 @@ + $d) { + if (preg_match('/^#|^\s*$/', $d)) { + // the line contains no data + continue; + } elseif (!preg_match('/^([a-z_]+)(?:\(([a-zA-Z0-9\-_]+)\))?:\s*(.+)$/', $d, $m)) { + throw new SitePatternException("Malformed data on line ".($l + 1), 1); + } + [, $directive, $param, $value] = $m; + switch ($directive) { + case "title": + case "body": + case "date": + case "author": + case "strip": + case "single_page_link": + case "single_page_link_in_feed": + case "next_page_link": + # XPath + case "strip_id_or_class": + case "strip_image_src": + case "find_string": + # string + case "replace_sring": + case "http_header": + # string with param + case "tidy": + case "prune": + case "atodetect_on_failure": + # yes/no boolean + case "test_url": + # URL + default: + # Unsupported directive + } + } + } +} \ No newline at end of file diff --git a/lib/SitePatternException.php b/lib/SitePatternException.php new file mode 100644 index 0000000..5346e20 --- /dev/null +++ b/lib/SitePatternException.php @@ -0,0 +1,10 @@ +