Skip to content

jslicense/spdx-to-html.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

var spdxToHTML = require('spdx-to-html')

Returns null for invalid license expressions:

var assert = require('assert')
assert.deepStrictEqual(
  spdxToHTML('InvalidExpression'),
  null
)

Returns links for standard licenses on spdx.org:

assert.deepStrictEqual(
  spdxToHTML('MIT'),
  '<a href="https://spdx.org/licenses/MIT.html">MIT</a>'
)

For license references:

assert.deepStrictEqual(
  spdxToHTML('LicenseRef-123ABC'),
  'License Reference "LicenseRef-123ABC"'
)

Constructs English disjunctions for multilicensing expressions:

assert.deepStrictEqual(
  spdxToHTML('(MPL-2.0 OR GPL-2.0+)'),
  (
    '<a href="https://spdx.org/licenses/MPL-2.0.html">MPL-2.0</a>' +
    ' or ' +
    '<a href="https://spdx.org/licenses/GPL-2.0.html">GPL-2.0</a> or newer'
  )
)

Describes ranges and exceptions:

assert.deepStrictEqual(
  spdxToHTML('(GPL-2.0+ WITH Bison-exception-2.2)'),
  (
    '<a href="https://spdx.org/licenses/GPL-2.0.html">GPL-2.0</a>' +
    ' or newer' +
    ' with Bison-exception-2.2'
  )
)

About

convert an SPDX expression to English text and links

Resources

License

Stars

Watchers

Forks

Packages

No packages published