mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Add task class to all task list items
This commit is contained in:
parent
56bbdf0370
commit
e1f61bb156
2 changed files with 9 additions and 7 deletions
|
|
@ -4,8 +4,8 @@
|
|||
- [x] bar
|
||||
//- - - - - - - - -//
|
||||
<ul>
|
||||
<li><input disabled="" type="checkbox"> foo</li>
|
||||
<li><input checked="" disabled="" type="checkbox"> bar</li>
|
||||
<li class="task"><input disabled="" type="checkbox"> foo</li>
|
||||
<li class="task"><input checked="" disabled="" type="checkbox"> bar</li>
|
||||
</ul>
|
||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||
|
||||
|
|
@ -19,12 +19,12 @@
|
|||
- [ ] bim
|
||||
//- - - - - - - - -//
|
||||
<ul>
|
||||
<li><input checked="" disabled="" type="checkbox"> foo
|
||||
<li class="task"><input checked="" disabled="" type="checkbox"> foo
|
||||
<ul>
|
||||
<li><input disabled="" type="checkbox"> bar</li>
|
||||
<li><input checked="" disabled="" type="checkbox"> baz</li>
|
||||
<li class="task"><input disabled="" type="checkbox"> bar</li>
|
||||
<li class="task"><input checked="" disabled="" type="checkbox"> baz</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><input disabled="" type="checkbox"> bim</li>
|
||||
<li class="task"><input disabled="" type="checkbox"> bim</li>
|
||||
</ul>
|
||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ func (s *taskCheckBoxParser) Parse(parent gast.Node, block text.Reader, pc parse
|
|||
return nil
|
||||
}
|
||||
|
||||
if _, ok := parent.Parent().(*gast.ListItem); !ok {
|
||||
listItem, ok := parent.Parent().(*gast.ListItem)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
line, _ := block.PeekLine()
|
||||
|
|
@ -48,6 +49,7 @@ func (s *taskCheckBoxParser) Parse(parent gast.Node, block text.Reader, pc parse
|
|||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
listItem.SetAttributeString("class", []byte("task"))
|
||||
value := line[m[2]:m[3]][0]
|
||||
block.Advance(m[1])
|
||||
checked := value == 'x' || value == 'X'
|
||||
|
|
|
|||
Loading…
Reference in a new issue