0.1.5 • Published 8 years ago

simple-inline v0.1.5

Weekly downloads
57
License
MIT
Repository
github
Last release
8 years ago

simple-inline

Build Status

:necktie: Generate inline elements from plain text using begin & offset

Usage

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);

Output

<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>

Install

$ npm i simple-inline

API

inline(text, styles, options)

const inline = require('simple-inline');

text

type: string

styles

type: object (array)

An item must have begin, offset and types. types is string array and will be <span class="<types>"...

options

returnType

specify return type. html(default) or object.

const result = inline(text, styles, {
  returnType: 'object'
});

Test

$ npm test

License

MIT © Jaewe Heo

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago