Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mf2py/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@ def handle_microformat(
# if some properties not already found find in implied ways unless in backcompat mode
if not backcompat_mode:
# stop implied name if any p-*, e-*, h-* is already found
if "name" not in properties and parsed_types_aggregation.isdisjoint(
"peh"
if (
"name" not in properties
and parsed_types_aggregation.isdisjoint("peh")
and "h-geo" not in el.attrs["class"] # skip nested backcompat geo
):
properties["name"] = [
implied_properties.name(el, self.__url__, self.filtered_roots)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="vcard">
<div class="fn">John Doe</div>
<div>Location: <abbr class="geo" title="30.267991;-97.739568"><a class="u-url" href="https://brighton.co.uk">Brighton</a></abbr></div>
</div>
19 changes: 19 additions & 0 deletions test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,25 @@ def test_implied_nested_photo_alt_name():
assert result["items"][3]["properties"]["name"][0] == "Tom Morris"


def test_implied_nested_backcompat():
result = parse_fixture("implied_properties/implied_nested_backcompat.html")
hcard = result["items"][0]

assert {
"type": ["h-card"],
"properties": {
"name": ["John Doe"],
"geo": [
{
"type": ["h-geo"],
"properties": {"url": ["https://brighton.co.uk"]},
"value": "30.267991;-97.739568",
}
],
},
} == hcard


def test_implied_image():
result = parse_fixture("implied_properties/implied_properties.html")
assert result["items"][4]["properties"]["photo"][0] == {
Expand Down