{"id":15831687,"url":"https://github.com/cleverdevil/microformats2","last_synced_at":"2025-04-01T17:33:21.115Z","repository":{"id":52706117,"uuid":"124623306","full_name":"cleverdevil/microformats2","owner":"cleverdevil","description":"Validate Microformats2 JSON with JSON Schema, and perform Post Type Discovery","archived":false,"fork":false,"pushed_at":"2021-04-20T17:02:01.000Z","size":47,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-12T12:32:10.217Z","etag":null,"topics":["indieweb","json","json-schema","microformats2","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cleverdevil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-10T04:53:16.000Z","updated_at":"2023-07-11T19:59:48.000Z","dependencies_parsed_at":"2022-08-22T08:00:30.237Z","dependency_job_id":null,"html_url":"https://github.com/cleverdevil/microformats2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverdevil%2Fmicroformats2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverdevil%2Fmicroformats2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverdevil%2Fmicroformats2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverdevil%2Fmicroformats2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cleverdevil","download_url":"https://codeload.github.com/cleverdevil/microformats2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222745086,"owners_count":17031339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["indieweb","json","json-schema","microformats2","python"],"created_at":"2024-10-05T12:06:03.357Z","updated_at":"2024-11-02T17:07:58.020Z","avatar_url":"https://github.com/cleverdevil.png","language":"Python","readme":"microformats2\n=============\n\nA Python package for validating JSON-encoded \n[Microformats2](http://microformats.org/wiki/microformats2) using \n[JSON Schema](http://json-schema.org).\n\n\nUsage\n-----\n\nValidating MF2 JSON:\n\n```python\nimport microformats2\n\nmf2 = { \n    \"type\": [\"h-event\"],\n    \"properties\": {\n        \"name\": [\"IndieWebCamp 2012\"],\n        \"url\": [\"http://indiewebcamp.com/2012\"],\n        \"start\": [\"2012-06-30\"],\n        \"end\": [\"2012-07-01\"],\n        \"location\": [{\n            \"value\": \"Geoloqi\",\n            \"type\": [\"h-card\"],\n            \"properties\": {\n                \"name\": [\"Geoloqi\"],\n                \"org\": [\"Geoloqi\"],\n                \"url\": [\"http://geoloqi.com/\"],\n                \"street-address\": [\"920 SW 3rd Ave. Suite 400\"],\n                \"locality\": [\"Portland\"],\n                \"region\": [\"Oregon\"]\n            }\n        }]\n    }\n}\n\nmicroformats2.validate(mf2)\n```\n\nGet the schema for a particular microformat:\n\n```python3\n\nimport microformats2\nimport json\n\nprint(json.dumps(microformats2.schema_for('h-entry'), indent=2))\n```\n\nFor those of you not using Python, who just want a raw JSON schema file to use,\nrefer to\n[schema.json](https://raw.githubusercontent.com/cleverdevil/microformats2/master/schema.json)\nwhich was generated using this command:\n\n```sh\npython tools/generate.py \u003e schema.json\n```\n\nDetermine the post type for a MF2 JSON entry, using the [Post Type\nDiscovery](https://www.w3.org/TR/post-type-discovery/) guidelines from the W3C.\n\n```python3\n\nimport microformats2\n\nmf2 = {\n    \"type\": [\n        \"h-entry\"\n    ],\n    \"properties\": {\n        \"name\": [\n            \"Microformats are amazing\"\n        ],\n        \"author\": [\n            {\n                \"value\": \"W. Developer\",\n                \"type\": [\n                    \"h-card\"\n                ],\n                \"properties\": {\n                    \"name\": [\n                        \"W. Developer\"\n                    ],\n                    \"url\": [\n                        \"http://example.com\"\n                    ]\n                }\n            }\n        ],\n        \"published\": [\n            \"2013-06-13 12:00:00\"\n        ],\n        \"summary\": [\n            \"In which I extoll the virtues of using microformats.\"\n        ],\n        \"content\": [\n            {\n                \"value\": \"Blah blah blah\",\n                \"html\": \"\u003cp\u003eBlah blah blah\u003c/p\u003e\"\n            }\n        ]\n    }\n}\n\nassert microformats2.get_post_type(mf2) == microformats2.PostTypes.article\n```\n\nConvert MF2 JSON to JF2:\n\n```python\njf2 = microformats2.to_jf2(mf2)\nassert jf2 == {\n    \"type\": \"entry\",\n    \"name\": \"Microformats are amazing\",\n    \"author\": {\n        \"type\": \"card\",\n        \"name\": \"W. Developer\",\n        \"url\": \"http://example.com\"\n    },\n    \"published\": \"2013-06-13 12:00:00\",\n    \"summary\": \"In which I extoll the virtues of using microformats.\",\n    \"content\": \"Blah blah blah\"\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleverdevil%2Fmicroformats2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcleverdevil%2Fmicroformats2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleverdevil%2Fmicroformats2/lists"}