spdx-to-html

1.0.0 • Public • Published
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'
  )
)

/spdx-to-html/

    Package Sidebar

    Install

    npm i spdx-to-html

    Weekly Downloads

    389

    Version

    1.0.0

    License

    Apache-2.0

    Unpacked Size

    15 kB

    Total Files

    7

    Last publish

    Collaborators

    • kemitchell