diff options
author | zeripath <art27@cantab.net> | 2020-04-26 06:09:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-26 02:09:08 -0300 |
commit | 9f959ac0641821148e46d0899b74cc714c858879 (patch) | |
tree | f878ad83c9cd2c942aa0f99959cab7f248469ee1 /modules/markup/markdown/ast.go | |
parent | f1f56da4d1339345ffea68d675e972648bd60a59 (diff) | |
download | gitea-9f959ac0641821148e46d0899b74cc714c858879.tar.gz gitea-9f959ac0641821148e46d0899b74cc714c858879.zip |
Make TaskCheckBox render correctly (#11214)
* Fix checkbox rendering
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Normalize checkbox rendering
Signed-off-by: Andrew Thornton <art27@cantab.net>
* set the checkboxes to readonly instead of disabled
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/markup/markdown/ast.go')
-rw-r--r-- | modules/markup/markdown/ast.go | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/modules/markup/markdown/ast.go b/modules/markup/markdown/ast.go index f79d12435b..d735ff5ebd 100644 --- a/modules/markup/markdown/ast.go +++ b/modules/markup/markdown/ast.go @@ -4,7 +4,11 @@ package markdown -import "github.com/yuin/goldmark/ast" +import ( + "strconv" + + "github.com/yuin/goldmark/ast" +) // Details is a block that contains Summary and details type Details struct { @@ -70,6 +74,41 @@ func IsSummary(node ast.Node) bool { return ok } +// TaskCheckBoxListItem is a block that repressents a list item of a markdown block with a checkbox +type TaskCheckBoxListItem struct { + *ast.ListItem + IsChecked bool +} + +// KindTaskCheckBoxListItem is the NodeKind for TaskCheckBoxListItem +var KindTaskCheckBoxListItem = ast.NewNodeKind("TaskCheckBoxListItem") + +// Dump implements Node.Dump . +func (n *TaskCheckBoxListItem) Dump(source []byte, level int) { + m := map[string]string{} + m["IsChecked"] = strconv.FormatBool(n.IsChecked) + ast.DumpHelper(n, source, level, m, nil) +} + +// Kind implements Node.Kind. +func (n *TaskCheckBoxListItem) Kind() ast.NodeKind { + return KindTaskCheckBoxListItem +} + +// NewTaskCheckBoxListItem returns a new TaskCheckBoxListItem node. +func NewTaskCheckBoxListItem(listItem *ast.ListItem) *TaskCheckBoxListItem { + return &TaskCheckBoxListItem{ + ListItem: listItem, + } +} + +// IsTaskCheckBoxListItem returns true if the given node implements the TaskCheckBoxListItem interface, +// otherwise false. +func IsTaskCheckBoxListItem(node ast.Node) bool { + _, ok := node.(*TaskCheckBoxListItem) + return ok +} + // Icon is an inline for a fomantic icon type Icon struct { ast.BaseInline |