A port of kemitchell's spdx-to-html
import spdxReact from 'spdx-to-react';
Returns []
for invalid license expressions:
spdxReact('InvalidExpression')
// => []
Returns React <a>
tags for standard licenses on spdx.org:
spdxReact('MIT')
// => [<a href="http://spdx.org/licenses/MIT">MIT</a>]
For license references:
spdxReact('LicenseRef-123ABC')
// => ['License Reference "LicenseRef-123ABC"']
Constructs English disjunctions for multilicensing expressions:
spdxReact('(MPL-2.0 OR GPL-2.0+)')
// => [
// <a href="http://spdx.org/licenses/MPL-2.0">MPL-2.0</a>,
// ' or ',
// <a href="http://spdx.org/licenses/GPL-2.0">GPL-2.0</a>,
// 'or newer'
// ]
Describes ranges and exceptions:
spdxReact('(GPL-2.0+ WITH Bison-exception-2.2)')
// => [<a href="http://spdx.org/licenses/GPL-2.0">GPL-2.0</a>, ' or newer', ' with Bison-exception-2.2']
You could also map this to other values, by passing a mapping function.
By default, the mapping function is <a href="spdx.org/licenses/${VALUE}>${VALUE}</a>
spdxReact('MIT', x => <b>${x.toLowerCase()}</b>);
// => [<b>mit</b>]