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

properly handle rdf:HTML #2

Open
sballesteros opened this issue Mar 10, 2016 · 0 comments
Open

properly handle rdf:HTML #2

sballesteros opened this issue Mar 10, 2016 · 0 comments
Labels

Comments

@sballesteros
Copy link
Member

graph-rdfa-processor works fine but currently, jsonld-rdfa-parser only get the textContent see:

import util from 'util';
import { jsdom } from 'jsdom';
import getRdfaGraph from 'graph-rdfa-processor';
import jsonld from 'jsonld';
import jsonldRdfaParser from 'jsonld-rdfa-parser';
jsonld.registerRDFParser('text/html', jsonldRdfaParser);

const html = '<span resource="http://example.com"><span property="schema:name" datatype="rdf:HTML"><em>MonkeyPatcher</em></span></span>';

let { document } = jsdom(html).defaultView.window;
let graph = getRdfaGraph(document, {baseURI: 'http://localhost'});
console.log(graph.toString());

// <http://example.com> <http://schema.org/name> """<em>MonkeyPatcher</em>"""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML> .


jsonld.fromRDF(html, {format: 'text/html'}, function(err, data) {
  console.log(util.inspect(data, {depth: null}));

  //[ { '@id': 'http://example.com',
  //    'http://schema.org/name':
  //    [ { '@value': NodeList { '0': HTMLElement { item: null } },
  //        '@type': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML' } ] } ]

});

we should take the outerHTML

@sballesteros sballesteros changed the title propertly handle rdf:HTML properly handle rdf:HTML Mar 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant