microformats 4.0.6 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.editorconfig +10 -0
- data/.gitignore +33 -15
- data/.rspec +3 -2
- data/.rubocop +3 -0
- data/.rubocop.yml +22 -0
- data/.ruby-version +1 -0
- data/.simplecov +11 -0
- data/.travis.yml +16 -2
- data/CONTRIBUTING.md +103 -0
- data/Guardfile +2 -2
- data/LICENSE +116 -0
- data/README.md +112 -172
- data/Rakefile +6 -7
- data/bin/microformats +10 -9
- data/lib/microformats.rb +15 -14
- data/lib/microformats/absolute_uri.rb +4 -8
- data/lib/microformats/format_parser.rb +271 -251
- data/lib/microformats/parser.rb +39 -39
- data/lib/microformats/parser_core.rb +142 -109
- data/lib/microformats/property_parser.rb +42 -65
- data/lib/microformats/results/collection.rb +19 -38
- data/lib/microformats/results/parser_result.rb +25 -37
- data/lib/microformats/results/property_set.rb +24 -31
- data/lib/microformats/time_property_parser.rb +130 -104
- data/lib/microformats/version.rb +1 -1
- data/logo.svg +23 -0
- data/microformats.gemspec +35 -33
- metadata +122 -445
- data/LICENSE.md +0 -36
- data/spec/lib/microformats/absolute_uri_spec.rb +0 -56
- data/spec/lib/microformats/parser_spec.rb +0 -132
- data/spec/lib/microformats_spec.rb +0 -33
- data/spec/spec_helper.rb +0 -10
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-0.html +0 -2
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-0.js +0 -9
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-1.html +0 -2
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-1.js +0 -10
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-2.html +0 -5
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-2.js +0 -11
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-3.html +0 -17
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-3.js +0 -20
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-4.html +0 -16
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-4.js +0 -24
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-5.html +0 -7
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-5.js +0 -11
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-6.html +0 -9
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-6.js +0 -18
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-7.html +0 -9
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-7.js +0 -18
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-8.html +0 -9
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-8.js +0 -17
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-9.html +0 -9
- data/spec/support/cases/microformats.org/microformats-2/microformats-2-9.js +0 -17
- data/spec/support/lib/edge_cases/blank_href.html +0 -23
- data/spec/support/lib/edge_cases/blank_href.js +0 -15
- data/spec/support/lib/edge_cases/blank_rel.html +0 -23
- data/spec/support/lib/edge_cases/blank_rel.js +0 -41
- data/spec/support/lib/edge_cases/blank_src.html +0 -24
- data/spec/support/lib/edge_cases/blank_src.js +0 -16
- data/spec/support/lib/edge_cases/blank_value.html +0 -5
- data/spec/support/lib/edge_cases/blank_value.js +0 -19
- data/spec/support/lib/edge_cases/relative.html +0 -29
- data/spec/support/lib/edge_cases/relative.js +0 -15
- data/spec/support/lib/microformats/blank_href.html +0 -23
- data/spec/support/lib/microformats/blank_href.js +0 -11
- data/spec/support/lib/microformats/implied_property/name-fail.html +0 -60
- data/spec/support/lib/microformats/implied_property/name-pass.html +0 -30
- data/spec/support/lib/microformats/implied_property/photo-fail.html +0 -60
- data/spec/support/lib/microformats/implied_property/photo-pass.html +0 -30
- data/spec/support/lib/microformats/implied_property/url-fail.html +0 -18
- data/spec/support/lib/microformats/implied_property/url-pass.html +0 -12
- data/spec/support/lib/microformats/implied_property/url-relative.html +0 -13
- data/spec/support/lib/microformats/implied_property/url-unnormalized.html +0 -12
- data/spec/support/lib/microformats/nested-format-with-property-of-same-name.html +0 -13
- data/spec/support/lib/microformats/nested-format-with-property-of-same-name.js +0 -16
- data/spec/support/lib/microformats/nested-format-with-property.html +0 -12
- data/spec/support/lib/microformats/nested-format-with-property.js +0 -16
- data/spec/support/lib/microformats/nested-format-without-property.html +0 -13
- data/spec/support/lib/microformats/nested-property.html +0 -12
- data/spec/support/lib/microformats/nested-property.js +0 -10
- data/spec/support/lib/microformats/rels-that-drop-the-base.html +0 -11
- data/spec/support/lib/microformats/rels-with-unnormalized-urls.html +0 -11
- data/spec/support/lib/microformats/rels.html +0 -12
- data/spec/support/lib/microformats/rels.js +0 -13
- data/spec/support/lib/microformats/simple.html +0 -23
- data/spec/support/lib/microformats/simple.js +0 -11
- data/vendor/tests/.gitignore +0 -25
- data/vendor/tests/LICENSE.md +0 -36
- data/vendor/tests/README.md +0 -48
- data/vendor/tests/app.js +0 -84
- data/vendor/tests/composer.json +0 -5
- data/vendor/tests/css/testsuite.css +0 -159
- data/vendor/tests/interface.js +0 -18
- data/vendor/tests/package.json +0 -27
- data/vendor/tests/tests/microformats-mixed/h-card/change-log.html +0 -63
- data/vendor/tests/tests/microformats-mixed/h-card/mixedpropertries.html +0 -14
- data/vendor/tests/tests/microformats-mixed/h-card/mixedpropertries.json +0 -22
- data/vendor/tests/tests/microformats-mixed/h-card/tworoots.html +0 -1
- data/vendor/tests/tests/microformats-mixed/h-card/tworoots.json +0 -10
- data/vendor/tests/tests/microformats-mixed/h-entry/mixedroots.html +0 -16
- data/vendor/tests/tests/microformats-mixed/h-entry/mixedroots.json +0 -38
- data/vendor/tests/tests/microformats-mixed/h-resume/change-log.html +0 -68
- data/vendor/tests/tests/microformats-mixed/h-resume/mixedroots.html +0 -16
- data/vendor/tests/tests/microformats-mixed/h-resume/mixedroots.json +0 -31
- data/vendor/tests/tests/microformats-v1/adr/change-log.html +0 -63
- data/vendor/tests/tests/microformats-v1/adr/simpleproperties.html +0 -8
- data/vendor/tests/tests/microformats-v1/adr/simpleproperties.json +0 -15
- data/vendor/tests/tests/microformats-v1/geo/abbrpattern.html +0 -5
- data/vendor/tests/tests/microformats-v1/geo/abbrpattern.json +0 -11
- data/vendor/tests/tests/microformats-v1/geo/change-log.1.html +0 -78
- data/vendor/tests/tests/microformats-v1/geo/change-log.html +0 -63
- data/vendor/tests/tests/microformats-v1/geo/hidden.html +0 -10
- data/vendor/tests/tests/microformats-v1/geo/hidden.json +0 -11
- data/vendor/tests/tests/microformats-v1/geo/simpleproperties.html +0 -6
- data/vendor/tests/tests/microformats-v1/geo/simpleproperties.json +0 -11
- data/vendor/tests/tests/microformats-v1/geo/valuetitleclass.html +0 -11
- data/vendor/tests/tests/microformats-v1/geo/valuetitleclass.json +0 -11
- data/vendor/tests/tests/microformats-v1/hcalendar/ampm.html +0 -41
- data/vendor/tests/tests/microformats-v1/hcalendar/ampm.json +0 -21
- data/vendor/tests/tests/microformats-v1/hcalendar/attendees.html +0 -13
- data/vendor/tests/tests/microformats-v1/hcalendar/attendees.json +0 -37
- data/vendor/tests/tests/microformats-v1/hcalendar/change-log.html +0 -68
- data/vendor/tests/tests/microformats-v1/hcalendar/combining.html +0 -15
- data/vendor/tests/tests/microformats-v1/hcalendar/combining.json +0 -31
- data/vendor/tests/tests/microformats-v1/hcalendar/concatenate.html +0 -7
- data/vendor/tests/tests/microformats-v1/hcalendar/concatenate.json +0 -12
- data/vendor/tests/tests/microformats-v1/hcalendar/time.html +0 -44
- data/vendor/tests/tests/microformats-v1/hcalendar/time.json +0 -22
- data/vendor/tests/tests/microformats-v1/hcard/change-log.html +0 -68
- data/vendor/tests/tests/microformats-v1/hcard/email.html +0 -14
- data/vendor/tests/tests/microformats-v1/hcard/email.json +0 -11
- data/vendor/tests/tests/microformats-v1/hcard/format.html +0 -6
- data/vendor/tests/tests/microformats-v1/hcard/format.json +0 -11
- data/vendor/tests/tests/microformats-v1/hcard/hyperlinkedphoto.html +0 -3
- data/vendor/tests/tests/microformats-v1/hcard/hyperlinkedphoto.json +0 -8
- data/vendor/tests/tests/microformats-v1/hcard/justahyperlink.html +0 -1
- data/vendor/tests/tests/microformats-v1/hcard/justahyperlink.json +0 -8
- data/vendor/tests/tests/microformats-v1/hcard/justaname.html +0 -1
- data/vendor/tests/tests/microformats-v1/hcard/justaname.json +0 -8
- data/vendor/tests/tests/microformats-v1/hcard/multiple.html +0 -74
- data/vendor/tests/tests/microformats-v1/hcard/multiple.json +0 -65
- data/vendor/tests/tests/microformats-v1/hcard/name.html +0 -11
- data/vendor/tests/tests/microformats-v1/hcard/name.json +0 -15
- data/vendor/tests/tests/microformats-v1/hcard/single.html +0 -14
- data/vendor/tests/tests/microformats-v1/hcard/single.json +0 -24
- data/vendor/tests/tests/microformats-v1/hentry/change-log.html +0 -73
- data/vendor/tests/tests/microformats-v1/hentry/summarycontent.html +0 -20
- data/vendor/tests/tests/microformats-v1/hentry/summarycontent.json +0 -24
- data/vendor/tests/tests/microformats-v1/hfeed/simple.html +0 -30
- data/vendor/tests/tests/microformats-v1/hfeed/simple.json +0 -49
- data/vendor/tests/tests/microformats-v1/hnews/all.html +0 -37
- data/vendor/tests/tests/microformats-v1/hnews/all.json +0 -74
- data/vendor/tests/tests/microformats-v1/hnews/change-log.html +0 -72
- data/vendor/tests/tests/microformats-v1/hnews/minimum.html +0 -25
- data/vendor/tests/tests/microformats-v1/hnews/minimum.json +0 -48
- data/vendor/tests/tests/microformats-v1/hproduct/aggregate.html +0 -26
- data/vendor/tests/tests/microformats-v1/hproduct/aggregate.json +0 -52
- data/vendor/tests/tests/microformats-v1/hproduct/change-log.html +0 -62
- data/vendor/tests/tests/microformats-v1/hproduct/simpleproperties.html +0 -13
- data/vendor/tests/tests/microformats-v1/hproduct/simpleproperties.json +0 -33
- data/vendor/tests/tests/microformats-v1/hresume/affiliation.html +0 -12
- data/vendor/tests/tests/microformats-v1/hresume/affiliation.json +0 -25
- data/vendor/tests/tests/microformats-v1/hresume/change-log.html +0 -73
- data/vendor/tests/tests/microformats-v1/hresume/contact.html +0 -18
- data/vendor/tests/tests/microformats-v1/hresume/contact.json +0 -32
- data/vendor/tests/tests/microformats-v1/hresume/education.html +0 -13
- data/vendor/tests/tests/microformats-v1/hresume/education.json +0 -29
- data/vendor/tests/tests/microformats-v1/hresume/skill.html +0 -12
- data/vendor/tests/tests/microformats-v1/hresume/skill.json +0 -33
- data/vendor/tests/tests/microformats-v1/hresume/work.html +0 -16
- data/vendor/tests/tests/microformats-v1/hresume/work.json +0 -30
- data/vendor/tests/tests/microformats-v1/hreview-aggregate/change-log.html +0 -67
- data/vendor/tests/tests/microformats-v1/hreview-aggregate/hcard.html +0 -18
- data/vendor/tests/tests/microformats-v1/hreview-aggregate/hcard.json +0 -31
- data/vendor/tests/tests/microformats-v1/hreview-aggregate/justahyperlink.html +0 -6
- data/vendor/tests/tests/microformats-v1/hreview-aggregate/justahyperlink.json +0 -19
- data/vendor/tests/tests/microformats-v1/hreview-aggregate/vevent.html +0 -13
- data/vendor/tests/tests/microformats-v1/hreview-aggregate/vevent.json +0 -22
- data/vendor/tests/tests/microformats-v1/hreview/change-log.html +0 -73
- data/vendor/tests/tests/microformats-v1/hreview/item.html +0 -8
- data/vendor/tests/tests/microformats-v1/hreview/item.json +0 -19
- data/vendor/tests/tests/microformats-v1/hreview/vcard.html +0 -23
- data/vendor/tests/tests/microformats-v1/hreview/vcard.json +0 -58
- data/vendor/tests/tests/microformats-v1/includes/change-log.html +0 -72
- data/vendor/tests/tests/microformats-v1/includes/hcarditemref.html +0 -16
- data/vendor/tests/tests/microformats-v1/includes/hcarditemref.json +0 -49
- data/vendor/tests/tests/microformats-v1/includes/heventitemref.html +0 -25
- data/vendor/tests/tests/microformats-v1/includes/heventitemref.json +0 -33
- data/vendor/tests/tests/microformats-v1/includes/hyperlink.html +0 -18
- data/vendor/tests/tests/microformats-v1/includes/hyperlink.json +0 -43
- data/vendor/tests/tests/microformats-v1/includes/object.html +0 -23
- data/vendor/tests/tests/microformats-v1/includes/object.json +0 -42
- data/vendor/tests/tests/microformats-v1/includes/table.html +0 -12
- data/vendor/tests/tests/microformats-v1/includes/table.json +0 -19
- data/vendor/tests/tests/microformats-v2/h-adr/change-log.html +0 -62
- data/vendor/tests/tests/microformats-v2/h-adr/geo.html +0 -10
- data/vendor/tests/tests/microformats-v2/h-adr/geo.json +0 -16
- data/vendor/tests/tests/microformats-v2/h-adr/geourl.html +0 -4
- data/vendor/tests/tests/microformats-v2/h-adr/geourl.json +0 -13
- data/vendor/tests/tests/microformats-v2/h-adr/justaname.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-adr/justaname.json +0 -10
- data/vendor/tests/tests/microformats-v2/h-adr/lettercase.html +0 -21
- data/vendor/tests/tests/microformats-v2/h-adr/lettercase.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-adr/simpleproperties.html +0 -8
- data/vendor/tests/tests/microformats-v2/h-adr/simpleproperties.json +0 -16
- data/vendor/tests/tests/microformats-v2/h-as-note/note.html +0 -56
- data/vendor/tests/tests/microformats-v2/h-as-note/note.json +0 -98
- data/vendor/tests/tests/microformats-v2/h-card/baseurl.html +0 -6
- data/vendor/tests/tests/microformats-v2/h-card/baseurl.json +0 -26
- data/vendor/tests/tests/microformats-v2/h-card/change-log.html +0 -100
- data/vendor/tests/tests/microformats-v2/h-card/childimplied.html +0 -7
- data/vendor/tests/tests/microformats-v2/h-card/childimplied.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-card/extendeddescription.html +0 -10
- data/vendor/tests/tests/microformats-v2/h-card/extendeddescription.json +0 -15
- data/vendor/tests/tests/microformats-v2/h-card/hcard.html +0 -4
- data/vendor/tests/tests/microformats-v2/h-card/hcard.json +0 -19
- data/vendor/tests/tests/microformats-v2/h-card/horghcard.html +0 -4
- data/vendor/tests/tests/microformats-v2/h-card/horghcard.json +0 -19
- data/vendor/tests/tests/microformats-v2/h-card/hyperlinkedphoto.html +0 -3
- data/vendor/tests/tests/microformats-v2/h-card/hyperlinkedphoto.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-card/impliedname.html +0 -15
- data/vendor/tests/tests/microformats-v2/h-card/impliedname.json +0 -90
- data/vendor/tests/tests/microformats-v2/h-card/impliedphoto.html +0 -11
- data/vendor/tests/tests/microformats-v2/h-card/impliedphoto.json +0 -72
- data/vendor/tests/tests/microformats-v2/h-card/impliedurl.html +0 -5
- data/vendor/tests/tests/microformats-v2/h-card/impliedurl.json +0 -45
- data/vendor/tests/tests/microformats-v2/h-card/justahyperlink.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-card/justahyperlink.json +0 -11
- data/vendor/tests/tests/microformats-v2/h-card/justaname.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-card/justaname.json +0 -10
- data/vendor/tests/tests/microformats-v2/h-card/nested.html +0 -4
- data/vendor/tests/tests/microformats-v2/h-card/nested.json +0 -18
- data/vendor/tests/tests/microformats-v2/h-card/p-property.html +0 -21
- data/vendor/tests/tests/microformats-v2/h-card/p-property.json +0 -15
- data/vendor/tests/tests/microformats-v2/h-card/relativeurls.html +0 -6
- data/vendor/tests/tests/microformats-v2/h-card/relativeurls.json +0 -29
- data/vendor/tests/tests/microformats-v2/h-entry/change-log.html +0 -90
- data/vendor/tests/tests/microformats-v2/h-entry/encoding.html +0 -3
- data/vendor/tests/tests/microformats-v2/h-entry/encoding.json +0 -14
- data/vendor/tests/tests/microformats-v2/h-entry/impliedvalue-nested.html +0 -9
- data/vendor/tests/tests/microformats-v2/h-entry/impliedvalue-nested.json +0 -27
- data/vendor/tests/tests/microformats-v2/h-entry/justahyperlink.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-entry/justahyperlink.json +0 -11
- data/vendor/tests/tests/microformats-v2/h-entry/justaname.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-entry/justaname.json +0 -10
- data/vendor/tests/tests/microformats-v2/h-entry/scriptstyletags.html +0 -4
- data/vendor/tests/tests/microformats-v2/h-entry/scriptstyletags.json +0 -14
- data/vendor/tests/tests/microformats-v2/h-entry/summarycontent.html +0 -20
- data/vendor/tests/tests/microformats-v2/h-entry/summarycontent.json +0 -25
- data/vendor/tests/tests/microformats-v2/h-entry/u-property.html +0 -33
- data/vendor/tests/tests/microformats-v2/h-entry/u-property.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-entry/urlincontent.html +0 -13
- data/vendor/tests/tests/microformats-v2/h-entry/urlincontent.json +0 -14
- data/vendor/tests/tests/microformats-v2/h-event/ampm.html +0 -41
- data/vendor/tests/tests/microformats-v2/h-event/ampm.json +0 -21
- data/vendor/tests/tests/microformats-v2/h-event/attendees.html +0 -13
- data/vendor/tests/tests/microformats-v2/h-event/attendees.json +0 -37
- data/vendor/tests/tests/microformats-v2/h-event/change-log.html +0 -82
- data/vendor/tests/tests/microformats-v2/h-event/combining.html +0 -13
- data/vendor/tests/tests/microformats-v2/h-event/combining.json +0 -25
- data/vendor/tests/tests/microformats-v2/h-event/concatenate.html +0 -8
- data/vendor/tests/tests/microformats-v2/h-event/concatenate.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-event/dates.html +0 -13
- data/vendor/tests/tests/microformats-v2/h-event/dates.json +0 -26
- data/vendor/tests/tests/microformats-v2/h-event/dt-property.html +0 -23
- data/vendor/tests/tests/microformats-v2/h-event/dt-property.json +0 -20
- data/vendor/tests/tests/microformats-v2/h-event/justahyperlink.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-event/justahyperlink.json +0 -11
- data/vendor/tests/tests/microformats-v2/h-event/justaname.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-event/justaname.json +0 -10
- data/vendor/tests/tests/microformats-v2/h-event/time.html +0 -47
- data/vendor/tests/tests/microformats-v2/h-event/time.json +0 -25
- data/vendor/tests/tests/microformats-v2/h-feed/implied-title.html +0 -30
- data/vendor/tests/tests/microformats-v2/h-feed/implied-title.json +0 -23
- data/vendor/tests/tests/microformats-v2/h-feed/simple.html +0 -26
- data/vendor/tests/tests/microformats-v2/h-feed/simple.json +0 -33
- data/vendor/tests/tests/microformats-v2/h-geo/abbrpattern.html +0 -5
- data/vendor/tests/tests/microformats-v2/h-geo/abbrpattern.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-geo/altitude.html +0 -8
- data/vendor/tests/tests/microformats-v2/h-geo/altitude.json +0 -13
- data/vendor/tests/tests/microformats-v2/h-geo/change-log.html +0 -67
- data/vendor/tests/tests/microformats-v2/h-geo/hidden.html +0 -10
- data/vendor/tests/tests/microformats-v2/h-geo/hidden.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-geo/justaname.html +0 -3
- data/vendor/tests/tests/microformats-v2/h-geo/justaname.json +0 -10
- data/vendor/tests/tests/microformats-v2/h-geo/simpleproperties.html +0 -5
- data/vendor/tests/tests/microformats-v2/h-geo/simpleproperties.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-geo/valuetitleclass.html +0 -11
- data/vendor/tests/tests/microformats-v2/h-geo/valuetitleclass.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-news/all.html +0 -35
- data/vendor/tests/tests/microformats-v2/h-news/all.json +0 -51
- data/vendor/tests/tests/microformats-v2/h-news/change-log.html +0 -78
- data/vendor/tests/tests/microformats-v2/h-news/minimum.html +0 -24
- data/vendor/tests/tests/microformats-v2/h-news/minimum.json +0 -40
- data/vendor/tests/tests/microformats-v2/h-org/change-log.html +0 -57
- data/vendor/tests/tests/microformats-v2/h-org/hyperlink.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-org/hyperlink.json +0 -11
- data/vendor/tests/tests/microformats-v2/h-org/simple.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-org/simple.json +0 -10
- data/vendor/tests/tests/microformats-v2/h-org/simpleproperties.html +0 -4
- data/vendor/tests/tests/microformats-v2/h-org/simpleproperties.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-product/aggregate.html +0 -21
- data/vendor/tests/tests/microformats-v2/h-product/aggregate.json +0 -45
- data/vendor/tests/tests/microformats-v2/h-product/change-log.html +0 -62
- data/vendor/tests/tests/microformats-v2/h-product/justahyperlink.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-product/justahyperlink.json +0 -11
- data/vendor/tests/tests/microformats-v2/h-product/justaname.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-product/justaname.json +0 -10
- data/vendor/tests/tests/microformats-v2/h-product/simpleproperties.html +0 -10
- data/vendor/tests/tests/microformats-v2/h-product/simpleproperties.json +0 -26
- data/vendor/tests/tests/microformats-v2/h-recipe/all.html +0 -63
- data/vendor/tests/tests/microformats-v2/h-recipe/all.json +0 -54
- data/vendor/tests/tests/microformats-v2/h-recipe/change-log.html +0 -62
- data/vendor/tests/tests/microformats-v2/h-recipe/minimum.html +0 -7
- data/vendor/tests/tests/microformats-v2/h-recipe/minimum.json +0 -17
- data/vendor/tests/tests/microformats-v2/h-resume/affiliation.html +0 -12
- data/vendor/tests/tests/microformats-v2/h-resume/affiliation.json +0 -20
- data/vendor/tests/tests/microformats-v2/h-resume/change-log.html +0 -78
- data/vendor/tests/tests/microformats-v2/h-resume/contact.html +0 -17
- data/vendor/tests/tests/microformats-v2/h-resume/contact.json +0 -26
- data/vendor/tests/tests/microformats-v2/h-resume/education.html +0 -13
- data/vendor/tests/tests/microformats-v2/h-resume/education.json +0 -30
- data/vendor/tests/tests/microformats-v2/h-resume/justaname.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-resume/justaname.json +0 -10
- data/vendor/tests/tests/microformats-v2/h-resume/skill.html +0 -12
- data/vendor/tests/tests/microformats-v2/h-resume/skill.json +0 -12
- data/vendor/tests/tests/microformats-v2/h-resume/work.html +0 -16
- data/vendor/tests/tests/microformats-v2/h-resume/work.json +0 -31
- data/vendor/tests/tests/microformats-v2/h-review-aggregate/change-log.html +0 -78
- data/vendor/tests/tests/microformats-v2/h-review-aggregate/hevent.html +0 -13
- data/vendor/tests/tests/microformats-v2/h-review-aggregate/hevent.json +0 -23
- data/vendor/tests/tests/microformats-v2/h-review-aggregate/justahyperlink.html +0 -8
- data/vendor/tests/tests/microformats-v2/h-review-aggregate/justahyperlink.json +0 -19
- data/vendor/tests/tests/microformats-v2/h-review-aggregate/simpleproperties.html +0 -18
- data/vendor/tests/tests/microformats-v2/h-review-aggregate/simpleproperties.json +0 -26
- data/vendor/tests/tests/microformats-v2/h-review/change-log.html +0 -84
- data/vendor/tests/tests/microformats-v2/h-review/hyperlink.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-review/hyperlink.json +0 -11
- data/vendor/tests/tests/microformats-v2/h-review/implieditem.html +0 -4
- data/vendor/tests/tests/microformats-v2/h-review/implieditem.json +0 -19
- data/vendor/tests/tests/microformats-v2/h-review/item.html +0 -8
- data/vendor/tests/tests/microformats-v2/h-review/item.json +0 -20
- data/vendor/tests/tests/microformats-v2/h-review/justaname.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-review/justaname.json +0 -10
- data/vendor/tests/tests/microformats-v2/h-review/photo.html +0 -1
- data/vendor/tests/tests/microformats-v2/h-review/photo.json +0 -11
- data/vendor/tests/tests/microformats-v2/h-review/vcard.html +0 -23
- data/vendor/tests/tests/microformats-v2/h-review/vcard.json +0 -48
- data/vendor/tests/tests/microformats-v2/rel/change-log.html +0 -67
- data/vendor/tests/tests/microformats-v2/rel/duplicate-rels.html +0 -10
- data/vendor/tests/tests/microformats-v2/rel/duplicate-rels.json +0 -75
- data/vendor/tests/tests/microformats-v2/rel/license.html +0 -1
- data/vendor/tests/tests/microformats-v2/rel/license.json +0 -12
- data/vendor/tests/tests/microformats-v2/rel/nofollow.html +0 -1
- data/vendor/tests/tests/microformats-v2/rel/nofollow.json +0 -12
- data/vendor/tests/tests/microformats-v2/rel/rel-urls.html +0 -8
- data/vendor/tests/tests/microformats-v2/rel/rel-urls.json +0 -33
- data/vendor/tests/tests/microformats-v2/rel/varying-text-duplicate-rels.html +0 -4
- data/vendor/tests/tests/microformats-v2/rel/varying-text-duplicate-rels.json +0 -20
- data/vendor/tests/tests/microformats-v2/rel/xfn-all.html +0 -19
- data/vendor/tests/tests/microformats-v2/rel/xfn-all.json +0 -92
- data/vendor/tests/tests/microformats-v2/rel/xfn-elsewhere.html +0 -10
- data/vendor/tests/tests/microformats-v2/rel/xfn-elsewhere.json +0 -40
data/lib/microformats/parser.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
module Microformats
|
2
|
-
|
3
2
|
class Parser < ParserCore
|
4
3
|
attr_reader :http_headers, :http_body
|
4
|
+
|
5
5
|
def initialize
|
6
6
|
@http_headers = {}
|
7
7
|
super
|
8
8
|
end
|
9
9
|
|
10
|
-
def parse(html, base: nil, headers:{})
|
11
|
-
|
10
|
+
def parse(html, base: nil, headers: {})
|
12
11
|
@http_headers = {}
|
13
12
|
|
14
13
|
@items = []
|
@@ -26,49 +25,51 @@ module Microformats
|
|
26
25
|
@base = found_base unless found_base.nil?
|
27
26
|
|
28
27
|
document.traverse do |node|
|
29
|
-
if
|
28
|
+
if !node.attribute('src').nil?
|
30
29
|
absolute_url = Microformats::AbsoluteUri.new(node.attribute('src').value.to_s, base: @base).absolutize
|
31
30
|
node.attribute('src').value = absolute_url.to_s
|
32
|
-
|
33
|
-
elsif not node.attribute('href').nil?
|
31
|
+
elsif !node.attribute('href').nil?
|
34
32
|
absolute_url = Microformats::AbsoluteUri.new(node.attribute('href').value.to_s, base: @base).absolutize
|
35
33
|
node.attribute('href').value = absolute_url.to_s
|
36
34
|
end
|
37
35
|
end
|
36
|
+
|
38
37
|
parse_node(document)
|
39
38
|
parse_rels(document)
|
40
39
|
|
41
|
-
Collection.new(
|
40
|
+
Collection.new('items' => @items, 'rels' => @rels, 'rel-urls' => @rel_urls)
|
42
41
|
end
|
43
42
|
|
44
|
-
def read_html(html, headers:{})
|
43
|
+
def read_html(html, headers: {})
|
45
44
|
stripped_html = html.strip
|
46
|
-
|
45
|
+
|
46
|
+
(URI.respond_to?(:open) ? URI : Kernel).open(stripped_html, **headers) do |response|
|
47
47
|
@http_headers = response.meta if response.respond_to?(:meta)
|
48
48
|
@http_body = response.read
|
49
49
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
|
51
|
+
@base = stripped_html if @base.nil?
|
52
|
+
|
53
53
|
@http_body
|
54
|
-
rescue Errno::ENOENT, Errno::ENAMETOOLONG
|
54
|
+
rescue Errno::ENOENT, Errno::ENAMETOOLONG
|
55
55
|
@http_body = html
|
56
56
|
end
|
57
57
|
|
58
58
|
private
|
59
59
|
|
60
60
|
def parse_element(element)
|
61
|
-
|
62
61
|
fmt_classes = format_classes(element)
|
62
|
+
|
63
63
|
bc_fmt_classes = backcompat_format_classes(element).reject do |format_class|
|
64
|
-
fmt_classes.include?
|
64
|
+
fmt_classes.include?(format_class)
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
|
+
joined_classes = fmt_classes + bc_fmt_classes
|
67
68
|
|
68
69
|
if bc_fmt_classes.length >= 1
|
69
70
|
@items << FormatParser.new.parse(element, base: @base, format_class_array: joined_classes, backcompat: true)
|
70
71
|
elsif fmt_classes.length >= 1
|
71
|
-
@items << FormatParser.new.parse(element, base: @base, format_class_array: fmt_classes
|
72
|
+
@items << FormatParser.new.parse(element, base: @base, format_class_array: fmt_classes)
|
72
73
|
else
|
73
74
|
parse_nodeset(element.children)
|
74
75
|
end
|
@@ -76,36 +77,35 @@ module Microformats
|
|
76
77
|
|
77
78
|
def parse_base(document)
|
78
79
|
base = document.search('base').first
|
80
|
+
|
79
81
|
base.values.first unless base.nil?
|
80
82
|
end
|
81
83
|
|
82
84
|
def parse_rels(element)
|
83
85
|
element.search('*[@rel]').each do |rel|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
@rels[rel_value] = [] unless @rels.has_key?(rel_value)
|
90
|
-
@rels[rel_value] << Microformats::AbsoluteUri.new(rel.attribute('href').text, base: @base).absolutize
|
91
|
-
@rels[rel_value].uniq!
|
92
|
-
end
|
93
|
-
|
94
|
-
unless rel_values.empty?
|
95
|
-
@rel_urls[url] = {} unless @rel_urls.has_key?(url)
|
96
|
-
|
97
|
-
@rel_urls[url]['hreflang'] = rel.attribute('hreflang').value if @rel_urls[url]['hreflang'].nil? and not rel.attribute('hreflang').nil?
|
98
|
-
@rel_urls[url]['media'] = rel.attribute('media').value if @rel_urls[url]['media'].nil? and not rel.attribute('media').nil?
|
99
|
-
@rel_urls[url]['title'] = rel.attribute('title').value if @rel_urls[url]['title'].nil? and not rel.attribute('title').nil?
|
100
|
-
@rel_urls[url]['type'] = rel.attribute('type').value if @rel_urls[url]['type'].nil? and not rel.attribute('type').nil?
|
101
|
-
@rel_urls[url]['text'] = rel.text.strip if @rel_urls[url]['text'].nil? and not rel.text.empty?
|
102
|
-
@rel_urls[url]['rels'] = rel_values
|
103
|
-
end
|
86
|
+
next if rel.attribute('href').nil?
|
87
|
+
|
88
|
+
url = Microformats::AbsoluteUri.new(rel.attribute('href').text, base: @base).absolutize
|
89
|
+
|
90
|
+
rel_values = rel.attribute('rel').text.split(' ')
|
104
91
|
|
92
|
+
rel_values.each do |rel_value|
|
93
|
+
@rels[rel_value] = [] unless @rels.key?(rel_value)
|
94
|
+
@rels[rel_value] << Microformats::AbsoluteUri.new(rel.attribute('href').text, base: @base).absolutize
|
95
|
+
@rels[rel_value].uniq!
|
105
96
|
end
|
97
|
+
|
98
|
+
next if rel_values.empty?
|
99
|
+
|
100
|
+
@rel_urls[url] = {} unless @rel_urls.key?(url)
|
101
|
+
|
102
|
+
@rel_urls[url]['hreflang'] = rel.attribute('hreflang').value if @rel_urls[url]['hreflang'].nil? && !rel.attribute('hreflang').nil?
|
103
|
+
@rel_urls[url]['media'] = rel.attribute('media').value if @rel_urls[url]['media'].nil? && !rel.attribute('media').nil?
|
104
|
+
@rel_urls[url]['title'] = rel.attribute('title').value if @rel_urls[url]['title'].nil? && !rel.attribute('title').nil?
|
105
|
+
@rel_urls[url]['type'] = rel.attribute('type').value if @rel_urls[url]['type'].nil? && !rel.attribute('type').nil?
|
106
|
+
@rel_urls[url]['text'] = rel.text.strip if @rel_urls[url]['text'].nil? && !rel.text.empty?
|
107
|
+
@rel_urls[url]['rels'] = rel_values
|
106
108
|
end
|
107
109
|
end
|
108
|
-
|
109
110
|
end
|
110
111
|
end
|
111
|
-
|
@@ -1,12 +1,10 @@
|
|
1
1
|
module Microformats
|
2
2
|
class ParserCore
|
3
|
-
|
4
3
|
VALUE_CLASS_REG_EXP = /^value$/
|
5
4
|
VALUE_TITLE_CLASS_REG_EXP = /^value-title$/
|
6
5
|
FORMAT_CLASS_REG_EXP = /^h-[a-z-]+$/
|
7
6
|
PROPERTY_CLASS_REG_EXP = /^(p-|u-|dt-|e-)[a-z-]+$/
|
8
7
|
|
9
|
-
|
10
8
|
def initialize
|
11
9
|
@mode_backcompat = false
|
12
10
|
@fmt_classes = []
|
@@ -15,18 +13,15 @@ module Microformats
|
|
15
13
|
private
|
16
14
|
|
17
15
|
def parse_node(node)
|
18
|
-
if node.is_a?(Nokogiri::HTML::Document)
|
16
|
+
if node.is_a?(Nokogiri::HTML::Document)
|
19
17
|
parse_node(node.children)
|
20
|
-
elsif node.is_a?(Nokogiri::XML::NodeSet)
|
18
|
+
elsif node.is_a?(Nokogiri::XML::NodeSet)
|
21
19
|
parse_nodeset(node)
|
22
|
-
elsif node.is_a?(Nokogiri::XML::Element)
|
20
|
+
elsif node.is_a?(Nokogiri::XML::Element)
|
23
21
|
parse_element(node)
|
24
|
-
else
|
25
|
-
nil
|
26
22
|
end
|
27
23
|
end
|
28
24
|
|
29
|
-
|
30
25
|
def parse_nodeset(nodeset)
|
31
26
|
nodeset.each do |node|
|
32
27
|
parse_node(node)
|
@@ -67,60 +62,71 @@ module Microformats
|
|
67
62
|
when /^[vh][cC]ard$/
|
68
63
|
result_set << 'h-card'
|
69
64
|
|
70
|
-
#these aren't actually specified by the backcompat faq, but probably should parse them
|
65
|
+
# these aren't actually specified by the backcompat faq, but probably should parse them
|
71
66
|
when /^h[fF]eed$/
|
72
67
|
result_set << 'h-feed'
|
73
68
|
when /^h[nN]ews$/
|
74
69
|
result_set << 'h-news'
|
75
|
-
|
76
70
|
else
|
77
|
-
if @fmt_classes.include?
|
71
|
+
if @fmt_classes.include?('h-entry') && html_class == 'author'
|
78
72
|
result_set << 'h-card'
|
79
73
|
end
|
80
|
-
|
74
|
+
|
75
|
+
if @fmt_classes.include?('h-product') && html_class == 'review'
|
81
76
|
result_set << 'h-review'
|
82
77
|
end
|
83
|
-
|
78
|
+
|
79
|
+
if @fmt_classes.include?('h-recipe') && html_class == 'author'
|
84
80
|
result_set << 'h-card'
|
85
81
|
end
|
86
|
-
|
82
|
+
|
83
|
+
if @fmt_classes.include?('h-resume') && html_class == 'contact'
|
87
84
|
result_set << 'h-card'
|
88
85
|
end
|
89
|
-
|
86
|
+
|
87
|
+
if @fmt_classes.include?('h-resume') && html_class == 'education'
|
90
88
|
result_set << 'h-event'
|
91
89
|
end
|
92
|
-
|
90
|
+
|
91
|
+
if @fmt_classes.include?('h-resume') && html_class == 'experience'
|
93
92
|
result_set << 'h-event'
|
94
93
|
end
|
95
|
-
|
94
|
+
|
95
|
+
if @fmt_classes.include?('h-resume') && html_class == 'affiliation'
|
96
96
|
result_set << 'h-card'
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
|
+
if @fmt_classes.include?('h-review') && html_class == 'reviewer'
|
99
100
|
result_set << 'h-card'
|
100
101
|
end
|
101
|
-
|
102
|
-
|
102
|
+
|
103
|
+
if @fmt_classes.include?('h-review') && html_class == 'item'
|
104
|
+
if !html_classes.include?('vcard') && !html_classes.include?('vevent') && !html_classes.include?('hproduct')
|
103
105
|
result_set << 'h-item'
|
104
106
|
end
|
105
107
|
end
|
106
|
-
|
107
|
-
|
108
|
+
|
109
|
+
if @fmt_classes.include?('h-review-aggregate') && html_class == 'item'
|
110
|
+
if !html_classes.include?('vcard') && !html_classes.include?('vevent') && !html_classes.include?('hproduct')
|
108
111
|
result_set << 'h-item'
|
109
112
|
end
|
110
113
|
end
|
111
|
-
|
114
|
+
|
115
|
+
if @fmt_classes.include?('h-review-aggregate') && html_class == 'reviewer'
|
112
116
|
result_set << 'h-card'
|
113
117
|
end
|
114
|
-
|
118
|
+
|
119
|
+
if @fmt_classes.include?('h-entry') && html_class == 'location'
|
115
120
|
result_set << 'h-adr'
|
116
121
|
result_set << 'h-card'
|
117
122
|
end
|
118
|
-
|
123
|
+
|
124
|
+
if @fmt_classes.include?('h-feed') && html_class == 'author'
|
119
125
|
result_set << 'h-card'
|
120
126
|
end
|
121
127
|
end
|
122
|
-
|
123
128
|
end
|
129
|
+
|
124
130
|
result_set.uniq
|
125
131
|
end
|
126
132
|
|
@@ -134,195 +140,199 @@ module Microformats
|
|
134
140
|
result_set = []
|
135
141
|
rels = element.attribute('rel').to_s.split
|
136
142
|
|
137
|
-
if @fmt_classes.include?
|
143
|
+
if @fmt_classes.include?('h-entry') && rels.include?('bookmark')
|
138
144
|
result_set << 'u-url'
|
139
145
|
end
|
140
|
-
|
146
|
+
|
147
|
+
if @fmt_classes.include?('h-entry') && rels.include?('tag')
|
141
148
|
result_set << 'p-category'
|
142
149
|
end
|
143
|
-
|
150
|
+
|
151
|
+
if @fmt_classes.include?('h-recipe') && rels.include?('tag')
|
144
152
|
result_set << 'p-category'
|
145
153
|
end
|
146
|
-
|
154
|
+
|
155
|
+
if @fmt_classes.include?('h-review') && rels.include?('tag')
|
147
156
|
result_set << 'p-category'
|
148
157
|
end
|
149
|
-
|
158
|
+
|
159
|
+
if @fmt_classes.include?('h-feed') && rels.include?('tag')
|
150
160
|
result_set << 'p-category'
|
151
161
|
end
|
152
|
-
|
162
|
+
|
163
|
+
if @fmt_classes.include?('h-review') && rels.include?('self') && rels.include?('bookmark')
|
153
164
|
result_set << 'u-url'
|
154
165
|
end
|
155
|
-
|
166
|
+
|
167
|
+
if @fmt_classes.include?('h-news') && rels.include?('principles')
|
156
168
|
result_set << 'u-principles'
|
157
169
|
end
|
158
170
|
|
159
|
-
#TODO PROPOSED convert time.entry-date[datetime] to dt-published see wiki/h-entry
|
160
|
-
#TODO PROPOSED convert rel=author to u-author see wiki/h-entry
|
171
|
+
# TODO: PROPOSED convert time.entry-date[datetime] to dt-published see wiki/h-entry
|
172
|
+
# TODO: PROPOSED convert rel=author to u-author see wiki/h-entry
|
161
173
|
|
162
174
|
element.attribute('class').to_s.split.each do |html_class|
|
163
|
-
|
164
|
-
|
165
|
-
if [ 'post-office-box', 'extended-address', 'street-address', 'locality', 'region', 'postal-code', 'country-name' ].include? html_class
|
175
|
+
if @fmt_classes.include?('h-adr')
|
176
|
+
if %w[post-office-box extended-address street-address locality region postal-code country-name].include?(html_class)
|
166
177
|
result_set << 'p-' + html_class
|
167
178
|
end
|
168
179
|
end
|
169
180
|
|
170
|
-
if @fmt_classes.include?
|
171
|
-
if [
|
181
|
+
if @fmt_classes.include?('h-geo')
|
182
|
+
if %w[longitude latitude].include?(html_class)
|
172
183
|
result_set << 'p-' + html_class
|
173
184
|
end
|
174
185
|
end
|
175
186
|
|
176
|
-
if @fmt_classes.include?
|
177
|
-
if html_class ==
|
187
|
+
if @fmt_classes.include?('h-entry')
|
188
|
+
if html_class == 'entry-title'
|
178
189
|
result_set << 'p-name'
|
179
|
-
elsif html_class ==
|
190
|
+
elsif html_class == 'entry-summary'
|
180
191
|
result_set << 'p-summary'
|
181
|
-
elsif html_class ==
|
192
|
+
elsif html_class == 'entry-content'
|
182
193
|
result_set << 'e-content'
|
183
|
-
elsif [
|
194
|
+
elsif %w[updated published].include?(html_class)
|
184
195
|
result_set << 'dt-' + html_class
|
185
|
-
elsif [
|
196
|
+
elsif %w[category author].include?(html_class)
|
186
197
|
result_set << 'p-' + html_class
|
187
198
|
end
|
188
199
|
end
|
189
200
|
|
190
|
-
#h-news isn't even listed in backcompat list, adding to follow test suite
|
191
|
-
if @fmt_classes.include?
|
192
|
-
if [
|
201
|
+
# h-news isn't even listed in backcompat list, adding to follow test suite
|
202
|
+
if @fmt_classes.include?('h-news')
|
203
|
+
if %w[source-org entry dateline geo].include?(html_class)
|
193
204
|
result_set << 'p-' + html_class
|
194
205
|
end
|
195
206
|
end
|
196
207
|
|
197
|
-
if @fmt_classes.include?
|
198
|
-
if html_class ==
|
208
|
+
if @fmt_classes.include?('h-feed')
|
209
|
+
if html_class == 'fn'
|
199
210
|
result_set << 'p-name'
|
200
|
-
elsif [
|
211
|
+
elsif %w[author summary].include?(html_class)
|
201
212
|
result_set << 'p-' + html_class
|
202
|
-
elsif [
|
213
|
+
elsif %w[photo url].include?(html_class)
|
203
214
|
result_set << 'u-' + html_class
|
204
215
|
end
|
205
216
|
end
|
206
217
|
|
207
|
-
if @fmt_classes.include?
|
208
|
-
if html_class ==
|
218
|
+
if @fmt_classes.include?('h-item')
|
219
|
+
if html_class == 'fn'
|
209
220
|
result_set << 'p-name'
|
210
|
-
elsif [
|
221
|
+
elsif %w[photo url].include?(html_class)
|
211
222
|
result_set << 'u-' + html_class
|
212
223
|
end
|
213
224
|
end
|
214
225
|
|
215
|
-
if @fmt_classes.include?
|
216
|
-
if html_class ==
|
226
|
+
if @fmt_classes.include?('h-product')
|
227
|
+
if html_class == 'fn'
|
217
228
|
result_set << 'p-name'
|
218
|
-
elsif [
|
229
|
+
elsif %w[photo url identifier].include?(html_class)
|
219
230
|
result_set << 'u-' + html_class
|
220
|
-
elsif [
|
231
|
+
elsif %w[brand category price review description].include?(html_class)
|
221
232
|
result_set << 'p-' + html_class
|
222
233
|
end
|
223
234
|
end
|
224
235
|
|
225
|
-
if @fmt_classes.include?
|
226
|
-
if html_class ==
|
236
|
+
if @fmt_classes.include?('h-recipe')
|
237
|
+
if html_class == 'fn'
|
227
238
|
result_set << 'p-name'
|
228
|
-
elsif html_class ==
|
239
|
+
elsif html_class == 'instructions'
|
229
240
|
result_set << 'e-instructions'
|
230
|
-
elsif html_class ==
|
241
|
+
elsif html_class == 'duration'
|
231
242
|
result_set << 'dt-duration'
|
232
|
-
elsif html_class ==
|
243
|
+
elsif html_class == 'photo'
|
233
244
|
result_set << 'u-photo'
|
234
|
-
elsif [
|
245
|
+
elsif %w[ingredient category yield summary nutrition author].include?(html_class)
|
235
246
|
result_set << 'p-' + html_class
|
236
247
|
end
|
237
248
|
end
|
238
249
|
|
239
|
-
if @fmt_classes.include?
|
240
|
-
if [
|
250
|
+
if @fmt_classes.include?('h-resume')
|
251
|
+
if %w[skill summary contact education experience affiliation].include?(html_class)
|
241
252
|
result_set << 'p-' + html_class
|
242
253
|
end
|
243
254
|
end
|
244
255
|
|
245
|
-
if @fmt_classes.include?
|
246
|
-
if html_class ==
|
256
|
+
if @fmt_classes.include?('h-review')
|
257
|
+
if html_class == 'summary'
|
247
258
|
result_set << 'p-name'
|
248
|
-
elsif html_class ==
|
259
|
+
elsif html_class == 'fn'
|
249
260
|
result_set << 'p-name'
|
250
|
-
elsif html_class ==
|
261
|
+
elsif html_class == 'reviewer'
|
251
262
|
result_set << 'p-author'
|
252
|
-
elsif html_class ==
|
263
|
+
elsif html_class == 'dtreviewed'
|
253
264
|
result_set << 'dt-published'
|
254
|
-
elsif html_class ==
|
265
|
+
elsif html_class == 'description'
|
255
266
|
result_set << 'e-content'
|
256
|
-
elsif [
|
267
|
+
elsif %w[photo url identifier].include?(html_class)
|
257
268
|
result_set << 'u-' + html_class
|
258
|
-
elsif [
|
269
|
+
elsif %w[rating best worst item].include?(html_class)
|
259
270
|
result_set << 'p-' + html_class
|
260
271
|
end
|
261
272
|
end
|
262
273
|
|
263
|
-
if @fmt_classes.include?
|
264
|
-
if html_class ==
|
274
|
+
if @fmt_classes.include?('h-review-aggregate')
|
275
|
+
if html_class == 'summary'
|
265
276
|
result_set << 'p-name'
|
266
|
-
elsif html_class ==
|
277
|
+
elsif html_class == 'fn'
|
267
278
|
result_set << 'p-name'
|
268
|
-
elsif html_class ==
|
279
|
+
elsif html_class == 'reviewer'
|
269
280
|
result_set << 'p-author'
|
270
|
-
elsif html_class ==
|
281
|
+
elsif html_class == 'dtreviewed'
|
271
282
|
result_set << 'dt-published'
|
272
|
-
elsif html_class ==
|
283
|
+
elsif html_class == 'description'
|
273
284
|
result_set << 'e-content'
|
274
|
-
elsif [
|
285
|
+
elsif %w[photo url identifier].include?(html_class)
|
275
286
|
result_set << 'u-' + html_class
|
276
|
-
elsif [
|
287
|
+
elsif %w[rating best worst item count votes average].include?(html_class)
|
277
288
|
result_set << 'p-' + html_class
|
278
289
|
end
|
279
290
|
end
|
280
291
|
|
281
|
-
if @fmt_classes.include?
|
282
|
-
if html_class ==
|
292
|
+
if @fmt_classes.include?('h-event')
|
293
|
+
if html_class == 'summary'
|
283
294
|
result_set << 'p-name'
|
284
|
-
elsif html_class ==
|
295
|
+
elsif html_class == 'dtstart'
|
285
296
|
result_set << 'dt-start'
|
286
|
-
elsif html_class ==
|
297
|
+
elsif html_class == 'dtend'
|
287
298
|
result_set << 'dt-end'
|
288
|
-
elsif html_class ==
|
299
|
+
elsif html_class == 'duration'
|
289
300
|
result_set << 'dt-duration'
|
290
|
-
elsif html_class ==
|
301
|
+
elsif html_class == 'geo'
|
291
302
|
result_set << 'p-location'
|
292
|
-
elsif [
|
303
|
+
elsif %w[url].include?(html_class)
|
293
304
|
result_set << 'u-' + html_class
|
294
|
-
elsif [
|
305
|
+
elsif %w[description category location attendee].include?(html_class)
|
295
306
|
result_set << 'p-' + html_class
|
296
307
|
end
|
297
308
|
end
|
298
309
|
|
299
|
-
if @fmt_classes.include?
|
300
|
-
if html_class ==
|
310
|
+
if @fmt_classes.include?('h-card')
|
311
|
+
if html_class == 'fn'
|
301
312
|
result_set << 'p-name'
|
302
|
-
elsif html_class ==
|
313
|
+
elsif html_class == 'bday'
|
303
314
|
result_set << 'dt-bday'
|
304
|
-
elsif html_class ==
|
315
|
+
elsif html_class == 'title'
|
305
316
|
result_set << 'p-job-title'
|
306
|
-
elsif html_class ==
|
317
|
+
elsif html_class == 'rev'
|
307
318
|
result_set << 'dt-rev'
|
308
|
-
elsif [
|
319
|
+
elsif %w[email logo photo url uid key].include?(html_class)
|
309
320
|
result_set << 'u-' + html_class
|
310
|
-
elsif [
|
311
|
-
|
312
|
-
|
321
|
+
elsif %w[honorific-prefix given-name additional-name family-name honorific-suffix nickname
|
322
|
+
category adr extended-address street-address locality region postal-code country-name
|
323
|
+
label geo latitude longitude tel note org organization-name organization-unit role tz].include?(html_class)
|
313
324
|
result_set << 'p-' + html_class
|
314
325
|
|
315
|
-
#these aren't listed in the wiki, may be removed
|
316
|
-
elsif [
|
326
|
+
# these aren't listed in the wiki, may be removed
|
327
|
+
elsif %w[sound].include?(html_class)
|
317
328
|
result_set << 'u-' + html_class
|
318
|
-
#these aren't listed in the wiki, may be removed
|
319
|
-
elsif [
|
329
|
+
# these aren't listed in the wiki, may be removed
|
330
|
+
elsif %w[agent mailer sort-string class].include?(html_class)
|
320
331
|
result_set << 'p-' + html_class
|
321
|
-
|
322
332
|
end
|
323
333
|
end
|
324
|
-
|
325
334
|
end
|
335
|
+
|
326
336
|
result_set.uniq
|
327
337
|
end
|
328
338
|
|
@@ -331,13 +341,36 @@ module Microformats
|
|
331
341
|
html_class =~ VALUE_CLASS_REG_EXP
|
332
342
|
end
|
333
343
|
end
|
344
|
+
|
334
345
|
def value_title_classes(element)
|
335
346
|
element.attribute('class').to_s.split.select do |html_class|
|
336
347
|
html_class =~ VALUE_TITLE_CLASS_REG_EXP
|
337
348
|
end
|
338
349
|
end
|
339
350
|
|
340
|
-
|
351
|
+
def render_and_strip(data)
|
352
|
+
new_doc = Nokogiri::HTML(data)
|
353
|
+
new_doc.xpath('//script|//style').remove
|
354
|
+
new_doc.text.strip
|
355
|
+
end
|
341
356
|
|
342
|
-
|
357
|
+
def render_text(in_node, base: nil)
|
358
|
+
doc = Nokogiri::HTML(in_node.inner_html)
|
359
|
+
|
360
|
+
doc.xpath('//script|//style').remove
|
361
|
+
|
362
|
+
# cannot use doc.css('img').each as it makes a copy of them, it does not modify the original
|
363
|
+
doc.traverse do |node|
|
364
|
+
next unless node.name == 'img'
|
365
|
+
|
366
|
+
if !node.attribute('alt').nil?
|
367
|
+
node.replace(node.attribute('alt').value.to_s)
|
368
|
+
elsif !node.attribute('src').nil?
|
369
|
+
node.replace(Microformats::AbsoluteUri.new(node.attribute('src').value.to_s, base: @base).absolutize)
|
370
|
+
end
|
371
|
+
end
|
343
372
|
|
373
|
+
doc.text.strip
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|