diff --git a/Mf2/Parser.php b/Mf2/Parser.php
index 27805f2..bbba5f2 100644
--- a/Mf2/Parser.php
+++ b/Mf2/Parser.php
@@ -127,9 +127,9 @@ function mfNamesFromClass($class, $prefix='h-') {
$matches = array();
foreach ($classes as $classname) {
- $compare_classname = strtolower(' ' . $classname);
- $compare_prefix = strtolower(' ' . $prefix);
- if (stristr($compare_classname, $compare_prefix) !== false && ($compare_classname != $compare_prefix)) {
+ $compare_classname = ' ' . $classname;
+ $compare_prefix = ' ' . $prefix;
+ if (strstr($compare_classname, $compare_prefix) !== false && ($compare_classname != $compare_prefix)) {
$matches[] = ($prefix === 'h-') ? $classname : substr($classname, strlen($prefix));
}
}
@@ -688,6 +688,11 @@ public function parseH(\DOMElement $e) {
$this->elementPrefixParsed($subMF, 'dt');
$this->elementPrefixParsed($subMF, 'e');
}
+ if($e->tagName == 'area') {
+ $coords = $e->getAttribute('coords');
+ $shape = $e->getAttribute('shape');
+
+ }
// Handle p-*
foreach ($this->xpath->query('.//*[contains(concat(" ", @class) ," p-")]', $e) as $p) {
@@ -762,7 +767,7 @@ public function parseH(\DOMElement $e) {
if (!array_key_exists('name', $return)) {
try {
// Look for img @alt
- if ($e->tagName == 'img' and $e->getAttribute('alt') != '')
+ if (($e->tagName == 'img' or $e->tagName == 'area') and $e->getAttribute('alt') != '')
throw new Exception($e->getAttribute('alt'));
if ($e->tagName == 'abbr' and $e->hasAttribute('title'))
@@ -770,14 +775,35 @@ public function parseH(\DOMElement $e) {
// Look for nested img @alt
foreach ($this->xpath->query('./img[count(preceding-sibling::*)+count(following-sibling::*)=0]', $e) as $em) {
- if ($em->getAttribute('alt') != '')
+ $emNames = mfNamesFromElement($em, 'h-');
+ if(empty($emNames) && $em->getAttribute('alt') != ''){
+ throw new Exception($em->getAttribute('alt'));
+ }
+ }
+
+ // Look for nested area @alt
+ foreach ($this->xpath->query('./area[count(preceding-sibling::*)+count(following-sibling::*)=0]', $e) as $em) {
+ $emNames = mfNamesFromElement($em, 'h-');
+ if(empty($emNames) && $em->getAttribute('alt') != ''){
throw new Exception($em->getAttribute('alt'));
+ }
}
+
// Look for double nested img @alt
foreach ($this->xpath->query('./*[count(preceding-sibling::*)+count(following-sibling::*)=0]/img[count(preceding-sibling::*)+count(following-sibling::*)=0]', $e) as $em) {
- if ($em->getAttribute('alt') != '')
+ $emNames = mfNamesFromElement($em, 'h-');
+ if(empty($emNames) && $em->getAttribute('alt') != ''){
throw new Exception($em->getAttribute('alt'));
+ }
+ }
+
+ // Look for double nested img @alt
+ foreach ($this->xpath->query('./*[count(preceding-sibling::*)+count(following-sibling::*)=0]/area[count(preceding-sibling::*)+count(following-sibling::*)=0]', $e) as $em) {
+ $emNames = mfNamesFromElement($em, 'h-');
+ if(empty($emNames) && $em->getAttribute('alt') != ''){
+ throw new Exception($em->getAttribute('alt'));
+ }
}
throw new Exception($e->nodeValue);
@@ -812,13 +838,25 @@ public function parseH(\DOMElement $e) {
// Check for u-url
if (!array_key_exists('url', $return)) {
// Look for img @src
- if ($e->tagName == 'a')
+ if ($e->tagName == 'a' or $e->tagName == 'area')
$url = $e->getAttribute('href');
- // Look for nested img @src
+ // Look for nested a @href
foreach ($this->xpath->query('./a[count(preceding-sibling::a)+count(following-sibling::a)=0]', $e) as $em) {
- $url = $em->getAttribute('href');
- break;
+ $emNames = mfNamesFromElement($em, 'h-');
+ if(empty($emNames)){
+ $url = $em->getAttribute('href');
+ break;
+ }
+ }
+
+ // Look for nested area @src
+ foreach ($this->xpath->query('./area[count(preceding-sibling::area)+count(following-sibling::area)=0]', $e) as $em) {
+ $emNames = mfNamesFromElement($em, 'h-');
+ if(empty($emNames)){
+ $url = $em->getAttribute('href');
+ break;
+ }
}
if (!empty($url))
@@ -833,6 +871,12 @@ public function parseH(\DOMElement $e) {
'type' => $mfTypes,
'properties' => $return
);
+ if (!empty($shape)){
+ $parsed['shape'] = $shape;
+ }
+ if (!empty($coords)){
+ $parsed['coords'] = $coords;
+ }
if (!empty($children))
$parsed['children'] = array_values(array_filter($children));
return $parsed;
diff --git a/phpunit.xml b/phpunit.xml
index 07b176f..08a3463 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,8 +1,8 @@
-