styles-to-text

1.0.2 • Public • Published

Javascript Styles to Text

A small module for styling text with html by using arrays of text style definitions. Commonly necessary for parsing text blocks from content management systems like Takeshape.io and other cm-systems.

Install

npm i styles-to-text
# or 
yarn styles-to-text

Usage

import stylesToText from "styles-to-text";
 
const textToStyle = `To be, or not to be, that is the question.`;
 
const styleDefinitions = [  {
    offset: 0,
    length: 20,
    style: "BOLD"
}, {
    offset: 3,
    length: 17,
    style: "STRIKE"
}, {
    offset: 14,
    length: 15,
    style: "UNDERLINE"
}  ];
 
console.log(stylesToText(textToStyle, styleDefinitions));

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i styles-to-text

    Weekly Downloads

    12

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    11.2 kB

    Total Files

    7

    Last publish

    Collaborators

    • coderwelsch