From 6021fbfe7a4e73c209eeea514a929fcb5598d63e Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sun, 23 May 2021 16:14:03 +0200 Subject: Make tasklist checkboxes clickable (#15791) Co-authored-by: silverwind Co-authored-by: Lauris BH --- modules/markup/markdown/goldmark.go | 19 ++++++++++--------- modules/markup/markdown/markdown_test.go | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'modules/markup/markdown') 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("
  • ") } - end := ">" - if r.XHTML { - end = " />" + _, _ = w.WriteString(` 0 { + segment := segments.At(0) + _, _ = w.WriteString(fmt.Sprintf(` data-source-position="%d"`, segment.Start)) } - var err error if n.IsChecked { - _, err = w.WriteString(``) + } else { + _ = w.WriteByte('>') } fc := n.FirstChild() if fc != nil { diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index 46a380aa6c..76c6d28d07 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -166,9 +166,9 @@ func testAnswers(baseURLContent, baseURLImages string) []string {

    (from https://www.markdownguide.org/extended-syntax/)

    Checkboxes

      -
    • unchecked
    • -
    • checked
    • -
    • still unchecked
    • +
    • unchecked
    • +
    • checked
    • +
    • still unchecked

    Definition list

    -- cgit v1.2.3