summaryrefslogtreecommitdiffstats
path: root/helpers/content_renderer_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-09 13:08:20 +0200
committerGitHub <noreply@github.com>2016-09-09 13:08:20 +0200
commiteaf2f9bce5537a1dcbdb32dc62b9827e5a99585b (patch)
tree1ba3b7e24d8e5a68575e324be1a28471b050f48b /helpers/content_renderer_test.go
parent76bf2dcdd23f4cedb425f66503916a58698986dd (diff)
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
Diffstat (limited to 'helpers/content_renderer_test.go')
-rw-r--r--helpers/content_renderer_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/helpers/content_renderer_test.go b/helpers/content_renderer_test.go
index f96cf0ad5..7baaadb20 100644
--- a/helpers/content_renderer_test.go
+++ b/helpers/content_renderer_test.go
@@ -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)
+ }
+ }
+}