@@ -167,7 +167,7 @@ function nestedMfPropertyNamesFromClass($class) {
167167 }
168168 }
169169 }
170-
170+
171171 foreach ($ propertyNames as $ property => $ prefixes ) {
172172 $ propertyNames [$ property ] = array_unique ($ prefixes );
173173 }
@@ -338,8 +338,8 @@ public function __construct($input, $url = null, $jsonMode = false) {
338338 libxml_use_internal_errors (true );
339339 if (is_string ($ input )) {
340340 if (class_exists ('Masterminds \\HTML5 ' )) {
341- $ doc = new \Masterminds \HTML5 (array ('disable_html_ns ' => true ));
342- $ doc = $ doc ->loadHTML ($ input );
341+ $ doc = new \Masterminds \HTML5 (array ('disable_html_ns ' => true ));
342+ $ doc = $ doc ->loadHTML ($ input );
343343 } else {
344344 $ doc = new DOMDocument ();
345345 @$ doc ->loadHTML (unicodeToHtmlEntities ($ input ));
@@ -402,7 +402,7 @@ private function isElementParsed(\DOMElement $e, $prefix) {
402402 if (!$ this ->parsed ->contains ($ e )) {
403403 return false ;
404404 }
405-
405+
406406 $ prefixes = $ this ->parsed [$ e ];
407407
408408 if (!in_array ($ prefix , $ prefixes )) {
@@ -443,49 +443,49 @@ private function resolveChildUrls(DOMElement $el) {
443443 }
444444 }
445445
446- /**
447- * The following two methods implements plain text parsing.
448- * @see https://wiki.zegnat.net/media/textparsing.html
449- **/
446+ /**
447+ * The following two methods implements plain text parsing.
448+ * @see https://wiki.zegnat.net/media/textparsing.html
449+ **/
450450 public function textContent (DOMElement $ element )
451451 {
452- return preg_replace (
453- '/(^[\t\n\f\r ]+| +(?=\n)|(?<=\n) +| +(?= )|[\t\n\f\r ]+$)/ ' ,
454- '' ,
455- $ this ->elementToString ($ element )
456- );
452+ return preg_replace (
453+ '/(^[\t\n\f\r ]+| +(?=\n)|(?<=\n) +| +(?= )|[\t\n\f\r ]+$)/ ' ,
454+ '' ,
455+ $ this ->elementToString ($ element )
456+ );
457457 }
458458 private function elementToString (DOMElement $ input )
459459 {
460- $ output = '' ;
461- foreach ($ input ->childNodes as $ child ) {
462- if ($ child ->nodeType === XML_TEXT_NODE ) {
463- $ output .= str_replace (array ("\t" , "\n" , "\r" ) , ' ' , $ child ->textContent );
464- } else if ($ child ->nodeType === XML_ELEMENT_NODE ) {
465- $ tagName = strtoupper ($ child ->tagName );
466- if (in_array ($ tagName , array ('SCRIPT ' , 'STYLE ' ))) {
467- continue ;
468- } else if ($ tagName === 'IMG ' ) {
469- if ($ child ->hasAttribute ('alt ' )) {
470- $ output .= ' ' . trim ($ child ->getAttribute ('alt ' ), "\t\n\f\r " ) . ' ' ;
471- } else if ($ child ->hasAttribute ('src ' )) {
472- $ output .= ' ' . $ this ->resolveUrl (trim ($ child ->getAttribute ('src ' ), "\t\n\f\r " )) . ' ' ;
473- }
474- } else if ($ tagName === 'BR ' ) {
475- $ output .= "\n" ;
476- } else if ($ tagName === 'P ' ) {
477- $ output .= "\n" . $ this ->elementToString ($ child );
478- } else {
479- $ output .= $ this ->elementToString ($ child );
480- }
481- }
482- }
483- return $ output ;
460+ $ output = '' ;
461+ foreach ($ input ->childNodes as $ child ) {
462+ if ($ child ->nodeType === XML_TEXT_NODE ) {
463+ $ output .= str_replace (array ("\t" , "\n" , "\r" ) , ' ' , $ child ->textContent );
464+ } else if ($ child ->nodeType === XML_ELEMENT_NODE ) {
465+ $ tagName = strtoupper ($ child ->tagName );
466+ if (in_array ($ tagName , array ('SCRIPT ' , 'STYLE ' ))) {
467+ continue ;
468+ } else if ($ tagName === 'IMG ' ) {
469+ if ($ child ->hasAttribute ('alt ' )) {
470+ $ output .= ' ' . trim ($ child ->getAttribute ('alt ' ), "\t\n\f\r " ) . ' ' ;
471+ } else if ($ child ->hasAttribute ('src ' )) {
472+ $ output .= ' ' . $ this ->resolveUrl (trim ($ child ->getAttribute ('src ' ), "\t\n\f\r " )) . ' ' ;
473+ }
474+ } else if ($ tagName === 'BR ' ) {
475+ $ output .= "\n" ;
476+ } else if ($ tagName === 'P ' ) {
477+ $ output .= "\n" . $ this ->elementToString ($ child );
478+ } else {
479+ $ output .= $ this ->elementToString ($ child );
480+ }
481+ }
482+ }
483+ return $ output ;
484484 }
485485
486486 /**
487487 * This method parses the language of an element
488- * @param DOMElement $el
488+ * @param DOMElement $el
489489 * @access public
490490 * @return string
491491 */
@@ -495,7 +495,7 @@ public function language(DOMElement $el)
495495 if ($ el ->hasAttribute ('lang ' )) {
496496 return unicodeTrim ($ el ->getAttribute ('lang ' ));
497497 }
498-
498+
499499 if ($ el ->tagName == 'html ' ) {
500500 // we're at the <html> element and no lang; check <meta> http-equiv Content-Language
501501 foreach ( $ this ->xpath ->query ('.//meta[@http-equiv] ' ) as $ node )
@@ -506,7 +506,7 @@ public function language(DOMElement $el)
506506 }
507507 } elseif ($ el ->parentNode instanceof DOMElement) {
508508 // check the parent node
509- return $ this ->language ($ el ->parentNode );
509+ return $ this ->language ($ el ->parentNode );
510510 }
511511
512512 return '' ;
@@ -619,15 +619,15 @@ public function parseU(\DOMElement $u) {
619619 } elseif ($ u ->tagName == 'object ' and $ u ->hasAttribute ('data ' )) {
620620 $ uValue = $ u ->getAttribute ('data ' );
621621 } elseif (($ classTitle = $ this ->parseValueClassTitle ($ u )) !== null ) {
622- $ uValue = $ classTitle ;
622+ $ uValue = $ classTitle ;
623623 } elseif (($ u ->tagName == 'abbr ' or $ u ->tagName == 'link ' ) and $ u ->hasAttribute ('title ' )) {
624624 $ uValue = $ u ->getAttribute ('title ' );
625625 } elseif (in_array ($ u ->tagName , array ('data ' , 'input ' )) and $ u ->hasAttribute ('value ' )) {
626626 $ uValue = $ u ->getAttribute ('value ' );
627627 } else {
628628 $ uValue = $ this ->textContent ($ u );
629629 }
630- return $ this ->resolveUrl ($ uValue );
630+ return $ this ->resolveUrl ($ uValue );
631631 }
632632
633633 /**
@@ -802,7 +802,7 @@ public function parseDT(\DOMElement $dt, &$dates = array(), &$impliedTimezone =
802802
803803 $ dtValue = unicodeTrim ($ dtValue );
804804
805- // Store the date part so that we can use it when assembling the final timestamp if the next one is missing a date part
805+ // Store the date part so that we can use it when assembling the final timestamp if the next one is missing a date part
806806 if (preg_match ('/(\d{4}-\d{2}-\d{2})/ ' , $ dtValue , $ matches )) {
807807 $ dates [] = $ matches [0 ];
808808 }
@@ -913,7 +913,7 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
913913
914914 // Handle p-*
915915 foreach ($ this ->xpath ->query ('.//*[contains(concat(" ", @class) ," p-")] ' , $ e ) as $ p ) {
916- // element is already parsed
916+ // element is already parsed
917917 if ($ this ->isElementParsed ($ p , 'p ' )) {
918918 continue ;
919919 // backcompat parsing and element was not upgraded; skip it
@@ -1117,7 +1117,7 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
11171117 // Make sure things are unique and in alphabetical order
11181118 $ mfTypes = array_unique ($ mfTypes );
11191119 sort ($ mfTypes );
1120-
1120+
11211121 // Properties should be an object when JSON serialised
11221122 if (empty ($ return ) and $ this ->jsonMode ) {
11231123 $ return = new stdClass ();
@@ -1299,7 +1299,7 @@ public function parseRelsAndAlternates() {
12991299
13001300 /**
13011301 * Find rel=tag elements that don't have class=category and have an href.
1302- * For each element, get the last non-empty URL segment. Append a <data>
1302+ * For each element, get the last non-empty URL segment. Append a <data>
13031303 * element with that value as the category. Uses the mf1 class 'category'
13041304 * which will then be upgraded to p-category during backcompat.
13051305 * @param DOMElement $el
@@ -2105,8 +2105,8 @@ function resolveUrl($baseURI, $referenceURI) {
21052105
21062106 # 5.2.1 Pre-parse the Base URI
21072107 # The base URI (Base) is established according to the procedure of
2108- # Section 5.1 and parsed into the five main components described in
2109- # Section 3
2108+ # Section 5.1 and parsed into the five main components described in
2109+ # Section 3
21102110 $ base = parseUriToComponents ($ baseURI );
21112111
21122112 # If base path is blank (http://example.com) then set it to /
0 commit comments