diff options
author | KN4CK3R <KN4CK3R@users.noreply.github.com> | 2021-05-23 16:14:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-23 17:14:03 +0300 |
commit | 6021fbfe7a4e73c209eeea514a929fcb5598d63e (patch) | |
tree | 0058ceeaa2df9d20655aae7ad78c82f3e0f7623e /modules/markup/markdown/goldmark.go | |
parent | b4d10598c9be1ba8008c5a47ef1cd3612e99331a (diff) | |
download | gitea-6021fbfe7a4e73c209eeea514a929fcb5598d63e.tar.gz gitea-6021fbfe7a4e73c209eeea514a929fcb5598d63e.zip |
Make tasklist checkboxes clickable (#15791)
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/markup/markdown/goldmark.go')
-rw-r--r-- | modules/markup/markdown/goldmark.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/modules/markup/markdown/goldmark.go b/modules/markup/markdown/goldmark.go index ad77177db4..f1c259f824 100644 --- a/modules/markup/markdown/goldmark.go +++ b/modules/markup/markdown/goldmark.go @@ -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 { |