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

Fix parsing class properties with newlines #245

Closed
gRegorLove opened this issue Oct 8, 2022 · 0 comments · Fixed by #248
Closed

Fix parsing class properties with newlines #245

gRegorLove opened this issue Oct 8, 2022 · 0 comments · Fixed by #248
Assignees

Comments

@gRegorLove
Copy link
Member

Tracked this one down via indieweb/indiewebify-me#102. Initially I thought that issue was due to the php-mf2 version (it did need to be updated), but I realized once I parsed with php-mf2 0.5.0, the p-name was not being found when there's new lines between the classes.

I tried a several variations based on that source HTML and came up with some minimal tests:

<div class="h-entry">
<h1 class="post_title__text
p-name">Page Title</h1>
<p class="p-summary">A summary so the p-name won't be implied. This test demonstrates p-name is not being parsed.</p>
</div>

Parsed result with 0.5.0:

{
    "items": [
        {
            "type": [
                "h-entry"
            ],
            "properties": {
                "summary": [
                    "A summary so the p-name won't be implied. This test demonstrates p-name is not being parsed."
                ]
            }
        }
    ],
    "rels": {},
    "rel-urls": {},
    "debug": {
        "package": "https://packagist.org/packages/mf2/mf2",
        "source": "https://github.com/indieweb/php-mf2",
        "version": "v0.5.0",
        "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",
            "Using the Masterminds HTML5 parser"
        ]
    }
}

And with implied p-name parsing:

<div class="h-entry">
<h1 class="post_title__text
p-name">Page Title</h1>
<p> Here is some content without microformats. If the parser does not find p-name above, it will try to imply p-name, which will include this text as well. </p>
<p> implied p-name parsing will occur if the parser doesn't find any p-* or e-* properties. </p>
</div>

Parsed result with php-mf2 0.5.0

{
    "items": [
        {
            "type": [
                "h-entry"
            ],
            "properties": {
                "name": [
                    "Page Title\nHere is some content without microformats. If the parser does not find p-name above, it will try to imply p-name, which will include this text as well.\nimplied p-name parsing will occur if the parser doesn't find any p-* or e-* properties."
                ]
            }
        }
    ],
    "rels": {},
    "rel-urls": {},
    "debug": {
        "package": "https://packagist.org/packages/mf2/mf2",
        "source": "https://github.com/indieweb/php-mf2",
        "version": "v0.5.0",
        "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",
            "Using the Masterminds HTML5 parser"
        ]
    }
}
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

Successfully merging a pull request may close this issue.

1 participant