0.1.1 • Published 6 years ago
spangle-lite v0.1.1
Spangle Lite
Spangle adds some ✨ razzle-dazzle ✨ to strings using formatted ranges.
The "lite" version can format data to HTML, but cannot parse HTML. The formatter builds strings directly without using the native DOM API. That makes it more lightweight, but in some rare cases it may be possible to generate HTML that violate tag nesting rules.
Usage
Formatting HTML
import { formatHtml } from 'spangle';
const output = formatHtml({
blocks: [{
type: 'text',
text: 'This is your text.',
formatting: [
{ start: 8, end: 12, type: 'emphasis' },
],
}],
});
console.log(output);
// "<p>This is <em>your</em> text.</p>"