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

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