{"id":13545672,"url":"https://github.com/microformats/php-mf2","last_synced_at":"2025-04-10T06:36:41.813Z","repository":{"id":4953120,"uuid":"6110485","full_name":"microformats/php-mf2","owner":"microformats","description":"php-mf2 is a pure, generic microformats-2 parser for PHP. It makes HTML as easy to consume as JSON.","archived":false,"fork":false,"pushed_at":"2024-09-30T03:01:19.000Z","size":1206,"stargazers_count":195,"open_issues_count":27,"forks_count":38,"subscribers_count":30,"default_branch":"main","last_synced_at":"2025-04-03T03:51:15.957Z","etag":null,"topics":["indieweb","microformats","microformats2","parser","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microformats.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-10-07T08:01:35.000Z","updated_at":"2024-12-04T01:54:37.000Z","dependencies_parsed_at":"2023-01-13T13:18:41.292Z","dependency_job_id":"ed9a1224-5fdd-4729-8f56-ac081b946784","html_url":"https://github.com/microformats/php-mf2","commit_stats":{"total_commits":506,"total_committers":21,"mean_commits":"24.095238095238095","dds":0.4644268774703557,"last_synced_commit":"2d65354b3e4857c3f68f8c3737020d8a8298c6ee"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fphp-mf2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fphp-mf2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fphp-mf2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fphp-mf2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microformats","download_url":"https://codeload.github.com/microformats/php-mf2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248170783,"owners_count":21059249,"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","microformats","microformats2","parser","php"],"created_at":"2024-08-01T11:01:09.041Z","updated_at":"2025-04-10T06:36:41.777Z","avatar_url":"https://github.com/microformats.png","language":"PHP","readme":"# php-mf2\n\n[![Latest Stable Version](http://poser.pugx.org/mf2/mf2/v)](https://packagist.org/packages/mf2/mf2) [![Total Downloads](http://poser.pugx.org/mf2/mf2/downloads)](https://packagist.org/packages/mf2/mf2) [![Latest Unstable Version](http://poser.pugx.org/mf2/mf2/v/unstable)](https://packagist.org/packages/mf2/mf2) [![License](http://poser.pugx.org/mf2/mf2/license)](https://packagist.org/packages/mf2/mf2) [![PHP Version Require](http://poser.pugx.org/mf2/mf2/require/php)](https://packagist.org/packages/mf2/mf2) \u003ca href=\"https://github.com/microformats/php-mf2/actions/workflows/main.yml\"\u003e\u003cimg src=\"https://github.com/microformats/php-mf2/actions/workflows/main.yml/badge.svg?branch=main\" alt=\"\" /\u003e\u003c/a\u003e\n\nphp-mf2 is a pure, generic [microformats-2](http://microformats.org/wiki/microformats-2) parser. It makes HTML as easy to consume as JSON.\n\nInstead of having a hard-coded list of all the different microformats, it follows a set of procedures to handle different property types (e.g. `p-` for plaintext, `u-` for URL, etc). This allows for a very small and maintainable parser.\n\n## Installation\n\nThere are two ways of installing php-mf2. We **highly recommend** installing php-mf2 using [Composer](http://getcomposer.org). The rest of the documentation assumes that you have done so.\n\nTo install using Composer, run\n\n```\ncomposer require mf2/mf2\n```\n\nIf you can’t or don’t want to use Composer, then php-mf2 can be installed the old way by downloading [`/Mf2/Parser.php`](https://raw.githubusercontent.com/microformats/php-mf2/master/Mf2/Parser.php), adding it to your project and requiring it from files you want to call its functions from, like this:\n\n```php\n\u003c?php\n\nrequire_once 'Mf2/Parser.php';\n\n// Now all the functions documented below are available, for example:\n$mf = Mf2\\fetch('https://waterpigs.co.uk');\n```\n\nIt is recommended to install the HTML5 parser for proper handling of HTML5 elements. Using composer, run\n\n```\ncomposer require masterminds/html5\n```\n\nIf this library is added to your project, the php-mf2 parser will use it automatically instead of the built-in HTML parser.\n\n\n### Signed Code Verification\n\nFrom v0.2.9, php-mf2’s version tags are signed using GPG, allowing you to cryptographically verify that you’re using code which hasn’t been tampered with. To verify the code you will need the GPG keys for one of the people in the list of code signers:\n\n* Barnaby Walters barnaby@waterpigs.co.uk 1C00 430B 19C6 B426 922F E534 BEF8 CE58 118A D524\n* Aaron Parecki aaron@parecki.com F384 12A1 55FB 8B15 B7DD 8E07 4225 2B5E 65CE 0ADD\n* Bear bear@bear.im 0A93 9BA7 8203 FCBC 58A9 E8B5 9D1E 0661 8EE5 B4D8\n\nTo import the relevant keys into your GPG keychain, execute the following command:\n\n```bash\ngpg --recv-keys 1C00430B19C6B426922FE534BEF8CE58118AD524 F38412A155FB8B15B7DD8E0742252B5E65CE0ADD 0A939BA78203FCBC58A9E8B59D1E06618EE5B4D8\n```\n\nThen verify the installed files like this:\n\n```bash\n# in your project root\ncd vendor/mf2/mf2\ngit tag -v v0.3.0\n```\n\nIf nothing went wrong, you should see the tag commit message, ending something like this:\n\n```\ngpg: Signature made Wed  6 Aug 10:04:20 2014 GMT using RSA key ID 2B2BBB65\ngpg: Good signature from \"Barnaby Walters \u003cbarnaby@waterpigs.co.uk\u003e\"\ngpg:                 aka \"[jpeg image of size 12805]\"\n```\n\nPossible issues:\n\n* **Git complains that there’s no such tag**: check for a .git file in the source folder; odds are you have the prefer-dist setting enabled and composer is just extracting a zip rather than checking out from git.\n* **Git complains the gpg command doesn’t exist**: If you successfully imported my key then you obviously do have gpg installed, but you might have gpg2, whereas git looks for gpg. Solution: tell git which binary to use: `git config --global gpg.program 'gpg2'`\n\n## Usage\n\nphp-mf2 is PSR-0 autoloadable, so simply include Composer’s auto-generated autoload file (`/vendor/autoload.php`) and you can start using it. These two functions cover most situations:\n\n* To fetch microformats from a URL, call `Mf2\\fetch($url)`\n* To parse microformats from HTML, call `Mf2\\parse($html, $url)`, where `$url` is the URL from which `$html` was loaded, if any. This parameter is required for correct relative URL parsing and must not be left out unless parsing HTML which is not loaded from the web.\n\nAll parsing functions return a canonical microformats 2 representation of any microformats found on the page, as an array. For a general guide to safely and successfully processing parsed microformats data, see [How to Consume Microformats 2 Data](https://waterpigs.co.uk/articles/consuming-microformats/).\n\n## Examples\n\n### Fetching Microformats from a URL\n\n```php\n\u003c?php\n\nnamespace YourApp;\n\nrequire '/vendor/autoload.php';\n\nuse Mf2;\n\n// (Above code (or equivalent) assumed in future examples)\n\n$mf = Mf2\\fetch('http://microformats.org');\n\n// $mf is either a canonical mf2 array, or null on an error.\nif (is_array($mf)) {\n  foreach ($mf['items'] as $microformat) {\n    // Note: in real code, never assume that a property exists, or that a particular property value is a string!\n    echo \"A {$microformat['type'][0]} called {$microformat['properties']['name'][0]}\\n\";\n  }\n}\n\n```\n\n### Parsing Microformats from a HTML String\n\nHere we demonstrate parsing of microformats2 implied property parsing, where an entire h-card with name and URL properties is created using a single `h-card` class.\n\n```php\n\u003c?php\n\n$html = '\u003ca class=\"h-card\" href=\"https://waterpigs.co.uk/\"\u003eBarnaby Walters\u003c/a\u003e';\n$output = Mf2\\parse($html, 'https://waterpigs.co.uk/');\n```\n\n`$output` is a canonical microformats2 array structure like:\n\n```json\n{\n  \"items\": [\n    {\n      \"type\": [\"h-card\"],\n      \"properties\": {\n        \"name\": [\"Barnaby Walters\"],\n        \"url\": [\"https://waterpigs.co.uk/\"]\n      }\n    }\n  ],\n  \"rels\": {},\n  \"rel-urls\": {}\n}\n```\n\nIf no microformats are found, `items` will be an empty array.\n\nNote that, whilst the property prefixes are stripped, the prefix of the `h-*` classname(s) in the \"type\" array are retained.\n\n### Parsing a Document with Relative URLs\n\nMost of the time you’ll be getting your input HTML from a URL. You should pass that URL as the second parameter to `Mf2\\parse()` so that any relative URLs in the document can be resolved. For example, say you got the following HTML from `http://example.org/post/1`:\n\n```html\n\u003cdiv class=\"h-card\"\u003e\n  \u003ch1 class=\"p-name\"\u003eMr. Example\u003c/h1\u003e\n  \u003cimg class=\"u-photo\" alt=\"\" src=\"/photo.png\" /\u003e\n\u003c/div\u003e\n```\n\nParsing like this:\n\n```php\n$output = Mf2\\parse($html, 'http://example.org/post/1');\n```\n\nwill result in the following output, with relative URLs made absolute:\n\n```json\n{\n  \"items\": [{\n    \"type\": [\"h-card\"],\n    \"properties\": {\n      \"name\": [\"Mr. Example\"],\n      \"photo\": [{\n        \"value\": \"http://example.org/photo.png\",\n        \"alt\": \"\"\n      }]\n    }\n  }],\n  \"rels\": {},\n  \"rel-urls\": {}\n}\n```\n\nphp-mf2 correctly handles relative URL resolution according to the URI and HTML specs, including correct use of the `\u003cbase\u003e` element.\n\n### Parsing Link `rel` Values\n\nphp-mf2 also parses any link relations in the document, placing them into two top-level arrays. For convenience and completeness, one is indexed by each individual rel value, and the other by each URL.\n\nFor example, this HTML:\n\n```html\n\u003ca rel=\"me\" href=\"https://twitter.com/barnabywalters\"\u003eMe on twitter\u003c/a\u003e\n\u003clink rel=\"alternate etc\" href=\"http://example.com/notes.atom\" /\u003e\n```\n\nparses to the following canonical representation:\n\n```json\n{\n  \"items\": [],\n  \"rels\": {\n    \"me\": [\"https://twitter.com/barnabywalters\"],\n    \"alternate\": [\"http://example.com/notes.atom\"],\n    \"etc\": [\"http://example.com/notes.atom\"]\n  },\n  \"rel-urls\": {\n    \"https://twitter.com/barnabywalters\": {\n      \"text\": \"Me on twitter\",\n      \"rels\": [\"me\"]\n    },\n    \"http://example.com/notes.atom\": {\n      \"rels\": [\"alternate\", \"etc\"]\n    }\n  }\n}\n```\n\nIf you’re not bothered about the microformats2 data and just want rels and alternates, you can (very slightly) improve performance by creating a `Mf2\\Parser` object (see below) and calling `-\u003eparseRelsAndAlternates()` instead of `-\u003eparse()`, e.g.\n\n```php\n\u003c?php\n\n$parser = new Mf2\\Parser('\u003clink rel=\"…');\n$relsAndAlternates = $parser-\u003eparseRelsAndAlternates();\n```\n\n### Debugging Mf2\\fetch\n\n`Mf2\\fetch()` will attempt to parse any response served with “HTML” in the content-type, regardless of what the status code is. If it receives a non-HTML response it will return null.\n\nTo learn what the HTTP status code for any request was, or learn more about the request, pass a variable name as the third parameter to `Mf2\\fetch()` — this will be filled with the contents of `curl_getinfo()`, e.g:\n\n```php\n\n\u003c?php\n\n$mf = Mf2\\fetch('http://waterpigs.co.uk/this-page-doesnt-exist', true, $curlInfo);\nif ($curlInfo['http_code'] == '404') {\n  // This page doesn’t exist.\n}\n\n```\n\nIf it was HTML then it is still parsed, as there are cases where error pages contain microformats — for example a deleted h-entry resulting in a 410 Gone response containing a stub h-entry with an explanation for the deletion.\n\n### Getting more control by creating a Parser object\n\nThe `Mf2\\parse()` function covers the most common usage patterns by internally creating an instance of `Mf2\\Parser` and returning the output all in one step. For some advanced usage you can also create an instance of `Mf2\\Parser` yourself.\n\nThe constructor takes two arguments, the input HTML (or a DOMDocument) and the URL to use as a base URL. Once you have a parser, there are a few other things you can do:\n\n### Selectively Parsing a Document\n\nThere are several ways to selectively parse microformats from a document. If you wish to only parse microformats from an element with a particular ID, `Parser::parseFromId($id) ` is the easiest way.\n\nIf your needs are more complex, `Parser::parse` accepts an optional context DOMNode as its second parameter. Typically you’d use `Parser::query` to run XPath queries on the document to get the element you want to parse from under, then pass it to `Parser::parse`. Example usage:\n\n```php\n$doc = 'More microformats, more microformats \u003cdiv id=\"parse-from-here\"\u003e\u003cspan class=\"h-card\"\u003eThis shows up\u003c/span\u003e\u003c/div\u003e yet more ignored content';\n$parser = new Mf2\\Parser($doc);\n\n$parser-\u003eparseFromId('parse-from-here'); // returns a document with only the h-card descended from div#parse-from-here\n\n$elementIWant = $parser-\u003equery('an xpath query')[0];\n\n$parser-\u003eparse(true, $elementIWant); // returns a document with only the Microformats under the selected element\n\n```\n\n### Experimental Language Parsing\n\nThere is still [ongoing brainstorming](http://microformats.org/wiki/microformats2-parsing-brainstorming#Parse_language_information) around how HTML language attributes should be added to the parsed result. In order to use this feature, you will need to set a flag to opt in.\n\n```php\n$doc = '\u003cdiv class=\"h-entry\" lang=\"sv\" id=\"postfrag123\"\u003e\n  \u003ch1 class=\"p-name\"\u003eEn svensk titel\u003c/h1\u003e\n  \u003cdiv class=\"e-content\" lang=\"en\"\u003eWith an \u003cem\u003eenglish\u003c/em\u003e summary\u003c/div\u003e\n  \u003cdiv class=\"e-content\"\u003eOch \u003cem\u003esvensk\u003c/em\u003e huvudtext\u003c/div\u003e\n\u003c/div\u003e';\n$parser = new Mf2\\Parser($doc);\n$parser-\u003elang = true;\n$result = $parser-\u003eparse();\n```\n\n```json\n{\n  \"items\": [\n    {\n      \"type\": [\"h-entry\"],\n      \"properties\": {\n        \"name\": [\"En svensk titel\"],\n        \"content\": [\n          {\n            \"html\": \"With an \u003cem\u003eenglish\u003c/em\u003e summary\",\n            \"value\": \"With an english summary\",\n            \"lang\": \"en\"\n          },\n          {\n            \"html\": \"Och \u003cem\u003esvensk\u003c/em\u003e huvudtext\",\n            \"value\": \"Och svensk huvudtext\",\n            \"lang\": \"sv\"\n          }\n        ]\n      },\n      \"lang\": \"sv\"\n    }\n  ],\n  \"rels\": {},\n  \"rel-urls\": {}\n}\n```\n\nNote that this option is still considered experimental and in development, and the parsed output may change between minor releases.\n\n### Generating output for JSON serialization with JSON-mode\n\nDue to a quirk with the way PHP arrays work, there is an edge case ([reported](https://github.com/microformats/php-mf2/issues/29) by Tom Morris) in which a document with no rel values, when serialised as JSON, results in an empty object as the rels value rather than an empty array. Replacing this in code with a stdClass breaks PHP iteration over the values.\n\nAs of version 0.2.6, the default behaviour is back to being PHP-friendly, so if you want to produce results specifically for serialisation as JSON (for example if you run a HTML -\u003e JSON service, or want to run tests against JSON fixtures), enable JSON mode:\n\n```php\n// …by passing true as the third constructor:\n$jsonParser = new Mf2\\Parser($html, $url, true);\n```\n\n### Classic Microformats Markup\n\nphp-mf2 has some support for parsing classic microformats markup. It’s enabled by default, but can be turned off by calling `Mf2\\parse($html, $url, false);` or `$parser-\u003eparse(false);` if you’re instantiating a parser yourself.\n\nIf the built in mappings don’t successfully parse some classic microformats markup, please raise an issue and we’ll fix it.\n\n## Security\n\n**No filtering of content takes place in mf2\\Parser, so treat its output as you would any untrusted data from the source of the parsed document.**\n\nSome tips:\n\n* All content apart from the 'html' key in dictionaries produced by parsing an `e-*` property is not HTML-escaped. For example, `\u003cspan class=\"p-name\"\u003e\u0026lt;code\u0026gt;\u003c/span\u003e` will result in `\"name\": [\"\u003ccode\u003e\"]`. At the very least, HTML-escape all properties before echoing them out in HTML\n* If you’re using the raw HTML content under the 'html' key of dictionaries produced by parsing `e-*` properties, you SHOULD purify the HTML before displaying it to prevent injection of arbitrary code. For PHP we recommend using [HTML Purifier](http://htmlpurifier.org)\n\n## Contributing\n\nIssues and bug reports are very welcome. If you know how to write tests then please do so as code always expresses problems and intent much better than English, and gives me a way of measuring whether or not fixes have actually solved your problem. If you don’t know how to write tests, don’t worry :) Just include as much useful information in the issue as you can.\n\nPull requests very welcome, please try to maintain stylistic, structural and naming consistency with the existing codebase, and don’t be too upset if we make naming changes :)\n\n### How to make a Pull Request\n\n1. Fork the repo to your github account\n2. Clone a copy to your computer (simply installing php-mf2 using composer only works for using it, not developing it)\n3. Install the dev dependencies with `composer install`.\n4. Run PHPUnit with `./vendor/bin/phpunit`\n6. Add PHPUnit tests for your changes, either in an existing test file if suitable, or a new one\n7. Make your changes\n8. Make sure your tests pass (`./vendor/bin/phpunit`) and that your code is compatible with all supported versions of PHP (`./vendor/bin/phpcs -p`)\n9. Go to your fork of the repo on github.com and make a pull request, preferably with a short summary, detailed description and references to issues/parsing specs as appropriate\n10. Bask in the warm feeling of having contributed to a piece of free software (optional)\n\n### Testing\n\nThere are currently two separate test suites: one, in `tests/Mf2`, is written in phpunit, containing many microformats parsing examples as well as internal parser tests and regression tests for specific issues over php-mf2’s history. Run it with `./vendor/bin/phpunit`. If you do not have a live internet connection, you can exclude tests that depend on it: `./vendor/bin/phpunit --exclude-group internet`.\n\nThe other, in `tests/test-suite`, is a custom test harness which hooks up php-mf2 to the cross-platform [microformats test suite](https://github.com/microformats/tests). To run these tests you must first install the tests with `./composer.phar install`. Each test consists of a HTML file and a corresponding JSON file, and the suite can be run with `php ./tests/test-suite/test-suite.php`.\n\nCurrently php-mf2 passes the majority of it’s own test case, and a good percentage of the cross-platform tests. Contributors should ALWAYS test against the PHPUnit suite to ensure any changes don’t negatively impact php-mf2, and SHOULD run the cross-platform suite, especially if you’re changing parsing behaviour.\n\n### Changelog\n\n#### v0.5.0\n\n**Breaking changes**:\n\n* Bumped minimum PHP version from 5.4 to 5.6 ([#220](https://github.com/microformats/php-mf2/issues/220))\n* [#214](https://github.com/microformats/php-mf2/issues/214) parse an img element for src and alt — i.e. all property values parsed as image URLs where the img element has an `alt` attribute will now be a `{'value': 'url', 'alt': 'the alt value'}` structure rather than a single URL string\n* Renamed `master` branch to `main`. Anyone who had been installing the latest development version with `dev-master` will need to change their requirements to `dev-main`\n\nOther changes:\n\n* [#195](https://github.com/microformats/php-mf2/issues/195) Fix backcompat parsing for geo property\n* [#182](https://github.com/microformats/php-mf2/issues/182) Fix parsing for iframe.u-*\\[src]\n* [#206](https://github.com/microformats/php-mf2/issues/206) Add optional ID for h-* elements\n* [#198](https://github.com/microformats/php-mf2/issues/198) reduce instances where photo is implied\n* Internal: switched from Travis to Github Actions for CI\n\n#### v0.4.6\n\nBugfixes:\n\n* Don't include img src attribute in implied p-name ([#180](https://github.com/microformats/php-mf2/issues/180))\n* Normalize ordinal dates in VCP values ([#167](https://github.com/microformats/php-mf2/issues/167))\n* Fix for accidental array access of stdClass in deeply nested structures ([#196](https://github.com/microformats/php-mf2/issues/196))\n* Reduce instances where u-url is implied according to a [spec update](http://microformats.org/wiki/index.php?title=microformats2-parsing\u0026diff=66887\u0026oldid=66871) ([#183](https://github.com/microformats/php-mf2/issues/183) and [parsing issue #36](https://github.com/microformats/microformats2-parsing/issues/36))\n* Fix for wrongly implied photo property ([#190](https://github.com/microformats/php-mf2/issues/190))\n\nOther Updates:\n\n* Adds a filter to avoid running tests that require a live internet connection ([#194](https://github.com/microformats/php-mf2/pull/194))\n* Refactor implied name code to match new implied name handling of photo and url ([#193](https://github.com/microformats/php-mf2/pull/193))\n* Moved this repo to the microformats GitHub organization ([#179](https://github.com/microformats/php-mf2/issues/179))\n\n\n#### v0.4.5\n\n2018-08-02\n\nBugfixes:\n\n* Fix for parsing empty `e-` elements\n\nOther Updates:\n\n* Added `.editorconfig` to the project and cleaned up whitespace across all files\n\n\n#### v0.4.4\n\n2018-08-01\n\nBugfixes:\n\n* Ensure empty `properties` is an object `{}` rather than array  `[]` ([#171](https://github.com/microformats/php-mf2/issues/171))\n* Ensure the parser does not mutate the DOMDOcument passed in ([#174](https://github.com/microformats/php-mf2/issues/174))\n* Fix for multiple class names in backcompat parsing ([#156](https://github.com/microformats/php-mf2/issues/156))\n\nMicroformats Parsing Updates:\n\n* New algorithm for plaintext values ([#168](https://github.com/microformats/php-mf2/pull/168) and [parsing issue #15](https://github.com/microformats/microformats2-parsing/issues/15))\n* Always resolve URLs from `u-` properties even when not from a link element ([Parsing issue #10](https://github.com/microformats/microformats2-parsing/issues/10))\n\nOther Updates:\n\n* Improved test coverage\n\n\n#### v0.4.3\n\n2018-03-29\n\nIf the [masterminds/html5](https://github.com/Masterminds/html5-php) HTML5 parser is available, the Mf2 parser will use that instead of the built-in HTML parser. This enables proper handling of HTML5 elements such as `\u003carticle\u003e`.\n\nTo include the HTML5 parser in your project, run:\n\n```\ncomposer require masterminds/html5\n```\n\n#### v0.4.2\n\n2018-03-29\n\nFixes:\n\n* [#165](https://github.com/microformats/php-mf2/pull/165) - Prevents inadvertently adding whitespace to the html value\n* [#158](https://github.com/microformats/php-mf2/issues/158) - Allows numbers in vendor prefixed names\n* [#160](https://github.com/microformats/php-mf2/issues/160) - Ignores class names with consecutive dashes\n* [#159](https://github.com/microformats/php-mf2/issues/159) - Remove duplicate values from type and rels arrays\n* [#162](https://github.com/microformats/php-mf2/pull/162) - Improved rel attribute parsing\n\nBackcompat:\n\n* [#157](https://github.com/microformats/php-mf2/issues/157) - Parse `rel=tag` as `p-category` for hEntry and hReview\n\n#### v0.4.1\n\n2018-03-15\n\nFixes:\n\n* [#153](https://github.com/microformats/php-mf2/issues/153) - Fixes parsed timestamps authored with a Z timezone offset\n* [#151](https://github.com/microformats/php-mf2/issues/151) - Adds back \"value\" of nested microformats when no matching property exists\n\n\n#### v0.4.0\n\n2018-03-13\n\nBreaking changes:\n\n* [#125](https://github.com/microformats/php-mf2/pull/125) - Add `rel-urls` to parsed result. Removes `alternates` by default but still available behind a feature flag.\n* [#142](https://github.com/microformats/php-mf2/pull/142) - Reduce instances of implied `p-name`. See Microformats issue [#6](https://github.com/microformats/microformats2-parsing/issues/6). This means it is now possible for the parsed result to *not* have a `name` property, whereas before there was always a `name` property on an object. Make sure consuming code can handle an object without a name now.\n\nFixes:\n\n* [#124](https://github.com/microformats/php-mf2/pull/124) - Fix for experimental lang parsing\n* [#127](https://github.com/microformats/php-mf2/issues/127) - Fix for parsing `h-*` class names containing invalid characters.\n* [#131](https://github.com/microformats/php-mf2/pull/131) - Improved `dt-` parsing. Issues [#126](https://github.com/microformats/php-mf2/issues/126) and [#115](https://github.com/microformats/php-mf2/issues/115).\n* [#130](https://github.com/microformats/php-mf2/issues/130) - Fix for implied properties with empty attributes.\n* [#135](https://github.com/microformats/php-mf2/issues/135) - Trim leading and tailing whitespace from HTML value as well as text value.\n* [#137](https://github.com/microformats/php-mf2/issues/137) - Fix backcompat hfeed parsing.\n* [#134](https://github.com/microformats/php-mf2/issues/134) - Fix `rel=bookmark` backcompat parsing.\n* [#116](https://github.com/microformats/php-mf2/issues/116) - Fix backcompat parsing for `summary` property in `hreview`\n* [#149](https://github.com/microformats/php-mf2/issues/149) - Fix for datetime parsing, no longer tries to interpret the value and passes through instead\n\n#### v0.3.2\n\n2017-05-27\n\n* Fixed how the Microformats tests repo is loaded via composer\n* Moved experimental language parsing feature behind an opt-in flag\n* [#121](https://github.com/microformats/php-mf2/pull/121) Fixed language detection to support parsing of HTML fragments\n\n#### v0.3.1\n\n2017-05-24\n\n* [#89](https://github.com/microformats/php-mf2/issues/89) - Fixed parsing empty `img alt=\"\"` attributes\n* [#91](https://github.com/microformats/php-mf2/issues/91) - Ignore rel values from HTML tags that don't allow rel values\n* [#57](https://github.com/microformats/php-mf2/issues/57) - Implement hAtom rel=bookmark backcompat\n* [#94](https://github.com/microformats/php-mf2/pull/94) - Fixed HTML output when parsing e-* properties\n* [#97](https://github.com/microformats/php-mf2/pull/97) - Experimental language parsing\n* [#88](https://github.com/microformats/php-mf2/issues/88) - Fix for implied photo parsing\n* [#102](https://github.com/microformats/php-mf2/pull/102) - Ignore classes with numbers or capital letters\n* [#111](https://github.com/microformats/php-mf2/pull/111) - Improved backcompat parsing\n* [#106](https://github.com/microformats/php-mf2/issues/106) - Send `Accept: text/html` header when using the `fetch` method\n* [#114](https://github.com/microformats/php-mf2/issues/114) - Parse `poster` attribute for `video` tags\n* [#118](https://github.com/microformats/php-mf2/issues/118) - Fixes parsing elements with missing attributes\n* Tests now use [microformats/tests](https://github.com/microformats/tests) repo\n\nMany thanks to @gRegorLove for the major overhaul of the backcompat parsing!\n\n#### v0.3.0\n\n2016-03-14\n\n* Requires PHP 5.4 at minimum (PHP 5.3 is EOL)\n* Licensed under CC0 rather than MIT\n* Merges Pull requests #70, #73, #74, #75, #77, #80, #82, #83, #85 and #86.\n* Variety of small bug fixes and features including improved whitespace support, removal of style and script contents from plaintext properties\n* All PHPUnit tests passing finally\n\nMany thanks to @aaronpk, @diplix, @dissolve, @dymcx @gRegorLove, @jeena, @veganstraightedge and @voxpelli for all your hard work opening issues and sending and merging PRs!\n\n#### v0.2.12\n\n2015-07-12\n\n* Merges pull requests [#65](https://github.com/microformats/php-mf2/pull/65), [#66](https://github.com/microformats/php-mf2/pull/66) and [#67](https://github.com/microformats/php-mf2/pull/67).\n* Fixes issue [#64](https://github.com/microformats/php-mf2/issues/64).\n\nMany thanks to @aaronpk, @gRegorLove and @kylewm for contributions, @aaronpk and @kevinmarks for PR management and @tantek for issue reporting!\n\n#### v0.2.11\n\n2015-07-10\n\n#### v0.2.10\n\n2015-04-29\n\n* Merged [#58](https://github.com/microformats/php-mf2/pull/58), fixing some parsing bugs and adding support for area element parsing. Thanks so much for your hard work and patience, \u003ca class=\"h-card\" href=\"http://ben.thatmustbe.me/\"\u003eBen\u003c/a\u003e!\n\n#### v0.2.9\n\n2014-08-06\n\n* Added backcompat classmap for hProduct, associated tests\n* Started GPG signing version tags as barnaby@waterpigs.co.uk, fingerprint CBC7 7876 BF7C 9637 B6AE 77BA 7D49 834B 0416 CFA3\n\n#### v0.2.8\n\n2014-07-17\n\n* Fixed issue #51 causing php-mf2 to not work with PHP 5.3\n* Fixed issue #52 correctly handling the `\u003ctemplate\u003e` element by ignoring it\n* Fixed issue #53 improving the plaintext parsing of `\u003cimg\u003e` elements\n\n#### v0.2.7\n\n2014-06-18\n\n* Added `Mf2\\fetch()` which fetches content from a URL and returns parsed microformats\n* Added implied `dt-end` discovery (thanks for all your hard work, @gRegorLove!)\n* Fixed issue causing classnames like `blah e- blah` to produce properties with numeric keys (thanks @aaronpk and @gRegorLove)\n* Fixed issue causing resolved URLs to not include port numbers (thanks @aaronpk)\n\n#### v0.2.6\n\n* Added JSON mode as long-term fix for #29\n* Fixed bug causing microformats nested under multiple property names to be parsed only once\n\n#### v0.2.5\n\n* Removed conditional replacing empty rel list with stdclass. Original purpose was to make JSON-encoding the output from the parser correct but it also caused Fatal Errors due to trying to treat stdclass as array.\n\n#### v0.2.4\n\n#### v0.2.3\n\n* Made p-* parsing consistent with implied name parsing\n* Stopped collapsing whitespace in p-* properties\n* Implemented unicodeTrim which removes \u0026nbsp; characters as well as regex \\s\n* Added support for implied name via abbr[title]\n* Prevented excessively nested value-class elements from being parsed incorrectly, removed incorrect separator which was getting added in some cases\n* Updated u-* parsing to be spec-compliant, matching [href] before value-class and only attempting URL resolution for URL attributes\n* Added support for input[value] parsing\n* Tests for all the above\n\n#### v0.2.2\n\n* Made resolveUrl method public, allowing advanced parsers and subclasses to make use of it\n* Fixed bug causing multiple duplicate property values to appear\n\n#### v0.2.1\n\n* Fixed bug causing classic microformats property classnames to not be parsed correctly\n\n#### v0.2.0 (BREAKING CHANGES)\n\n* Namespace change from mf2 to Mf2, for PSR-0 compatibility\n* `Mf2\\parse()` function added to simplify the most common case of just parsing some HTML\n* Updated e-* property parsing rules to match mf2 parsing spec — instead of producing inconsistent HTML content, it now produces dictionaries like \u003cpre\u003e\u003ccode\u003e\n{\n  \"html\": \"\u003cb\u003eThe Content\u003c/b\u003e\",\n  \"value: \"The Content\"\n}\n\u003c/code\u003e\u003c/pre\u003e\n* Removed `htmlSafe` options as new e-* parsing rules make them redundant\n* Moved a whole load of static functions out of the class and into standalone functions\n* Changed autoloading to always include Parser.php instead of using classmap\n\n#### v0.1.23\n\n* Made some changes to the way back-compatibility with classic microformats are handled, ignoring classic property classnames inside mf2 roots and outside classic roots\n* Deprecated ability to add new classmaps, removed twitter classmap. Use [php-mf2-shim](http://github.com/microformats/php-mf2-shim) instead, it’s better\n\n#### v0.1.22\n\n* Converts classic microformats by default\n\n#### v0.1.21\n\n* Removed webignition dependency, also removing ext-intl dependency. php-mf2 is now a standalone, single file library again\n* Replaced webignition URL resolving with custom code passing almost all tests, courtesy of \u003ca class=\"h-card\" href=\"http://aaronparecki.com\"\u003eAaron Parecki\u003c/a\u003e\n\n#### v0.1.20\n\n* Added in almost-perfect custom URL resolving code\n\n#### v0.1.19 (2013-06-11)\n\n* Required stable version of webigniton/absolute-url-resolver, hopefully resolving versioning problems\n\n#### v0.1.18 (2013-06-05)\n\n* Fixed problems with isElementParsed, causing elements to be incorrectly parsed\n* Cleaned up some test files\n\n#### v0.1.17\n\n* Rewrote some PHP 5.4 array syntax which crept into 0.1.16 so php-mf2 still works on PHP 5.3\n* Fixed a bug causing weird partial microformats to be added to parent microformats if they had doubly property-nested children\n* Finally actually licensed this project under a real license (MIT, in composer.json)\n* Suggested barnabywalters/mf-cleaner in composer.json\n\n#### v0.1.16\n\n* Ability to parse from only an ID\n* Context DOMElement can be passed to $parse\n* Parser::query runs XPath queries on the current document\n* When parsing e-* properties, elements with @src, @data or @href have relative URLs resolved in the output\n\n#### v0.1.15\n\n* Added html-safe options\n* Added rel+rel-alternate parsing\n\n\n## License\n\nphp-mf2 is dedicated to the public domain using Creative Commons -- CC0 1.0 Universal.\n\nhttp://creativecommons.org/publicdomain/zero/1.0\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicroformats%2Fphp-mf2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicroformats%2Fphp-mf2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicroformats%2Fphp-mf2/lists"}