Fix implied photo parsing#191
Merged
Merged
Conversation
Zegnat
reviewed
Aug 7, 2018
| './object', | ||
| './*[not(contains(concat(" ", @class), " h-"))]/img[count(preceding-sibling::img)+count(following-sibling::img)=0]', | ||
| './*[not(contains(concat(" ", @class), " h-"))]/object[count(preceding-sibling::object)+count(following-sibling::object)=0]', | ||
| './*[count(preceding-sibling::*)+count(following-sibling::*)=0][not(contains(concat(" ", @class), " h-"))]/img[count(preceding-sibling::img)+count(following-sibling::img)=0]', |
Member
There was a problem hiding this comment.
Can we make this XPath a little easier to read perhaps? I still need to test it, but seems like something as follows should do the same without requiring arithmetic:
./*[not(contains(concat(" ", @class), " h-")) and count(../*) = 1 and count(img) = 1]/img
count(../*)counts the number of child elements of the parent. In other words our*is only matched if it is the only child (= 1).count(img)counts the number of childimgelements within. So*is only matched if it contains only a singleimg(= 1).
This gets rid of all the sibling counting, summations, etc. Could also be adapted for object elements.
Simplified xpath count() using traversal. Added selectors from spec as comments. Moved child h-* check into xpaths. Added check for xpath query() returning false.
Zegnat
requested changes
Aug 7, 2018
|
|
||
| if ($photo !== false) { | ||
| $return['photo'][] = $this->resolveUrl($photo); | ||
| $return['photo'][] = $photo; |
Member
There was a problem hiding this comment.
Without resolving here, the implied values from img.h-x[src] and object.h-x[data] will never get resolved. Why not keep resolveUrl() here?
Member
Author
There was a problem hiding this comment.
I can add resolveUrl to those two. My thinking is parseImpliedPhoto() should return an absolute URL or false.
Zegnat
approved these changes
Aug 7, 2018
Member
|
LGTM 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #190