@liascript/exporter 2.6.4--0.10.31 → 2.6.5--0.10.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liascript/exporter",
3
- "version": "2.6.4--0.10.31",
3
+ "version": "2.6.5--0.10.31",
4
4
  "description": "A generic exporter for LiaScript",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -200,7 +200,7 @@ export async function exporter(
200
200
  const jsonLD = {
201
201
  '@context': 'http://schema.org/',
202
202
  '@type': 'ItemList',
203
- itemListElement: itemList,
203
+ itemListElement: removeContext(itemList),
204
204
  }
205
205
 
206
206
  let title = json.title || 'LiaScript Course Index'
@@ -220,7 +220,7 @@ export async function exporter(
220
220
  <title>${title}</title>
221
221
 
222
222
  <script type="application/ld+json">
223
- ${JSON.stringify(await RDF.compact(jsonLD), null, 2)}
223
+ ${JSON.stringify(jsonLD, null, 2)}
224
224
  </script>
225
225
 
226
226
  ${
@@ -304,6 +304,18 @@ export async function exporter(
304
304
  helper.writeFile(output + '.html', helper.prettify(helper.prettify(html)))
305
305
  }
306
306
 
307
+ function removeContext(obj) {
308
+ for (let key in obj) {
309
+ if (obj.hasOwnProperty(key)) {
310
+ if (key === '@context') {
311
+ delete obj[key]
312
+ } else if (typeof obj[key] === 'object') {
313
+ removeContext(obj[key])
314
+ }
315
+ }
316
+ }
317
+ return obj
318
+ }
307
319
  async function moveFile(oldPath, newPath) {
308
320
  // 1. Create the destination directory if it does not exist
309
321
  // Set the `recursive` option to `true` to create all the subdirectories
package/src/export/rdf.ts CHANGED
@@ -50,7 +50,7 @@ export async function exporter(
50
50
  },
51
51
  json
52
52
  ) {
53
- let doc = parse(argument, json)
53
+ let doc = await parse(argument, json)
54
54
 
55
55
  if (argument['rdf-format'] === 'n-quads') {
56
56
  const nquads = await jsonld.toRDF(doc, { format: 'application/n-quads' })
@@ -176,7 +176,7 @@ export async function parse(
176
176
  doc = langInformation(doc, json.lia.definition)
177
177
  doc = logoInformation(doc, json.lia.definition, baseURL)
178
178
  doc = await licenseInformation(doc, argument, baseURL)
179
- doc = await jsonld.compact(doc, 'http://schema.org/')
179
+ doc = await jsonld.compact(doc, 'http://schema.org')
180
180
 
181
181
  return clean(doc)
182
182
  }
package/src/index.ts CHANGED
@@ -22,7 +22,7 @@ import fetch from 'node-fetch'
22
22
 
23
23
  // -------------------------------Main Execution-------------------------------
24
24
  if (argv.v || argv.version) {
25
- console.log('version: 2.6.4--0.10.31')
25
+ console.log('version: 2.6.5--0.10.31')
26
26
  } else if (argv.h || argv.help) {
27
27
  help()
28
28
  } else if (argv.i || argv.input) {