Skip to content

Commit 046451e

Browse files
rhysdwooorm
authored andcommitted
Add task-list-item class to checkbox lists
According to github-markdown-css, 'task-list-item' class will hide the bullets on the head of list items. Closes GH-2.
1 parent cc460cb commit 046451e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/handlers/list-item.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function listItem(h, node, parent) {
3232
var single = (!parent || !parent.loose) && head.children && children.length === 1;
3333
var result = all(h, single ? head : node);
3434
var container;
35+
var props = {};
3536

3637
if (typeof node.checked === 'boolean') {
3738
if (!single && head.type !== 'paragraph') {
@@ -49,11 +50,14 @@ function listItem(h, node, parent) {
4950
checked: node.checked,
5051
disabled: true
5152
}));
53+
54+
/* according to github-markdown-css, this class hides bullet. */
55+
props.className = ['task-list-item'];
5256
}
5357

5458
if (!single && result.length) {
5559
result = wrap(result, true);
5660
}
5761

58-
return h(node, 'li', result);
62+
return h(node, 'li', props, result);
5963
}

test/list-item.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ test('ListItem', function (t) {
5050
to(u('listItem', {checked: true}, [
5151
u('paragraph', [u('text', 'québec')])
5252
])),
53-
u('element', {tagName: 'li', properties: {}}, [
53+
u('element', {tagName: 'li', properties: {className: ['task-list-item']}}, [
5454
u('element', {
5555
tagName: 'input',
5656
properties: {
@@ -70,7 +70,7 @@ test('ListItem', function (t) {
7070
u('paragraph', [u('text', 'romeo')]),
7171
u('paragraph', [u('text', 'sierra')])
7272
])),
73-
u('element', {tagName: 'li', properties: {}}, [
73+
u('element', {tagName: 'li', properties: {className: ['task-list-item']}}, [
7474
u('text', '\n'),
7575
u('element', {tagName: 'p', properties: {}}, [
7676
u('element', {
@@ -97,7 +97,7 @@ test('ListItem', function (t) {
9797
to(u('listItem', {checked: true}, [
9898
u('html', '<!--tango-->')
9999
])),
100-
u('element', {tagName: 'li', properties: {}}, [
100+
u('element', {tagName: 'li', properties: {className: ['task-list-item']}}, [
101101
u('text', '\n'),
102102
u('element', {tagName: 'p', properties: {}}, [
103103
u('element', {

0 commit comments

Comments
 (0)