Browse Source

Collapse child into e- properly

master
J. King 11 months ago
parent
commit
682dcf576b
  1. 12
      lib/Parser.php
  2. 11
      tests/cases/third-party/phpmf2/classic/hreview.html
  3. 93
      tests/cases/third-party/phpmf2/classic/hreview.json

12
lib/Parser.php

@ -521,19 +521,19 @@ class Parser {
if ($child) {
if ($prefix === "p" && isset($child['properties']['name'])) {
# if it's a p-* property element, use the first p-name of the h-* child
$childValue = $child['properties']['name'][0];
$childValue = ['value' => $child['properties']['name'][0]];
} elseif ($prefix === "e") {
# else if it's an e-* property element, re-use its { } structure with existing value: inside.
$childValue = $value['value'];
// NOTE: This is misleading; the 'value' and 'html' keys should both be copied over
$childValue = ['value' => $value['value'], 'html' => $value['html']];
} elseif ($prefix === "u" && isset($child['properties']['url'])) {
# else if it's a u-* property element and the h-* child has a u-url, use the first such u-url
$childValue = $child['properties']['url'][0];
$childValue = ['value' => $child['properties']['url'][0]];
} else {
# else use the parsed property value per p-*,u-*,dt-* parsing respectively
$childValue = $value;
$childValue = ['value' => $value];
}
$value = $child;
$value['value'] = $childValue;
$value = array_merge($childValue, $child);
$childValue = null;
}
if ($defer) {

11
tests/cases/third-party/phpmf2/classic/hreview.html

@ -0,0 +1,11 @@
<div class="hreview">
<span><span class="rating">5</span> out of 5 stars</span>
<h4 class="summary">Crepes on Cole is awesome</h4>
<span class="reviewer vcard">Reviewer: <span class="fn">Tantek</span> -
<abbr class="dtreviewed" title="2005-04-18">April 18, 2005</abbr></span>
<div class="description item vcard">
<p> <span class="fn org">Crepes on Cole</span> is one of the best little creperies in <span class="adr"><span class="locality">San Francisco</span></span>. Excellent food and service. Plenty of tables in a variety of sizes for parties large and small. Window seating makes for excellent people watching to/from the N-Judah which stops right outside. I've had many fun social gatherings here, as well as gotten plenty of work done thanks to neighborhood WiFi. </p>
</div>
<p>Visit date: <span>April 2005</span></p>
<p>Food eaten: <span>Florentine crepe</span></p>
</div>

93
tests/cases/third-party/phpmf2/classic/hreview.json

@ -0,0 +1,93 @@
{
"items": [
{
"type": [
"h-review"
],
"properties": {
"rating": [
"5"
],
"name": [
"Crepes on Cole is awesome"
],
"author": [
{
"value": "Tantek",
"type": [
"h-card"
],
"properties": {
"name": [
"Tantek"
]
}
}
],
"content": [
{
"value": "Crepes on Cole is one of the best little creperies in San Francisco. Excellent food and service. Plenty of tables in a variety of sizes for parties large and small. Window seating makes for excellent people watching to/from the N-Judah which stops right outside. I've had many fun social gatherings here, as well as gotten plenty of work done thanks to neighborhood WiFi.",
"type": [
"h-card"
],
"properties": {
"name": [
"Crepes on Cole"
],
"org": [
"Crepes on Cole"
],
"adr": [
{
"value": "San Francisco",
"type": [
"h-adr"
],
"properties": {
"locality": [
"San Francisco"
]
}
}
]
},
"html": "<p> <span class=\"fn org\">Crepes on Cole</span> is one of the best little creperies in <span class=\"adr\"><span class=\"locality\">San Francisco</span></span>. Excellent food and service. Plenty of tables in a variety of sizes for parties large and small. Window seating makes for excellent people watching to/from the N-Judah which stops right outside. I've had many fun social gatherings here, as well as gotten plenty of work done thanks to neighborhood WiFi. </p>"
}
],
"item": [
{
"value": "Crepes on Cole",
"type": [
"h-card"
],
"properties": {
"name": [
"Crepes on Cole"
],
"org": [
"Crepes on Cole"
],
"adr": [
{
"value": "San Francisco",
"type": [
"h-adr"
],
"properties": {
"locality": [
"San Francisco"
]
}
}
]
}
}
]
}
}
],
"rels": {
},
"rel-urls": {
}
}
Loading…
Cancel
Save