3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 06:35:44 +01:00

Count a textless holder as a stripping run end, and test the nested count offset

This commit is contained in:
2026-11-15 14:24:53 +01:00
committed by Lillem4n
parent 08abdd117f
commit 7d1e2d96ba
2 changed files with 10 additions and 1 deletions
@@ -106,6 +106,15 @@ test('counts an emphasis run from its first to its last leaf holding more than s
assert.deepEqual(trimmingRuns(line, 'spanned'), [1, 1, 2, 2, 1, 1, 0])
})
test('counts a run nested in an emphasis run from the emphasis run\'s first leaf holding more than spaces and tabs', () => {
const line = [marked(' ', { type: 'em' }), marked('x', { type: 'code' }), marked('a', { type: 'em' }, { type: 'strong' }), marked('x', { type: 'code' }), marked('b', { type: 'em' }, { type: 'strong' })]
assert.deepEqual(trimmingRuns(line, 'spanned'), [0, 0, 2, 2, 0])
})
test('counts an emphasis run to a leaf holding it and no text, which the trim never changes', () => {
assert.deepEqual(trimmingRuns([marked('a', { type: 'em' }), marked('x', { type: 'code' }), { attrs: { id: 'a' }, marks: [{ type: 'em' }], type: 'mention' }], 'spanned'), [1, 1, 0])
})
const alternatingLines: readonly [string, AdfNode, AdfNode][] = [
['a code space beside an emphasized space', marked(' ', { type: 'code' }), marked(' ', { type: 'em' })],
['code x beside an emphasized space', marked('x', { type: 'code' }), marked(' ', { type: 'em' })],