Make tasklist checkboxes clickable (#15791)

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
KN4CK3R 2021-05-23 16:14:03 +02:00 committed by GitHub
parent b4d10598c9
commit 6021fbfe7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 96 additions and 24 deletions

View file

@ -384,18 +384,19 @@ func (r *HTMLRenderer) renderTaskCheckBoxListItem(w util.BufWriter, source []byt
} else {
_, _ = w.WriteString("<li>")
}
end := ">"
if r.XHTML {
end = " />"
_, _ = w.WriteString(`<input type="checkbox" disabled=""`)
segments := node.FirstChild().Lines()
if segments.Len() > 0 {
segment := segments.At(0)
_, _ = w.WriteString(fmt.Sprintf(` data-source-position="%d"`, segment.Start))
}
var err error
if n.IsChecked {
_, err = w.WriteString(`<input type="checkbox" disabled="" checked=""` + end)
} else {
_, err = w.WriteString(`<input type="checkbox" disabled=""` + end)
_, _ = w.WriteString(` checked=""`)
}
if err != nil {
return ast.WalkStop, err
if r.XHTML {
_, _ = w.WriteString(` />`)
} else {
_ = w.WriteByte('>')
}
fc := n.FirstChild()
if fc != nil {