Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

author backcompat: always vcard? #13

Open
sknebel opened this issue Sep 13, 2018 · 1 comment
Open

author backcompat: always vcard? #13

sknebel opened this issue Sep 13, 2018 · 1 comment

Comments

@sknebel
Copy link
Member

sknebel commented Sep 13, 2018

http://microformats.org/wiki/h-entry#Parser_Compatibility says

author - including compat root vcard in the absence of h-card

I interpret this as "parse as if there was a vcard class on the author, even if there isn't", which during parsing then gets converted to an h-card. This produces a suboptimal result when the author property is only a string: the assumed vcard then has no properties (since implied name doesn't exist in mf1), resulting in a case like this:

  <article class="hentry">
    <span class="author">Tom Morris</span>
    [....]
  </article>

parses as

{
  "type": ["h-entry"],
  "properties":  {
    "author": [{
      "type": ["h-card"], 
      "properties": { }, 
      "value": "Tom Morris"
    }]
…

Is this understanding correct?

IMHO a preferable result would be

{
  "type": ["h-entry"],
  "properties":  {
    "author": ["Tom Morris"]
…

which would result if the author property were just parsed as a p- property: If there's a nested vcard, it gets parsed and converted, otherwise it just parses to a string.

@tantek
Copy link
Member

tantek commented Dec 24, 2018

This is a misintepretation of the backcompat portion of the spec.

Everything in the compat rules means “look for”.

In this case, “author - including compat root vcard in the absence of h-card” means to look for an “author” class name, including looking for a “vcard” class name on the same element, only if there is no “h-card” class name on the same element.

Thus yes, according to the spec, the code snippet:

<span class="author">Tom Morris</span>

Inside an hentry as noted above must be treated like:

<span class="p-author">Tom Morris</span>

And thus in the parsed JSON it becomes a simple "author": ["Tom Morris"] as noted as a “preferable result”.

If you can suggest wording that would help clarify this in the spec, I would be happy to make an editorial change to make this more explicitly clear (as well as similar for h-event location).

(Originally published at: http://tantek.com/2018/358/t1/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants