Socket
Socket
Sign inDemoInstall

styles-to-text

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    styles-to-text

Tiny package for styling text by using javascript style definitions. Commonly used for handling texts of content management systems like takeshape, graphcms and other.


Version published
Weekly downloads
4
decreased by-75%
Maintainers
1
Install size
10.9 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 26 Jan 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc