New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@factsmission/rdfa-parser

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@factsmission/rdfa-parser

A parser for RDFa

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
2
Created
Source

rdfa-parser

Build Status

An RDFa parser in JS. Not yet complete but we aim for full support of HTML+RDFa 1.1.

Usage

rdfa-parser provides functions to parse either HTMLElements or Strings containg RDFa. A callback function is invoked whenever a quad has been read. The argument passed to this function is an rdfjs compliant quad.

parseDOM(element,callback,base,useInitialContext)

Parses a Node / HTMLElement with RDFa.

parseString(string,callback,base,useInitialContext)

Parses a String containing a Node / HTMLElement with RDFa

Parameters

ParameterTypeDescriptionDefault
elementNodeNode / Element to be parsedRequired Parameter
stringStringString of Node / Element to be parsedRequired Parameter
callbackFunctionFunction to give a quad. Gets called every time a quad is foundRequired Parameter
baseIRIbaseIRI to be usedelement.baseURI || window.location.href
useInitialContextbooleanIf https://www.w3.org/2013/json-ld-context/rdfa11 should be loaded as initial set of prefixesfalse

Building

Run yarn build to create /distribution/latest/rdfa.js for use in websites.

Example 1

<head>
    ...
    <script src="/distribution/latest/rdfa.js"></script>
    <script type="text/javascript" src="https://retog.github.io/ext-rdflib/latest/rdf.js"></script>
    <script>
        window.onload = () => {
            let g = $rdf.graph();
            RDFa.parseDOM(document.documentElement, (quad) => g.add(quad));
            const output = $rdf.serializers["text/turtle"].import(g.toStream());
            output.on('data', ntriples => console.log(ntriples.toString()));
        }
    </script>
    ...
</head>

All Triples found will be console.loged as stringified ntriples.

FAQs

Package last updated on 07 Jul 2019

Related posts