ruby-rdf / rdf-rdfa

Ruby RDFa reader/writer for RDF.rb.
http://ruby-rdf.github.com/rdf-rdfa
The Unlicense
35 stars 11 forks source link

Tolerate invalid RDF in script tag #32

Open fbacall opened 1 year ago

fbacall commented 1 year ago

I'm trying to parse an HTML document as RDFa that contains the following script tag (as well as some valid JSON-LD):

<script type="text/plain" cookie-consent="tracking">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
...
</script>

the text/plain content type causes ruby-rdf to load the NTriples reader, which fails with the exception: RDF::ReaderError: Expected subject (found: "window.dataLayer = window.dataLayer || [];")

Is there a way that the RDFa reader could tolerate (and log) bad RDF in a script tag and continue reading the rest of the document?

Or, is there a good way to not load the NTriples reader for text/plain content?

Thanks!

gkellogg commented 1 year ago

Loading N-Triples when seeing text/plain is historic, and obsolete. Best to remove support for this directly in the RDF gem.