Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var BBPromise = require('bluebird');
var cheerio = require('cheerio');
var microdata = require('microdata-node'); // Schema.org microdata
var yaml = require('js-yaml');

/**
* Returns Object containing all available datatypes, keyed
Expand Down Expand Up @@ -385,7 +386,9 @@ exports.parseJsonLd = BBPromise.method(function(chtml) {
jsonLd.each(function() {
var contents;
try {
contents = JSON.parse(this.children[0].data);
// some websites have multiline strings in their JSON
// and they're valid as per https://search.google.com/structured-data/testing-tool
contents = yaml.safeLoad(this.children[0].data, yaml.JSON_SCHEMA);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a test for the multiline string?

} catch (e) {
// Fail silently, just in case there are valid tags
return;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dependencies": {
"bluebird": "3.5.1",
"cheerio": "1.0.0-rc.2",
"microdata-node": "0.2.1",
"js-yaml": "^3.13.1",
"microdata-node": "https://github.com/n-sviridenko/microdata-node#a6b2eee9c383668a18ee467b96179dccd67af715",
Copy link
Collaborator

@mvolz mvolz Aug 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointing to this fork should be a separate PR... we'd have to review the replacement in more detail.

"preq": "0.5.4"
},
"devDependencies": {
Expand Down
Loading