mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
Add TODO list support for Blackfriday
* Add CSS class to TODO list and list items * Add a flag to turn task list support off Fixes #2269
This commit is contained in:
committed by
GitHub
parent
76bf2dcdd2
commit
eaf2f9bce5
@@ -88,3 +88,44 @@ func TestCodeFence(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlackfridayTaskList(t *testing.T) {
|
||||
for i, this := range []struct {
|
||||
markdown string
|
||||
taskListEnabled bool
|
||||
expect string
|
||||
}{
|
||||
{`
|
||||
TODO:
|
||||
|
||||
- [x] On1
|
||||
- [X] On2
|
||||
- [ ] Off
|
||||
|
||||
END
|
||||
`, true, `<p>TODO:</p>
|
||||
|
||||
<ul class="task-list">
|
||||
<li><input type="checkbox" checked disabled class="task-list-item"> On1</li>
|
||||
<li><input type="checkbox" checked disabled class="task-list-item"> On2</li>
|
||||
<li><input type="checkbox" disabled class="task-list-item"> Off</li>
|
||||
</ul>
|
||||
|
||||
<p>END</p>
|
||||
`},
|
||||
{`- [x] On1`, false, `<ul>
|
||||
<li>[x] On1</li>
|
||||
</ul>
|
||||
`},
|
||||
} {
|
||||
blackFridayConfig := NewBlackfriday(viper.GetViper())
|
||||
blackFridayConfig.TaskLists = this.taskListEnabled
|
||||
ctx := &RenderingContext{Content: []byte(this.markdown), PageFmt: "markdown", Config: blackFridayConfig}
|
||||
|
||||
result := string(RenderBytes(ctx))
|
||||
|
||||
if result != this.expect {
|
||||
t.Errorf("[%d] got \n%v but expected \n%v", i, result, this.expect)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user