metaformats: Difference between revisions
(→Background: prior) |
(split backcompat metaformats from explicit mf2 metaformats, per https://github.com/microformats/microformats2-parsing/issues/75 request from implementor, and in consideration of reducing chance of an unexpected (possibly worse) new first root microformat in parsed documents) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
<dfn style="font-style:normal;font-weight:bold">[[metaformats]]</dfn> is an extension to the [[microformats2-parsing]] for parsing [[invisible data]] published in HTML <code>meta</code> tags, both with an explicit methodology, and for backward compatibility with existing vocabularies that have multiple testable interoperable implementations. | <dfn style="font-style:normal;font-weight:bold">[[metaformats]]</dfn> is an extension to the [[microformats2-parsing]] for parsing [[invisible data]] published in HTML <code>meta</code> tags, both with an explicit methodology, and for backward compatibility with existing vocabularies that have multiple testable interoperable implementations. | ||
:This is a '''Living Specification''' that is subject to change as research discovers meta tag vocabularies in wide use and consumed by multiple implementations | :This is a '''Living Specification''' that is subject to change as research discovers meta tag vocabularies in wide use and consumed by multiple implementations. This specification has no stable portions. Features are untested, unless explicitly labeled stable, draft, or proposed, or in stable, draft, or proposed sections. All features are likely to change. Stable features are possible, and thus this living specification may eventually document some. When stable features are documented, substantive changes may be proposed by issues and errata filed in response to implementation experience, requiring consensus among participating implementers as part of an explicit to be defined change control <!--[[#change_control|change control]]--> process. | ||
;<span id="participate">Participate</span> | ;<span id="participate">Participate</span> | ||
:[https://github.com/microformats/metaformats/issues Open Issues] | :[https://github.com/microformats/metaformats/issues Open Issues] | ||
Line 18: | Line 18: | ||
For each of the following subsections, apply the changes therein to the steps in the same subsection in the [[microformats2-parsing]] specification. | For each of the following subsections, apply the changes therein to the steps in the same subsection in the [[microformats2-parsing]] specification. | ||
=== parse | === parse a document for microformats === | ||
Change the line "start with an empty JSON…" to: | |||
* start with an empty JSON "items" array and hashes "meta-item", "rels", "rel-urls": | |||
Update the JSON sample data structure to: | |||
<syntaxhighlight lang=json> | |||
{ | |||
"items": [], | |||
"meta-item": {}, | |||
"rels": {}, | |||
"rel-urls": {} | |||
} | |||
</syntaxhighlight> | |||
Before the line "* return the resulting JSON", insert: | |||
* parse the <code>head</code> element for backcompat metaformats | |||
* | |||
* | |||
=== parsing an element for properties === | === parsing an element for properties === | ||
Line 54: | Line 48: | ||
* else if <code>meta.dt-x[content]</code>, then return the <code>content</code> attribute | * else if <code>meta.dt-x[content]</code>, then return the <code>content</code> attribute | ||
== | === parse the head element for backcompat metaformats === | ||
After the section "parse an img element for src and alt", insert a new sibling section: | |||
* if <code>meta[property="og:title"]</code>, parse <code>content</code> attribute as <code>p-name</code> | <pre>=== parse the head element for backcompat metaformats ===</pre> | ||
* else <code>meta[name="twitter:title"]</code>, parse <code>content</code> as <code>p-name</code> | |||
* if <code>meta[property="og:description"]</code>, parse <code>content</code> as <code>p-summary</code> | With the following instructions: | ||
* else <code>meta[name="twitter:description"]</code>, parse <code>content</code> as <code>p-summary</code> | |||
* if <code>meta[property="og:image"]</code>, parse <code>content</code> as <code>u-photo</code> | * if there were no root class names found on the <code>html</code> and <code>head</code> elements | ||
* else <code>meta[name="twitter:image"]</code>, parse <code>content</code> as <code>u-photo</code> | ** if there is a <code>meta[property=og:type]</code> then | ||
* if <code>meta[property="og:video"]</code>, parse <code>content</code> as <code>u-video</code> | *** get that meta element’s <code>content</code> attribute value | ||
* if <code>meta[property="og:audio"]</code>, parse <code>content</code> as <code>u-audio</code> | *** if it’s "article" then set the meta-item "type" property to "entry" | ||
* if <code>meta[property="article:published_time"]</code>, parse <code>content</code> as <code>dt-published</code> | *** if it’s "profile" then set the meta-item "type" property to "card" | ||
* if <code>meta[property="article:modified_time"]</code>, parse <code>content</code> as <code>dt-updated</code> | *** if it's "music" or "video" then set the meta-item "type" property to "cite" | ||
* if <code>meta[property="article:author"]</code>, parse <code>content</code> as <code>p-author</code> | ** end if | ||
** if there is no meta-item "type" property value and there is a <code>meta[name=twitter:card]</code> then | |||
*** get that meta element’s <code>content</code> attribute value | |||
*** if it's "summary" or "summary_large_image" then set the meta-item "type" property to "entry" | |||
** end if | |||
** if there is no meta-item "type" property value and | |||
*** there is a <code>meta[property^=og:]</code> or <code>meta[name^=twitter:]</code> | |||
** then set the meta-item "type" property to "entry" | |||
** parse <code>meta</code> elements for backcompat properties as follows and add them to a "properties" hash inside the "meta-item" hash: | |||
*** if <code>meta[property="og:title"]</code>, parse <code>content</code> attribute as <code>p-name</code> | |||
*** else <code>meta[name="twitter:title"]</code>, parse <code>content</code> as <code>p-name</code> | |||
*** if <code>meta[property="og:description"]</code>, parse <code>content</code> as <code>p-summary</code> | |||
*** else if <code>meta[name="twitter:description"]</code>, parse <code>content</code> as <code>p-summary</code> | |||
*** if <code>meta[property="og:image"]</code>, parse <code>content</code> as <code>u-photo</code> | |||
*** else if <code>meta[name="twitter:image"]</code>, parse <code>content</code> as <code>u-photo</code> | |||
*** if <code>meta[property="og:video"]</code>, parse <code>content</code> as <code>u-video</code> | |||
*** if <code>meta[property="og:audio"]</code>, parse <code>content</code> as <code>u-audio</code> | |||
*** if <code>meta[property="article:published_time"]</code>, parse <code>content</code> as <code>dt-published</code> | |||
*** if <code>meta[property="article:modified_time"]</code>, parse <code>content</code> as <code>dt-updated</code> | |||
*** if <code>meta[property="article:author"]</code>, parse <code>content</code> as <code>p-author</code> | |||
** end if /* parse meta elements for backcompat properties */ | |||
* end if /* no root class names found on html and head */ | |||
== Background == | == Background == | ||
Line 77: | Line 92: | ||
== See Also == | == See Also == | ||
* [[microformats2-parsing]] | * [[microformats2-parsing]] | ||
* [[meta]] |
Latest revision as of 00:36, 2 December 2023
metaformats is an extension to the microformats2-parsing for parsing invisible data published in HTML meta
tags, both with an explicit methodology, and for backward compatibility with existing vocabularies that have multiple testable interoperable implementations.
- This is a Living Specification that is subject to change as research discovers meta tag vocabularies in wide use and consumed by multiple implementations. This specification has no stable portions. Features are untested, unless explicitly labeled stable, draft, or proposed, or in stable, draft, or proposed sections. All features are likely to change. Stable features are possible, and thus this living specification may eventually document some. When stable features are documented, substantive changes may be proposed by issues and errata filed in response to implementation experience, requiring consensus among participating implementers as part of an explicit to be defined change control process.
- Participate
- Open Issues
- IRC
- License
- Per CC0, to the extent possible under law, the editors have waived all copyright and related or neighboring rights to this work. In addition, as of 2024-11-22, the editors have made this specification available under the Open Web Foundation Agreement Version 1.0.
- Initial publication
- 2022-04-01
algorithm changes
For each of the following subsections, apply the changes therein to the steps in the same subsection in the microformats2-parsing specification.
parse a document for microformats
Change the line "start with an empty JSON…" to:
- start with an empty JSON "items" array and hashes "meta-item", "rels", "rel-urls":
Update the JSON sample data structure to:
{
"items": [],
"meta-item": {},
"rels": {},
"rel-urls": {}
}
Before the line "* return the resulting JSON", insert:
- parse the
head
element for backcompat metaformats
parsing an element for properties
parsing a p- property
insert before "else return the textContent of the element after …":
- else if
meta.p-x[content]
, then return thecontent
attribute
parsing a u- property
insert before "else return the textContent of the element after …":
- else if
meta.u-x[content]
, then get thecontent
attribute
parsing a dt- property
insert before "else return the textContent of the element after …":
- else if
meta.dt-x[content]
, then return thecontent
attribute
parse the head element for backcompat metaformats
After the section "parse an img element for src and alt", insert a new sibling section:
=== parse the head element for backcompat metaformats ===
With the following instructions:
- if there were no root class names found on the
html
andhead
elements- if there is a
meta[property=og:type]
then- get that meta element’s
content
attribute value - if it’s "article" then set the meta-item "type" property to "entry"
- if it’s "profile" then set the meta-item "type" property to "card"
- if it's "music" or "video" then set the meta-item "type" property to "cite"
- get that meta element’s
- end if
- if there is no meta-item "type" property value and there is a
meta[name=twitter:card]
then- get that meta element’s
content
attribute value - if it's "summary" or "summary_large_image" then set the meta-item "type" property to "entry"
- get that meta element’s
- end if
- if there is no meta-item "type" property value and
- there is a
meta[property^=og:]
ormeta[name^=twitter:]
- there is a
- then set the meta-item "type" property to "entry"
- parse
meta
elements for backcompat properties as follows and add them to a "properties" hash inside the "meta-item" hash:- if
meta[property="og:title"]
, parsecontent
attribute asp-name
- else
meta[name="twitter:title"]
, parsecontent
asp-name
- if
meta[property="og:description"]
, parsecontent
asp-summary
- else if
meta[name="twitter:description"]
, parsecontent
asp-summary
- if
meta[property="og:image"]
, parsecontent
asu-photo
- else if
meta[name="twitter:image"]
, parsecontent
asu-photo
- if
meta[property="og:video"]
, parsecontent
asu-video
- if
meta[property="og:audio"]
, parsecontent
asu-audio
- if
meta[property="article:published_time"]
, parsecontent
asdt-published
- if
meta[property="article:modified_time"]
, parsecontent
asdt-updated
- if
meta[property="article:author"]
, parsecontent
asp-author
- if
- end if /* parse meta elements for backcompat properties */
- if there is a
- end if /* no root class names found on html and head */
Background
The following prior work was used to develop this specification: