Commits

Tom Morris committed a173e89

added simple name-implied - will add more rules later when we have test cases

Comments (0)

Files changed (3)

     def parse(self):
         def handle_microformat(microformat_name, el):
             properties = parse_props(el, {})
+            if microformat_name == "h-card" and 'name' not in properties:
+                properties["name"] = [el.firstChild.nodeValue]
+                # TODO: replace with proper name-implied
             microformat = {"type": [microformat_name],
                            "properties": properties}
             return microformat

test/examples/simple_person_reference_implied.html

+<!DOCTYPE html>
+<html>
+<head>
+  <meta http-equiv="content-type" content="text/html; charset=utf-8">
+  <title>Simple_person_reference</title>
+</head>
+<body>
+  <span class="h-card">Frances Berriman</span>
+</body>
+</html>

test/test_parser.py

     p = Parser(open("test/examples/simple_person_reference.html"))
     result = p.to_dict()
     assert result["items"][0]["properties"] == {u'name': [u'Frances Berriman']}
+
+def test_simple_person_reference_implied():
+    p = Parser(open("test/examples/simple_person_reference_implied.html"))
+    result = p.to_dict()
+    assert result["items"][0]["properties"] == {u'name': [u'Frances Berriman']}