feat: github task lists, close #215 (#305)

This commit is contained in:
cinwell.li 2017-11-09 13:06:23 +08:00 committed by GitHub
parent b3c3180bab
commit d486eef6cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -100,9 +100,7 @@ body {
}
.markdown-section figure,
.markdown-section p,
.markdown-section ul,
.markdown-section ol {
.markdown-section p {
margin: 1.2em 0;
}