1
0
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:
Bjørn Erik Pedersen
2016-09-09 13:08:20 +02:00
committed by GitHub
parent 76bf2dcdd2
commit eaf2f9bce5
6 changed files with 145 additions and 3 deletions

View File

@@ -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)
}
}
}