3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-21 15:42:58 +01:00

Write a line where em shares a delimiter run with strong in time linear in its mark runs

This commit is contained in:
2026-10-30 20:39:09 +01:00
committed by Lillem4n
parent 01c8365f71
commit d0b2e22aa8
10 changed files with 64 additions and 26 deletions
@@ -401,6 +401,13 @@ test('drops the mark of the run that cannot close where it sits, and keeps the l
assert.equal(portable(paragraph(text('~', highlight), text('b'), text('日本', highlight))), '~b==日本==\n')
})
test('drops every em, strong and strike mark in a line still misread after 32 passes', () => {
const strike: AdfMark = { type: 'strike' }
const repeat = [text(' ~~ ', em, strong), text(')', em, strike, strong), text('a'), text('.unun', strike, strong)]
const line = Array.from({ length: 40 }, () => repeat).flat()
assert.equal(portable(paragraph(...line)), `${Array.from({ length: 40 }, () => '~~ )a.unun').join(' ')}\n`)
})
test('gives up every highlight run whose own delimiter cannot flank in one fallback, so a line of them re-emits once however many it holds', () => {
const highlight: AdfMark = { type: 'backgroundColor' }
const line = [text('a '), text('x', highlight), text('a '), text('x', highlight), text('a '), text('x', highlight), text('a')]