Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: github task lists, close #215 #305

Merged
merged 1 commit into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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