mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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>
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user