hcard parsing tests

This page was design to test the parsing of hcard and its output to the newer JSON structure of micorformats 2. These tests are part of the micorformats 2 test suite.

Theses are backwards compatibility tests for the older version 1 microformats specification. Please do not use this as a reference for authoring microformats.

Just a name (hcard parsing test)

Frances Berriman

The expected JSON output:


{
    "items": [{
        "type": ["h-card"],
        "properties": {
            "name": ["Frances Berriman"]
        }
    }]
}

Just a hyperlink (hcard parsing test)

Ben Ward

The expected JSON output:


{
    "items": [{
        "type": ["h-card"],
        "properties": {
            "name": ["Ben Ward"],
            "url": ["http://benward.me/"]
        }
    }]
}

A hyperlinked photo (hcard parsing test)

Rohit Khare

The expected JSON output:


{
    "items": [{
        "type": ["h-card"],
        "properties": {
            "name": ["Rohit Khare"],
            "photo": ["https://twimg0-a.akamaihd.net/profile_images/53307499/180px-Rohit-sq.jpg"],
            "url": ["http://rohit.khare.org/"]
        }
    }]
}

Name properties (hcard parsing test)

Dr John P Doe PHD

The expected JSON output:


{
    "items": [{
        "type": ["h-card"],
        "properties": {
            "honorific-prefix": ["Dr"],
            "given-name": ["John"],
            "additional-name": ["Peter"],
            "family-name": ["Doe"],
            "honorific-suffix": ["MSc","PHD"],
            "name": ["Dr John P Doe"]
        }
    }]
}

Class attribute format (hcard parsing test)

John Doe

The expected JSON output:


{
    "items": [{
        "type": ["h-card"],
        "properties": {
            "name": ["John Doe"],
            "given-name": ["John"]
        }
    }]
}

Emails (hcard parsing test)

John Doe

The expected JSON output:


{
    "items": [{
        "type": ["h-card"],
        "properties": {
            "name": ["John Doe"],
            "email": [
                "mailto:john@example.com", 
                "mailto:john@example.com",
                "mailto:john@example.com?subject=parser-test",
                "john@example.com"
            ]
        }
    }]
}

Note: The second example (value pattern) parses differently to a V1 parser

Single occurrence properties (hcard parsing test)

John Doe
Birthday: January 1st, 2000
Role: Designer
Location: Brighton
Time zone: Eastern Standard Time
Profile details:
Profile id: http://example.com/profiles/johndoe
Details are: Public
Last updated: January 1st, 2008 - 13:45

The expected JSON output:


{
    "items": [{
        "type": ["h-card"],
        "properties": {
            "name": ["John Doe"],
            "given-name": ["John"],
            "sort-string": ["John"],
            "bday": ["2000-01-01T00:00:00-0800"],
            "role": ["Designer"],
            "geo": [{
                "value": "Brighton",
                "type": ["h-geo"],
                "properties": {
                    "name": ["30.267991;-97.739568"]
                }
            }],
            "tz": ["-05:00"],
            "uid": ["http://example.com/profiles/johndoe"],
            "class": ["Public"],
            "rev": ["2008-01-01T13:45:00"]
        }
    }]
}

Multiple occurrence properties (hcard parsing test)

John Doe
Pronunciation of my name
Photo of John Doe

Nicknames:

  • Man with no name
  • Lost boy

About:

John Doe is one of those names you always have issues with.

It can be a real problem booking a hotel room with the name John Doe.

Companies:

Tags: , and

Phone numbers:

  • Work (preferred): +1 415 555 100
  • Home: +1 415 555 200
  • Postal: +1 415 555 300

Emails:

John Doe uses PigeonMail 2.1 or Outlook 2007 for email.

Addresses:

  • Work: North Street, Brighton, United Kingdom
  • Home: West Street, Brighton, United Kingdom

In emergency contact: Jane Doe or Dave Doe.

Key: hd02$Gfu*d%dh87KTa2=23934532479

The expected JSON output:


{
    "items": [{
        "type": ["h-card"],
        "properties": {
            "name": ["John Doe"],
            "given-name": ["John"],
            "family-name": ["Doe"],
            "sound": ["http://www.madgex.com/johndoe.mpeg"],
            "photo": ["http://example.com/images/photo.gif"],
            "nickname": ["Man with no name","Lost boy"],
            "note": [
                "John Doe is one of those names you always have issues with.",
                "It can be a real problem booking a hotel room with the name John Doe."
            ],
            "url": ["http://www.madgex.com/", "http://www.webfeetmedia.com/"],
            "org": ["Madgex","Web Feet Media Ltd"],
            "title": ["Creative Director", "Owner"],
            "category": ["design", "development", "web"],
            "tel": ["+1 415 555 100", "+1 415 555 200", "+1 415 555 300"],
            "email": ["mailto:john.doe@madgex.com", "mailto:john.doe@webfeetmedia.com"],
            "mailer": ["PigeonMail 2.1","Outlook 2007"],
            "adr": [{
                "value": "Work: North Street, Brighton, United Kingdom",
                "type": ["h-adr"],
                "properties": {
                    "street-address": ["North Street"],
                    "locality": ["Brighton"],
                    "country-name": ["United Kingdom"]
                }
            },{
                "value": "Home: West Street, Brighton, United Kingdom",
                "type": ["h-adr"],
                "properties": {
                    "street-address": ["West Street"],
                    "locality": ["Brighton"],
                    "country-name": ["United Kingdom"]
                }
            }],
            "label": ["Work: North Street, Brighton, United Kingdom", "Home: West Street, Brighton, United Kingdom"],
            "agent": ["Jane Doe",
            {
                "value": "Dave Doe",
                "type": ["h-card"],
                "properties": {
                    "name": ["Dave Doe"]
                }
            }],
            "key": ["hd02$Gfu*d%dh87KTa2=23934532479"]
        }
    }]
}

Change log:

Contributors:

The orginal test also had contributions from: