Git Product home page Git Product logo

tik-attributed-text's Introduction

tik-attributed-text npm version Build Status codecov.io

Encodes and decodes TikApi::v5 text attributes to HTML

Install

$ npm install --save tik-attributed-text

Usage

Below is a example of usage.

var attrsTextToHTML = require('tik-attributed-text/to-html');
attrsTextToHTML("Hello World!", [
  {
    _type: "Tik::ApiModel::Text::BoldSpan",
    start: 2,
    end: 6
  },
  {
    _type: "Tik::ApiModel::Text::ItalicSpan",
    start: 4,
    end: 8
  }
]); // => "He<strong>ll<em>o </em></strong><em>Wo</em>rld!"
HTMLtoAttrs("He<strong>ll<em>o</em></strong><em> Wo</em>rld!"); /* => {
  text: "Hello World!",
  attrs: [
    { _type: 'Tik::ApiModel::Text::BoldSpan', start: 2, end: 6 },
    { _type: 'Tik::ApiModel::Text::ItalicSpan', start: 4, end: 8 }
  ]
}*/

Options

to-attrs:

replaceBrTagWithNewLine

default: false

replaces <br> tags with new lines \n

to-html:

proxyDocument

default: undefined (Browser document)

if you want to run this function in a browserless environment like node

skipIntersectionsCompress

default: false

if you want to skip intersections normalization

replaceNewLinesWithBrTag

default: false

replaces new lines \n with <br> tags

tik-attributed-text's People

Watchers

Hannes Dorfmann avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.