mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-19 06:35:44 +01:00
Write strike as HTML in adfToHtml and read it back in htmlToAdf
This commit is contained in:
@@ -75,6 +75,11 @@ test('writes the marks CommonMark spells, the first mark outermost', () => {
|
||||
assert.equal(html(adfToHtml(document(paragraph(text('Line one'), { type: 'hardBreak' }, text('Line two'))))), '<p>Line one<br>Line two</p>\n')
|
||||
})
|
||||
|
||||
test('writes a strike mark as <del>, a strike mark holding attributes as a carry element', () => {
|
||||
assert.equal(html(adfToHtml(document(paragraph(text('old', { type: 'strike' }), text(' new', { type: 'strong' }, { type: 'strike' }))))), '<p><del>old</del><strong><del> new</del></strong></p>\n')
|
||||
assert.match(html(adfToHtml(document(paragraph(text('old', { attrs: { x: 1 }, type: 'strike' }))))), /^<p><span class="adf-carry" data-adf=/)
|
||||
})
|
||||
|
||||
test('escapes text, and keeps tabs, line feeds and form feeds', () => {
|
||||
assert.equal(html(adfToHtml(document(paragraph(text('a < b && c > "d" \'e\'\tf\ng\fh'))))), '<p>a < b && c > "d" \'e\'\tf\ng\fh</p>\n')
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
const markElements: ReadonlyMap<string, string> = new Map([
|
||||
['code', 'code'],
|
||||
['em', 'em'],
|
||||
['strike', 'del'],
|
||||
['strong', 'strong'],
|
||||
])
|
||||
|
||||
|
||||
@@ -80,6 +80,10 @@ test('reads text\'s marks from its elements, the outermost first, and each run o
|
||||
assert.deepEqual(read(htmlToAdf('<p><a href="x" title="">y</a></p>\n')), document(paragraph(text('y', { attrs: { href: 'x', title: '' }, type: 'link' }))))
|
||||
})
|
||||
|
||||
test('reads <del> as a strike mark', () => {
|
||||
assert.deepEqual(read(htmlToAdf('<p><del>old</del><strong><del> new</del></strong></p>\n')), document(paragraph(text('old', { type: 'strike' }), text(' new', { type: 'strong' }, { type: 'strike' }))))
|
||||
})
|
||||
|
||||
test('reads escaped text, and keeps tabs, line feeds and form feeds', () => {
|
||||
assert.deepEqual(read(htmlToAdf('<p>a < b && c > "d" \'e\'\tf\ng\fh &lt;</p>\n')), document(paragraph(text('a < b && c > "d" \'e\'\tf\ng\fh <'))))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user