Skip to content

Commit

Permalink
feat: github task lists, close #215 (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Nov 9, 2017
1 parent b3c3180 commit d486eef
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 3 deletions.
20 changes: 20 additions & 0 deletions docs/de-de/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,23 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
[link](/demo ":target=_blank")
[link](/demo2 ":target=_self")
```


## Github Task Lists

```md

* [ ] foo
* bar
* [x] baz
* [] bam
* [ ] bim
* [ ] lim
```

* [ ] foo
* bar
* [x] baz
* [] bam
* [ ] bim
* [ ] lim
20 changes: 20 additions & 0 deletions docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,23 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
```md
[link](/demo ":disabled")
```

## Github Task Lists

```md

* [ ] foo
* bar
* [x] baz
* [] bam
* [ ] bim
* [ ] lim
```

* [ ] foo
* bar
* [x] baz
* [] bam
* [ ] bim
* [ ] lim

20 changes: 20 additions & 0 deletions docs/zh-cn/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,23 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
[link](/demo ":target=_blank")
[link](/demo2 ":target=_self")
```


## Github Task Lists

```md

* [ ] foo
* bar
* [x] baz
* [] bam
* [ ] bim
* [ ] lim
```

* [ ] foo
* bar
* [x] baz
* [] bam
* [ ] bim
* [ ] lim
9 changes: 9 additions & 0 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ export class Compiler {
return `<img src="${url}"data-origin="${href}" alt="${text}"${attrs}>`
}

const CHECKED_RE = /^\[([ x])\] +/
origin.listitem = renderer.listitem = function (text) {
const checked = CHECKED_RE.exec(text)
if (checked) {
text = text.replace(CHECKED_RE, `<input type="checkbox" ${checked[1] === 'x' ? 'checked' : ''} />`)
}
return `<li>${text}</li>\n`
}

renderer.origin = origin

return renderer
Expand Down
5 changes: 5 additions & 0 deletions src/themes/basic/_layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ kbd {
vertical-align: middle;
}

li input[type=checkbox] {
margin: 0 0.2em 0.25em -1.6em;
vertical-align: middle;
}

/* navbar */
.app-nav {
left: 0;
Expand Down
4 changes: 1 addition & 3 deletions src/themes/vue.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ body {
}

.markdown-section figure,
.markdown-section p,
.markdown-section ul,
.markdown-section ol {
.markdown-section p {
margin: 1.2em 0;
}

Expand Down

0 comments on commit d486eef

Please sign in to comment.