php-mf2 icon indicating copy to clipboard operation
php-mf2 copied to clipboard

hreview backcompat

Open kartikprabhu opened this issue 7 years ago • 5 comments

php-mf2 does not do hreview backcompat see: http://microformats.org/wiki/h-review#Parser_Compatibility

Example

HTML

    <article class="hreview">
<a class="url" href="http://example.com">URL</a>
    </article>

Current Output

    "items": [
        {
            "type": [
                "h-review"
            ],
            "properties": []
        }
    ]

Expected output

    "items": [
        {
            "type": [
                "h-review"
            ], 
            "properties": {
                "url": [
                    "http://example.com"
                ]
            }
        }
    ]

kartikprabhu avatar Mar 17 '18 21:03 kartikprabhu

A more complete, contrived example:

<article class="hreview">
	<h1> Review of <a class="url fn" href="http://example.com/product">Product</a> </h1>
	<p> <span class="rating">5</span> stars on a scale of <span class="worst">0</span> to <span class="best">5</span> </p>
	<img src="product.jpg" class="photo"/>
	<p class="summary">review summary</p>
	<div class="description"><p>Review description</p></div>
	<p> Reviewed by <span class="reviewer">John Doe</span> <abbr class="dtreviewed" title="2018-03-17">March 17, 2018</abbr> </p>
	<p> Tagged: <a href="/tag/reviews" rel="tag">Reviews</a> </p>
	<p> <a href="/review-permalink" rel="self bookmark">Permalink</a> </p>
</article>

Parsed:

{
    "items": [
        {
            "type": [
                "h-review"
            ],
            "properties": {
                "rating": [
                    "5"
                ],
                "worst": [
                    "0"
                ],
                "best": [
                    "5"
                ],
                "name": [
                    "review summary"
                ],
                "published": [
                    "2018-03-17"
                ],
                "content": [
                    {
                        "html": "<p>Review description</p>",
                        "value": "Review description"
                    }
                ],
                "author": [
                    {
                        "type": [
                            "h-card"
                        ],
                        "properties": {
                            "name": [
                                "John Doe"
                            ]
                        },
                        "value": "John Doe"
                    }
                ]
            }
        }
    ],
    "rels": {
        "tag": [
            "/tag/reviews"
        ],
        "self": [
            "/review-permalink"
        ],
        "bookmark": [
            "/review-permalink"
        ]
    },
    "rel-urls": {
        "/tag/reviews": {
            "text": "Reviews",
            "rels": [
                "tag"
            ]
        },
        "/review-permalink": {
            "text": "Permalink",
            "rels": [
                "self",
                "bookmark"
            ]
        }
    },
    "debug": {
        "package": "https://packagist.org/packages/mf2/mf2",
        "version": "v0.4.1",
        "note": [
            "This output was generated from the php-mf2 library available at https://github.com/indieweb/php-mf2",
            "Please file any issues with the parser at https://github.com/indieweb/php-mf2/issues"
        ]
    }
}
  • fn, photo, and url not correctly parsing as properties of p-item h-item
  • rel=tag and rel="self bookmark" not being upgraded to properties

I'll work on the fix.

gRegorLove avatar Mar 17 '18 22:03 gRegorLove

Also, I believe the expected output of @kartikprabhu's original example is:

"items": [
    {
        "type": [
            "h-review"
        ],
        "properties": {
            "item": [
                {
                    "type": [
                        "h-item"
                    ],
                    "properties": {
                        "url": [
                            "http://example.com"
                        ]
                    },
                    "value": "http://example.com"
                }
            ]
        }
    }
]

gRegorLove avatar Mar 17 '18 22:03 gRegorLove

This is currently awaiting examples in the wild of hReview with fn, photo, or url properties that are not nested in an item. I've been working through hReview Examples in the wild and have not found any yet. I have also had difficulty tracking down in the history of the hReview spec where it instructed to author those properties that way. If we don't find examples of this in the wild, I don't think we need to add it. If that's the case, h-review backcompat might need to be updated.

I haven't looked for examples in the wild for rel="self bookmark" yet.

The rel=tag parsing is fixed now in 0.4.2.

gRegorLove avatar Mar 29 '18 17:03 gRegorLove

#234 appears to have mostly fixed this, though I noticed the reviewer backcompat to p-author h-card is missing the name in the properties, so still need to address that:

    "items": [
        {
            "type": [
                "h-review"
            ],
            "properties": {
                "rating": [
                    "5"
                ],
                "worst": [
                    "0"
                ],
                "best": [
                    "5"
                ],
                "name": [
                    "review summary"
                ],
                "category": [
                    "reviews"
                ],
                "published": [
                    "2018-03-17"
                ],
                "content": [
                    {
                        "html": "<p>Review description<\/p>",
                        "value": "Review description"
                    }
                ],
                "author": [
                    {
                        "type": [
                            "h-card"
                        ],
                        "properties": [],
                        "value": "John Doe"
                    }
                ]
            }
        }
    ]

gRegorLove avatar Jul 08 '22 05:07 gRegorLove

I have a PR in progress for this.

gRegorLove avatar Sep 28 '22 17:09 gRegorLove