@@ -139,6 +139,7 @@ const context = {
139
139
```
140
140
141
141
### [ compact] ( http://json-ld.org/spec/latest/json-ld/#compacted-document-form )
142
+
142
143
``` js
143
144
// compact a document according to a particular context
144
145
jsonld .compact (doc, context, function (err , compacted ) {
@@ -161,6 +162,7 @@ const compacted = await jsonld.compact(doc, context);
161
162
```
162
163
163
164
### [ expand] ( http://json-ld.org/spec/latest/json-ld/#expanded-document-form )
165
+
164
166
``` js
165
167
// expand a document, removing its context
166
168
jsonld .expand (compacted, function (err , expanded ) {
@@ -181,6 +183,7 @@ const expanded = await jsonld.expand(doc);
181
183
```
182
184
183
185
### [ flatten] ( http://json-ld.org/spec/latest/json-ld/#flattened-document-form )
186
+
184
187
``` js
185
188
// flatten a document
186
189
jsonld .flatten (doc, (err , flattened ) => {
@@ -192,6 +195,7 @@ const flattened = await jsonld.flatten(doc);
192
195
```
193
196
194
197
### [ frame] ( http://json-ld.org/spec/latest/json-ld-framing/#introduction )
198
+
195
199
``` js
196
200
// frame a document
197
201
jsonld .frame (doc, frame, (err , framed ) => {
@@ -202,7 +206,8 @@ jsonld.frame(doc, frame, (err, framed) => {
202
206
const framed = await jsonld .frame (doc, frame);
203
207
```
204
208
205
- ### [ canonize] ( http://json-ld.github.io/normalization/spec/ ) (normalize)
209
+ ### <a name =" canonize " ></a >[ canonize] ( http://json-ld.github.io/normalization/spec/ ) (normalize)
210
+
206
211
``` js
207
212
// canonize (normalize) a document using the RDF Dataset Normalization Algorithm
208
213
// (URDNA2015), see:
@@ -218,7 +223,8 @@ jsonld.canonize(doc, {
218
223
const canonized = await jsonld .canonize (doc, {format: ' application/n-quads' });
219
224
```
220
225
221
- ### toRDF (N-Quads)
226
+ ### <a name =" tordf " ></a >toRDF (N-Quads)
227
+
222
228
``` js
223
229
// serialize a document to N-Quads (RDF)
224
230
jsonld .toRDF (doc, {format: ' application/n-quads' }, (err , nquads ) => {
@@ -229,7 +235,8 @@ jsonld.toRDF(doc, {format: 'application/n-quads'}, (err, nquads) => {
229
235
const rdf = await jsonld .toRDF (doc, {format: ' application/n-quads' });
230
236
```
231
237
232
- ### fromRDF (N-Quads)
238
+ ### <a name =" fromrdf " ></a >fromRDF (N-Quads)
239
+
233
240
``` js
234
241
// deserialize N-Quads (RDF) to JSON-LD
235
242
jsonld .fromRDF (nquads, {format: ' application/n-quads' }, (err , doc ) => {
@@ -241,6 +248,7 @@ const doc = await jsonld.fromRDF(nquads, {format: 'application/n-quads'});
241
248
```
242
249
243
250
### Custom RDF Parser
251
+
244
252
``` js
245
253
// register a custom async-callback-based RDF parser
246
254
jsonld .registerRDFParser (contentType, (input , callback ) => {
@@ -262,6 +270,7 @@ jsonld.registerRDFParser(contentType, async input => {
262
270
```
263
271
264
272
### Custom Document Loader
273
+
265
274
``` js
266
275
// how to override the default document loader with a custom one -- for
267
276
// example, one that uses pre-loaded contexts:
0 commit comments