3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-18 22:25:44 +01:00

Write strike as HTML in adfToHtml and read it back in htmlToAdf

This commit is contained in:
2026-11-14 23:17:06 +01:00
committed by Lillem4n
parent 2ea7cf3631
commit fde890db90
10 changed files with 39 additions and 12 deletions
+5
View File
@@ -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 &lt; b &amp;&amp; c &gt; &quot;d&quot; \'e\'\tf\ng\fh</p>\n')
})
+1
View File
@@ -2,6 +2,7 @@
const markElements: ReadonlyMap<string, string> = new Map([
['code', 'code'],
['em', 'em'],
['strike', 'del'],
['strong', 'strong'],
])
+4
View File
@@ -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 &lt; b &amp;&amp; c &gt; &quot;d&quot; \'e\'\tf\ng\fh &amp;lt;</p>\n')), document(paragraph(text('a < b && c > "d" \'e\'\tf\ng\fh &lt;'))))
})