Encodes and decodes TikApi::v5 text attributes to HTML
$ npm install --save tik-attributed-text
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 }
]
}*/
default: false
replaces <br>
tags with new lines \n
default: undefined
(Browser document)
if you want to run this function in a browserless environment like node
default: false
if you want to skip intersections normalization
default: false
replaces new lines \n
with <br>
tags