diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 7048794..c436c2d 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -1166,7 +1166,8 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf = } } - // Make sure things are in alphabetical order + // Make sure things are unique and in alphabetical order + $mfTypes = array_unique($mfTypes); sort($mfTypes); // Phew. Return the final result. diff --git a/tests/Mf2/ParserTest.php b/tests/Mf2/ParserTest.php index e5767ab..8d1304b 100644 --- a/tests/Mf2/ParserTest.php +++ b/tests/Mf2/ParserTest.php @@ -766,5 +766,15 @@ public function testMfClassRegex() { $this->assertArrayHasKey('123-url', $output['items'][0]['properties']); } + /** + * @see https://github.com/microformats/microformats2-parsing/issues/30 + */ + public function testUniqueAndAlphabeticalMfClasses() { + $input = '
'; + $output = Mf2\parse($input); + + $this->assertEquals(array('h-cite', 'h-entry'), $output['items'][0]['type']); + } + }