microformats / tests

Microformats test suite
http://microformats.org/wiki/microformats2
Creative Commons Zero v1.0 Universal
64 stars 20 forks source link

Update JSON output to comply with Parsing Specification Section 1.5 #116

Closed jgarber623 closed 4 years ago

jgarber623 commented 4 years ago

This PR is a follow up from #109 that I uncovered while testing. Adds the appropriate structures to output JSON files when parsing an img element with alt and src attributes.

See Section 1.5 of the microformats2 parsing specification. The changed files reflect the parsing rules for implied photos which reference Section 1.5.

Quote below, emphasis added:

if no explicit "photo" property, and no other explicit u-* properties, and no nested microformats, then imply by: if img.h-x[src], then use the result of "parse an img element for src and alt" (see Sec.1.5) for photo else if object.h-x[data] then use data for photo else if .h-x>img[src]:only-of-type:not[.h-*] then use the result of "parse an img element for src and alt" (see Sec.1.5) for photo else if .h-x>object[data]:only-of-type:not[.h-*] then use that object’s data for photo else if .h-x>:only-child:not[.h-*]>img[src]:only-of-type:not[.h-*], then use the result of "parse an img element for src and alt" (see Sec.1.5) for photo else if .h-x>:only-child:not[.h-*]>object[data]:only-of-type:not[.h-*], then use that object’s data for photo if there is a gotten photo value, return the normalized absolute URL of it, following the containing document's language's rules for resolving relative URLs (e.g. in HTML, use the current URL context as determined by the page, and first <base> element, if any).

jansauer commented 4 years ago

How about h-card/hyperlinkedphoto.json#L6. Everything else looks fine to me.

jgarber623 commented 4 years ago

@jansauer Great catch. Thank you! Pushed an update just now.

jansauer commented 4 years ago

thx; LGTM