👔 Generate inline elements from plain text using
begin
&offset
const inline = require('simple-inline');
const text = 'hello world';
const styles = [{
begin: 0,
offset: 5,
types: ['underline']
}, {
begin: 6,
offset: 5,
types: ['bold', 'strike']
}, {
begin: 4,
offset: 3,
types: ['italic']
}];
// generate html
const result = inline(text, styles);
<span class="underline">hell</span><span class="underline italic">o</span><span class="italic"> </span><span class="bold strike italic">w</span><span class="bold strike">orld</span>
$ npm i simple-inline
const inline = require('simple-inline');
type: string
type: object
(array)
An item must have begin
, offset
and types
.
types
is string array and will be <span class="<types>"...
specify return type. html
(default) or object
.
const result = inline(text, styles, {
returnType: 'object'
});
$ npm test
MIT © Jaewe Heo