Skip to content
This repository was archived by the owner on Apr 8, 2019. It is now read-only.

Commit ebd8657

Browse files
committed
Fix #17
- vertical align of checkbox still some style problem, but ... anyway
1 parent e29ea65 commit ebd8657

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

doc/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ var y = 3
3030

3131
- [ ] a
3232
- [x] b
33+
- I am just a simple list
34+
- [x] checked
35+
- [ ] not checked
3336

3437
## Contribute
3538

lib/renderer/toc-renderer.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ TocRenderer.prototype.heading = function (text, level) {
1919
};
2020

2121
// TODO: move the to do list render to another file
22-
TocRenderer.prototype.listitem = function(text) {
22+
TocRenderer.prototype.listitem = function (text) {
2323
if (/^\s*\[[x ]\]\s*/.test(text)) {
2424
text = text
25-
.replace(/^\s*\[ \]\s*/, '<input type="checkbox" disabled>')
26-
.replace(/^\s*\[x\]\s*/, '<input type="checkbox" checked disabled>');
27-
return '<li class="check-list-item">' + text + '</li>';
25+
.replace(/^\s*\[ \]\s*/,
26+
'<input type="checkbox" class="task-list-item-checkbox" disabled>')
27+
.replace(/^\s*\[x\]\s*/,
28+
'<input type="checkbox" class="task-list-item-checkbox" checked disabled>');
29+
return '<li class="task-list-item">' + text + '</li>';
2830
} else {
2931
return '<li>' + text + '</li>';
3032
}

public/assets/style/bundle.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ul {
3535
width: 70%;
3636
height: 100%;
3737
overflow: auto; }
38+
.markdown-content li.task-list-item {
39+
list-style: none; }
40+
.markdown-content li.task-list-item .task-list-item-checkbox {
41+
margin: 0 0.35em 0.25em -1.6em;
42+
vertical-align: middle;
43+
cursor: default; }
3844

3945
.markdown-toc {
4046
position: fixed;

views/assets/style/layout.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ ul{
4848
height: 100%;
4949

5050
overflow: auto;
51+
52+
li.task-list-item {
53+
list-style: none;
54+
55+
.task-list-item-checkbox {
56+
// copied from github...
57+
margin: 0 0.35em 0.25em -1.6em;
58+
vertical-align: middle;
59+
// otherwise the cursor would show a forbidden icon
60+
cursor: default;
61+
}
62+
}
5163
}
5264

5365
.markdown-toc{

0 commit comments

Comments
 (0)