Convert quill deltas to and from other formats
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
jfhr 55f895661b
Merge pull request #10 from jfhr/html-npf
11 months ago
.github/workflows Fix github build script some more 2 years ago
src Add npf-to-html and html-to-npf 11 months ago
.gitignore Initial commit 2 years ago
.npmignore Add npf-to-html and html-to-npf 11 months ago
CHANGELOG.md Add npf-to-html and html-to-npf 11 months ago
LICENSE Create LICENSE 2 years ago
README.md Add npf-to-html and html-to-npf 11 months ago
index.js Add npf-to-html and html-to-npf 11 months ago
package-lock.json Add HTML/SSML escaping 1 year ago
package.json Add npf-to-html and html-to-npf 11 months ago

README.md

deltaconvert

Node.js CI

Convert quill delta objects to and from plain text, HTML, and NPF.

Installation

npm install deltaconvert

Example

const {deltaToHtml} = require('deltaconvert');
deltaToHtml({
    ops: [
        {insert: 'Gandalf', attributes: {bold: true}},
        {insert: ' the '},
        {insert: 'Grey', attributes: {color: '#cccccc'}},
        {insert: '\n'}
    ]
});
/** 
 * Returns
 * <p><b>Gandalf</b> the <span style="color:#cccccc;">Grey</span></p>
 */

Reference

deltaToHtml

Convert a delta object to html. The resulting HTML can be inserted into an existing website, it will have no <html>, <body>, etc. tags. {insert: {divider:true}} objects will be converted to <hr> tags.

deltaToNpf

Convert a delta object to tumblr's NPF format. Headings of level >2 will be converted to bold text. Images will be inserted without any size information. Videos will be inserted as media object if we can guess the mime type from the url, otherwise as plain links. Code blocks will be converted to text objects with subtype chat, which should be rendered with a monospace font.

deltaToText

Convert a delta object to plain text. Formatting, images, etc. will be ignored.

deltaToSsml

Convert a delta object to the Speech Synthesis Markup Language. Images will be converted to elements containing the alt text. Other media and special elements will be ignored.

htmlToDelta

Convert a html document or snippet to a quill delta document. Note that only inline styles are supported. <style> tags and external stylesheets will be ignored. <hr> tags will be converted to {insert: {divider: true}} objects. <iframe>s with the ql-video class will be treated as videos.

npfToDelta

Convert a tumblr NPF to a quill delta. Blog references aren't supported yet.

textToDelta

Convert plain text to a delta object with no formatting information.

htmlToNpf

Convert a html document or snippet to tumblr's NPF format. This is a shorthand for deltaToNpf(htmlToDelta(...)).

npfToHtml

Convert a tumblr NPF to html. This is a shorthand for deltaToNpf(htmlToDelta(...)). Note that blockquotes with indent_level > 1 will be converted to plain <blockquote>s, not nested <blockquote>s. This may change in a future release.

Contributing

If you want to request a feature, report a bug, or contribute in some other way, please file an issue here. Thanks!