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

parse other JSON-LD elements if the first one is not of a recognized type #713

Merged
merged 2 commits into from
Nov 3, 2021

Conversation

michaldvorak79
Copy link
Contributor

One more proposed change regarding JSON-LD. I noticed that the "engadget" test case is not working optimally. The expected-metadata.json file expectes byline to be null. But the source.html actually contains byline information in a JSON-LD element: "Devindra Hardawar".

The problem is that there are two JSON-LD elements. The first one has type "Review" which Readability doesn't recognize. The second one is "Article", which it recognizes. However, Readability only checks the first JSON-LD element "Review" and when it sees unsupported type, it gives up.

My proposal is to keep going through the JSON-LD elements until we find one we support. I implemented it in this change request and I changed the byline in engadget/expected-metadata.json to contain the actual author's name. All unit tests are passing and lint doesn't complain, so I hope I did it correctly.

@gijsk
Copy link
Contributor

gijsk commented Nov 3, 2021

This makes sense to me and looks good - thanks for the patch! There were some conflicts with your other patch, which I've attempted to resolve. Just checking that tests pass (ie that I didn't screw it up) and then I'll merge this in.

@gijsk gijsk merged commit 7d4c939 into mozilla:master Nov 3, 2021
@michaldvorak79
Copy link
Contributor Author

There were some conflicts with your other patch, which I've attempted to resolve.

Sorry about that, I was worried that would be the case. The changes were very close to each other. But I figured I'd still better make two pull requests instead of one in case you liked one but not the other.

@gijsk
Copy link
Contributor

gijsk commented Nov 3, 2021

No worries at all, you did the right thing! Thanks again for both the patches.

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 this pull request may close these issues.

3 participants