convert-rich-text
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -7,3 +7,3 @@ var merge = require('merge-recursive'); | ||
embed: { | ||
1: '<img src="{image}" alt="{alt}" />' | ||
1: '<img src="{image}"/>' | ||
}, | ||
@@ -24,5 +24,3 @@ block: { | ||
underline: '<u>{content}</u>', | ||
strikethrough: '<s>{content}</s>', | ||
color: '<span style="color:{color}">{content}</span>', | ||
font: '<span style="font-family:{font}">{content}</span>', | ||
strikethrough: '<s>{content}</s>' | ||
} | ||
@@ -45,3 +43,4 @@ }; | ||
return convertAll(content, attrs, options.block); | ||
}).join('\n'); | ||
}).join('\n').replace(/<\/(ul|ol)>\n<\1>/g, '\n'); | ||
// TODO: stop doing this hacky regexp shit | ||
@@ -48,0 +47,0 @@ // |
{ | ||
"name": "convert-rich-text", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Facilities for converting an insert-only rich-text delta into various formats like HTML and Markdown", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
35
test.js
@@ -5,3 +5,3 @@ var assert = require('assert'); | ||
{ | ||
desc: 'HTML', | ||
desc: 'Complex HTML', | ||
format: 'html', | ||
@@ -11,6 +11,5 @@ delta: [ | ||
{insert: '\n', attributes: {firstheader: true}}, | ||
{insert: 'This is a demo of the Quilljs Renderer'}, | ||
{insert: 'This is a demo of convert-rich-text'}, | ||
{insert: 1, attributes: { | ||
image: 'monkey.png', | ||
alt: 'Funny monkey picture' | ||
image: 'monkey.png' | ||
}}, | ||
@@ -22,5 +21,24 @@ {insert: 'Google', attributes: {link: 'https://www.google.com'}} | ||
'<h1><b>This is a second line.</b></h1>\n' + | ||
'<p>This is a demo of the Quilljs Renderer</p>\n' + | ||
'<p><img src="monkey.png" alt="Funny monkey picture" /></p>\n' + | ||
'<p>This is a demo of convert-rich-text</p>\n' + | ||
'<p><img src="monkey.png"/></p>\n' + | ||
'<p><a href="https://www.google.com">Google</a></p>' | ||
}, | ||
{ | ||
desc: 'Lists', | ||
format: 'html', | ||
delta: [ | ||
{insert: 'Consecutive list elements'}, | ||
{insert: '\n', attributes: {list: true}}, | ||
{insert: 'Should create a parent tag'}, | ||
{insert: '\n', attributes: {list: true}}, | ||
{insert: 'Consecutive bullet elements'}, | ||
{insert: '\n', attributes: {bullet: true}}, | ||
{insert: 'Should create a parent tag'}, | ||
{insert: '\n', attributes: {bullet: true}} | ||
], | ||
expected: | ||
'<ol><li>Consecutive list elements</li>\n' + | ||
'<li>Should create a parent tag</li></ol>\n' + | ||
'<ul><li>Consecutive bullet elements</li>\n' + | ||
'<li>Should create a parent tag</li></ul>' | ||
} | ||
@@ -31,3 +49,6 @@ ]; | ||
it(test.desc, function() { | ||
assert.equal(convert(test.delta, test.format), test.expected); | ||
var result = convert(test.delta, test.format); | ||
// console.log(result); | ||
// console.log(test.expected); | ||
assert.equal(result, test.expected); | ||
}); | ||
@@ -34,0 +55,0 @@ }); |
13645
243