mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-21 23:46:21 +01:00
Read a list whose bullet or ordered delimiter changes as two lists, and alternate the marker between adjacent lists in place of !adf:listBreak
This commit is contained in:
@@ -127,7 +127,7 @@ test('spells a task list as a bullet list whose items lead with their state', ()
|
||||
assert.equal(portable(node('taskList', {}, nested, task('DONE', ''), said('Stray'))), '- - [ ] Review\n- \\[x]\n- Stray\n')
|
||||
assert.equal(portable(node('taskList', {}, node('taskList', {}), task('DONE', 'a'), said('b'), node('taskList', {}, task('TODO', 'c')))), '- \\[x] a\n- b\n - [ ] c\n')
|
||||
assert.equal(portable(node('taskList', {}, paragraph(), task('DONE', 'a'))), '- [x] a\n')
|
||||
assert.equal(portable(bulletList(item(said('x'))), node('taskList', {}, task('DONE', 'a'), node('taskList', {}, task('TODO', 'c')))), '- x\n- \\[x] a\n - [ ] c\n')
|
||||
assert.equal(portable(bulletList(item(said('x'))), node('taskList', {}, task('DONE', 'a'), node('taskList', {}, task('TODO', 'c')))), '- x\n\n* [x] a\n - [ ] c\n')
|
||||
assert.equal(portable(node('taskList', {}), task('TODO', 'Loose')), 'Loose\n')
|
||||
const blockTask = node('blockTaskItem', { state: 'DONE' }, said('First.'), said('Second.'))
|
||||
const codeTask = node('blockTaskItem', { state: 'TODO' }, { content: [text('x')], type: 'codeBlock' })
|
||||
@@ -135,9 +135,9 @@ test('spells a task list as a bullet list whose items lead with their state', ()
|
||||
const parent = node('blockTaskItem', { state: 'TODO' }, said('q'), said('q2'))
|
||||
assert.equal(portable(node('taskList', {}, parent, node('taskList', {}, task('DONE', 'n')), task('DONE', 'B'))), '- [ ] q\n\n q2\n - [x] n\n- [x] B\n')
|
||||
const holding = node('blockTaskItem', { state: 'TODO' }, said('A'), node('taskList', {}, task('TODO', 'c')))
|
||||
assert.equal(portable(node('taskList', {}, holding, node('taskList', {}, task('TODO', 'd')), task('TODO', 'B'))), '- [ ] A\n - [ ] c\n - [ ] d\n- [ ] B\n')
|
||||
assert.equal(portable(node('taskList', {}, holding, node('taskList', {}, task('TODO', 'd')), task('TODO', 'B'))), '- [ ] A\n - [ ] c\n * [ ] d\n- [ ] B\n')
|
||||
const listTask = node('blockTaskItem', { state: 'DONE' }, bulletList(item(said('a'))))
|
||||
assert.equal(portable(node('taskList', {}, task('TODO', ''), listTask, node('taskList', {}, task('TODO', 'b')))), '- \\[ ]\n- \\[x]\n- a\n- \\[ ] b\n')
|
||||
assert.equal(portable(node('taskList', {}, task('TODO', ''), listTask, node('taskList', {}, task('TODO', 'b')))), '- [ ]\n- [x]\n\n* a\n\n- [ ] b\n')
|
||||
assert.equal(portable(node('taskList', {}, task('DONE', 'a'), node('taskList', {}, task('TODO', '')))), '- [x] a\n - [ ]\n')
|
||||
})
|
||||
|
||||
@@ -192,12 +192,12 @@ test('keeps the CommonMark blocks in their spelling and drops their attributes a
|
||||
const code: AdfNode = { content: [text('x')], type: 'codeBlock' }
|
||||
assert.equal(portable(node('orderedList', { order: 1e10 }, item(said('Alpha')), item(code), item())), '- 10000000000. Alpha\n- 10000000001.\n\n ```\n x\n ```\n- 10000000002.\n')
|
||||
const long = node('orderedList', { order: 1e10 }, item(said('y')))
|
||||
assert.equal(portable(bulletList(item(said('x'))), long, bulletList(item(said('z')))), '- x\n- 10000000000. y\n- z\n')
|
||||
assert.equal(portable(node('taskList', {}, node('taskItem', { state: 'DONE' }, text('t'))), long), '- \\[x] t\n- 10000000000. y\n')
|
||||
assert.equal(portable(bulletList(item(said('a'), bulletList(item(said('x'))), long))), '- a\n - x\n - 10000000000. y\n')
|
||||
assert.equal(portable(bulletList(item(said('x'))), long, bulletList(item(said('z')))), '- x\n\n* 10000000000. y\n\n- z\n')
|
||||
assert.equal(portable(node('taskList', {}, node('taskItem', { state: 'DONE' }, text('t'))), long), '- [x] t\n\n* 10000000000. y\n')
|
||||
assert.equal(portable(bulletList(item(said('a'), bulletList(item(said('x'))), long))), '- a\n - x\n * 10000000000. y\n')
|
||||
const givesWay = node('orderedList', { order: 1e10 }, item(node('rule', {})), item(bulletList(item(bulletList(item())))))
|
||||
assert.equal(portable(givesWay, bulletList(item(said('z')))), '- 10000000000.\n- 10000000001.\n - -\n- z\n')
|
||||
assert.equal(portable(node('orderedList', { order: 999999999 }, item(said('a'))), node('orderedList', { order: 5 }, item(said('b')))), '- 999999999\\. a\n- 5\\. b\n')
|
||||
assert.equal(portable(givesWay, bulletList(item(said('z')))), '- 10000000000.\n- 10000000001.\n - -\n\n* z\n')
|
||||
assert.equal(portable(node('orderedList', { order: 999999999 }, item(said('a'))), node('orderedList', { order: 5 }, item(said('b')))), '999999999. a\n\n5) b\n')
|
||||
assert.equal(portable(node('heading', { level: 7 }, text('h'))), 'h\n')
|
||||
})
|
||||
|
||||
@@ -328,16 +328,16 @@ test('keeps a code span opening a line, whose backticks open no fence', () => {
|
||||
assert.equal(portable(paragraph(text('a\n'), text('``` x', code))), 'a\\\n```` ``` x ````\n')
|
||||
})
|
||||
|
||||
test('drops an empty paragraph and merges adjacent lists of one type', () => {
|
||||
test('drops an empty paragraph and alternates the marker between adjacent lists of a kind', () => {
|
||||
const ordered = (order: number, value: string): AdfNode => node('orderedList', { order }, item(said(value)))
|
||||
assert.equal(portable(said('a'), paragraph(), paragraph(text(' ')), said('b')), 'a\n\nb\n')
|
||||
assert.equal(portable(bulletList(item(said('a'))), paragraph(), node('decisionList', {}, node('decisionItem', {}, text('b')))), '- a\n- b\n')
|
||||
assert.equal(portable(ordered(2, 'a'), ordered(3, 'b'), bulletList(item(said('c')))), '2. a\n3. b\n\n- c\n')
|
||||
assert.equal(portable(bulletList(item(said('x'))), ordered(1, 'a'), ordered(5, 'b'), ordered(6, 'c')), '- x\n- 1\\. a\n- 5\\. b\n\n6. c\n')
|
||||
assert.equal(portable(ordered(1, 'a'), ordered(1e10, 'y')), '- 1\\. a\n- 10000000000. y\n')
|
||||
assert.equal(portable(node('taskList', {}, ordered(1e10, 'y')), bulletList(ordered(1e10, 'z'))), '- - 10000000000. y\n- - 10000000000. z\n')
|
||||
assert.equal(portable(bulletList(item(said('a'))), paragraph(), node('decisionList', {}, node('decisionItem', {}, text('b')))), '- a\n\n* b\n')
|
||||
assert.equal(portable(ordered(2, 'a'), ordered(3, 'b'), bulletList(item(said('c')))), '2. a\n\n3) b\n\n- c\n')
|
||||
assert.equal(portable(bulletList(item(said('x'))), ordered(1, 'a'), ordered(5, 'b'), ordered(6, 'c')), '- x\n\n1. a\n\n5) b\n\n6. c\n')
|
||||
assert.equal(portable(ordered(1, 'a'), ordered(1e10, 'y')), '1. a\n\n- 10000000000. y\n')
|
||||
assert.equal(portable(node('taskList', {}, ordered(1e10, 'y')), bulletList(ordered(1e10, 'z'))), '- - 10000000000. y\n\n* - 10000000000. z\n')
|
||||
const column = (list: AdfNode): AdfNode => node('layoutColumn', {}, list)
|
||||
assert.equal(portable(node('layoutSection', {}, column(bulletList(item(said('a')))), column(bulletList(item(said('b')))))), '- a\n- b\n')
|
||||
assert.equal(portable(node('layoutSection', {}, column(bulletList(item(said('a')))), column(bulletList(item(said('b')))))), '- a\n\n* b\n')
|
||||
})
|
||||
|
||||
test('keeps the nodes the portable flavour spells and degrades only what it cannot', () => {
|
||||
|
||||
Reference in New Issue
Block a user