Skip to content

Commit

Permalink
Change listItemIndent default from 'tab' (size) to 'one'
Browse files Browse the repository at this point in the history
Closes GH-48.
  • Loading branch information
wooorm committed Jul 9, 2023
1 parent 5b496da commit 019f25f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 53 deletions.
4 changes: 2 additions & 2 deletions lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@
* code is empty, or if it starts or ends in blank lines.
* @property {boolean | null | undefined} [incrementListMarker=true]
* Whether to increment the counter of ordered lists items (default: `true`).
* @property {'mixed' | 'one' | 'tab' | null | undefined} [listItemIndent='tab']
* How to indent the content of list items (default: `'tab'`).
* @property {'mixed' | 'one' | 'tab' | null | undefined} [listItemIndent='one']
* How to indent the content of list items (default: `'one'`).
*
* Either with the size of the bullet plus one space (when `'one'`), a tab
* stop (`'tab'`), or depending on the item and its parent list (`'mixed'`,
Expand Down
2 changes: 1 addition & 1 deletion lib/util/check-list-item-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @returns {Exclude<Options['listItemIndent'], null | undefined>}
*/
export function checkListItemIndent(state) {
const style = state.options.listItemIndent || 'tab'
const style = state.options.listItemIndent || 'one'

if (style !== 'tab' && style !== 'one' && style !== 'mixed') {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ Whether to increment the counter of ordered lists items (`boolean`, default:
###### `options.listItemIndent`

How to indent the content of list items (`'mixed'`, `'one'`, or `'tab'`,
default: `'tab'`).
default: `'one'`).
Either with the size of the bullet plus one space (when `'one'`), a tab stop
(`'tab'`), or depending on the item and its parent list (`'mixed'`, uses `'one'`
if the item and list are tight and `'tab'` otherwise).
Expand Down
98 changes: 49 additions & 49 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test('core', async function (t) {
{type: 'paragraph', children: [{type: 'text', value: 'b'}]}
]
}),
'* a\n\n b\n'
'* a\n\n b\n'
)
}
)
Expand All @@ -175,7 +175,7 @@ test('core', async function (t) {
{type: 'definition', identifier: 'b', label: 'c', url: 'd'}
]
}),
'* a\n\n [c]: d\n'
'* a\n\n [c]: d\n'
)
}
)
Expand All @@ -192,7 +192,7 @@ test('core', async function (t) {
{type: 'heading', depth: 1, children: [{type: 'text', value: 'b'}]}
]
}),
'* a\n # b\n'
'* a\n # b\n'
)
}
)
Expand All @@ -216,7 +216,7 @@ test('core', async function (t) {
},
{setext: true}
),
'* a\n\n b\n =\n'
'* a\n\n b\n =\n'
)
}
)
Expand Down Expand Up @@ -696,7 +696,7 @@ test('blockquote', async function (t) {
}
]
}),
'> a\n> b\n>\n> - c\n> d\n>\n> - ***\n>\n> - e\n> f\n'
'> a\n> b\n>\n> - c\n> d\n>\n> - ***\n>\n> - e\n> f\n'
)
})

Expand Down Expand Up @@ -2735,7 +2735,7 @@ test('list', async function (t) {
}
]
}),
'- a\n\n- ***\n\n- b\n'
'- a\n\n- ***\n\n- b\n'
)
})

Expand All @@ -2759,7 +2759,7 @@ test('list', async function (t) {
}
]
}),
'- a\n- ***\n'
'- a\n- ***\n'
)
}
)
Expand All @@ -2785,7 +2785,7 @@ test('list', async function (t) {
}
]
}),
'- a\n\n b\n- ***\n'
'- a\n\n b\n- ***\n'
)
}
)
Expand Down Expand Up @@ -2828,7 +2828,7 @@ test('list', async function (t) {
}
]
}),
'1. a\n\n2. ***\n\n3. b\n'
'1. a\n\n2. ***\n\n3. b\n'
)
})

Expand Down Expand Up @@ -2859,7 +2859,7 @@ test('list', async function (t) {
}
]
}),
'1. a\n2. ***\n3. b\n'
'1. a\n2. ***\n3. b\n'
)
}
)
Expand Down Expand Up @@ -2894,7 +2894,7 @@ test('list', async function (t) {
},
{incrementListMarker: false}
),
'1. a\n1. ***\n1. b\n'
'1. a\n1. ***\n1. b\n'
)
}
)
Expand Down Expand Up @@ -3212,7 +3212,7 @@ test('listItem', async function (t) {
type: 'listItem',
children: [{type: 'paragraph', children: [{type: 'text', value: 'a'}]}]
}),
'* a\n'
'* a\n'
)
})

Expand All @@ -3226,7 +3226,7 @@ test('listItem', async function (t) {
{type: 'paragraph', children: [{type: 'text', value: 'b'}]}
]
}),
'* a\n\n ***\n\n b\n'
'* a\n\n ***\n\n b\n'
)
})

Expand Down Expand Up @@ -3314,15 +3314,15 @@ test('listItem', async function (t) {
{type: 'thematicBreak'}
]
}),
'* a\n ***\n'
'* a\n ***\n'
)
}
)

await t.test('should support `bulletOther`', async function () {
assert.equal(
to(createList(createList(createList())), {bulletOther: '+'}),
'* * +\n'
'* * +\n'
)
})

Expand All @@ -3331,7 +3331,7 @@ test('listItem', async function (t) {
async function () {
assert.equal(
to(createList(createList(createList())), {bullet: '-'}),
'- - *\n'
'- - *\n'
)
}
)
Expand All @@ -3341,7 +3341,7 @@ test('listItem', async function (t) {
async function () {
assert.equal(
to(createList(createList(createList())), {bullet: '*'}),
'* * -\n'
'* * -\n'
)
}
)
Expand Down Expand Up @@ -3378,7 +3378,7 @@ test('listItem', async function (t) {
type: 'list',
children: [{type: 'listItem', children: [{type: 'thematicBreak'}]}]
}),
'- ***\n'
'- ***\n'
)
}
)
Expand All @@ -3399,22 +3399,22 @@ test('listItem', async function (t) {
{type: 'listItem', children: [{type: 'thematicBreak'}]}
]
}),
'- a\n\n- ***\n'
'- a\n\n- ***\n'
)
}
)

await t.test(
'should *not* use a different bullet for an empty list item in two lists',
async function () {
assert.equal(to(createList(createList())), '* *\n')
assert.equal(to(createList(createList())), '* *\n')
}
)

await t.test(
'should use a different bullet for an empty list item in three lists (1)',
async function () {
assert.equal(to(createList(createList(createList()))), '* * -\n')
assert.equal(to(createList(createList(createList()))), '* * -\n')
}
)

Expand All @@ -3429,7 +3429,7 @@ test('listItem', async function (t) {
{type: 'listItem', children: [createList(createList())]}
]
}),
'*\n\n* * -\n'
'*\n\n* * -\n'
)
}
)
Expand All @@ -3439,7 +3439,7 @@ test('listItem', async function (t) {
async function () {
assert.equal(
to(createList(createList(createList())), {bullet: '+'}),
'+ + +\n'
'+ + +\n'
)
}
)
Expand All @@ -3449,7 +3449,7 @@ test('listItem', async function (t) {
async function () {
assert.equal(
to(createList(createList(createList(createList())))),
'* * * -\n'
'* * * -\n'
)
}
)
Expand All @@ -3459,7 +3459,7 @@ test('listItem', async function (t) {
async function () {
assert.equal(
to(createList(createList(createList(createList(createList()))))),
'* * * * -\n'
'* * * * -\n'
)
}
)
Expand All @@ -3479,7 +3479,7 @@ test('listItem', async function (t) {
])
)
),
'* * * a\n\n <!---->\n\n *\n'
'* * * a\n\n <!---->\n\n *\n'
)
}
)
Expand Down Expand Up @@ -3810,7 +3810,7 @@ test('escape', async function (t) {
{type: 'paragraph', children: [{type: 'text', value: '> a\n> b'}]}
]
}),
'* \\> a\n \\> b\n'
'* \\> a\n \\> b\n'
)
}
)
Expand Down Expand Up @@ -4296,7 +4296,7 @@ test('escape', async function (t) {
]
}
),
'1. foo\n * bar\n'
'1. foo\n * bar\n'
)
}
)
Expand Down Expand Up @@ -4371,9 +4371,9 @@ test('roundtrip', async function (t) {
'should roundtrip spread items in block quotes',
async function () {
const doc = [
'> * Lorem ipsum dolor sit amet',
'> * Lorem ipsum dolor sit amet',
'>',
'> * consectetur adipisicing elit',
'> * consectetur adipisicing elit',
''
].join('\n')

Expand All @@ -4385,11 +4385,11 @@ test('roundtrip', async function (t) {
'should roundtrip spread items in sublists (1)',
async function () {
const doc = [
'* Lorem ipsum dolor sit amet',
'* Lorem ipsum dolor sit amet',
'',
' 1. consectetur adipisicing elit',
' 1. consectetur adipisicing elit',
'',
' 2. sed do eiusmod tempor incididunt',
' 2. sed do eiusmod tempor incididunt',
''
].join('\n')

Expand All @@ -4401,9 +4401,9 @@ test('roundtrip', async function (t) {
'should roundtrip spread items in sublists (2)',
async function () {
const doc = [
'* 1. Lorem ipsum dolor sit amet',
'* 1. Lorem ipsum dolor sit amet',
'',
' 2. consectetur adipisicing elit',
' 2. consectetur adipisicing elit',
''
].join('\n')

Expand All @@ -4415,15 +4415,15 @@ test('roundtrip', async function (t) {
'should roundtrip spread items in sublists (3)',
async function () {
const doc = [
'* hello',
' * world',
' how',
'* hello',
' * world',
' how',
'',
' are',
' you',
' are',
' you',
'',
' * today',
'* hi',
' * today',
'* hi',
''
].join('\n')

Expand Down Expand Up @@ -4460,25 +4460,25 @@ test('roundtrip', async function (t) {

await t.test('should roundtrip empty lists', async function () {
const doc = [
'* foo',
'* foo',
'',
'*',
'',
'* bar',
'* bar',
'',
'* baz',
'* baz',
'',
'*',
'',
'* qux quux',
'* qux quux',
''
].join('\n')

assert.equal(to(from(doc)), doc)
})

await t.test('should roundtrip empty lists', async function () {
const doc = '* a\n\n<!---->\n\n* b\n'
const doc = '* a\n\n<!---->\n\n* b\n'

assert.equal(to(from(doc)), doc)
})
Expand Down Expand Up @@ -4553,7 +4553,7 @@ test('roundtrip', async function (t) {
await t.test(
'should roundtrip an empty list item in two more lists',
async function () {
const doc = '* * -\n'
const doc = '* * -\n'

assert.equal(to(from(doc)), doc)
}
Expand All @@ -4562,7 +4562,7 @@ test('roundtrip', async function (t) {
await t.test(
'should roundtrip a thematic break at the start of a list item',
async function () {
const doc = '- ***\n'
const doc = '- ***\n'

assert.equal(to(from(doc)), doc)
}
Expand Down

0 comments on commit 019f25f

Please sign in to comment.