diff --git a/src/main/scala/view/Markdown.scala b/src/main/scala/view/Markdown.scala index e7c9cd6..d06dc1f 100644 --- a/src/main/scala/view/Markdown.scala +++ b/src/main/scala/view/Markdown.scala @@ -157,6 +157,28 @@ printWithAbbreviations(text) } } + + override def visit(node: BulletListNode): Unit = { + if (printChildrenToString(node).contains("""class="task-list-item-checkbox" """)) { + printer.println().print("""") + } else { + printIndentedTag(node, "ul") + } + } + + override def visit(node: ListItemNode): Unit = { + if (printChildrenToString(node).contains("""class="task-list-item-checkbox" """)) { + printer.println() + printer.print("""
  • """) + visitChildren(node) + printer.print("
  • ") + } else { + printer.println() + printTag(node, "li") + } + } } object GitBucketHtmlSerializer { @@ -171,12 +193,12 @@ } def escapeTaskList(text: String): String = { - Pattern.compile("""^ *- \[([x| ])\] """, Pattern.MULTILINE).matcher(text).replaceAll("task:$1: ") + Pattern.compile("""^( *)- \[([x| ])\] """, Pattern.MULTILINE).matcher(text).replaceAll("$1* task:$2: ") } def convertCheckBox(text: String, hasWritePermission: Boolean): String = { val disabled = if (hasWritePermission) "" else "disabled" - text.replaceAll("task:x:", """") - .replaceAll("task: :", """") + text.replaceAll("task:x:", """") + .replaceAll("task: :", """") } } diff --git a/src/main/webapp/assets/common/css/gitbucket.css b/src/main/webapp/assets/common/css/gitbucket.css index fecaa36..211277f 100644 --- a/src/main/webapp/assets/common/css/gitbucket.css +++ b/src/main/webapp/assets/common/css/gitbucket.css @@ -814,6 +814,20 @@ background-color: white; } +ul.task-list { + padding-left: 2em; + margin-left: 0; +} + +li.task-list-item { + list-style-type: none; +} + +li.task-list-item input.task-list-item-checkbox { + margin: 0 4px 0.25em -20px; + vertical-align: middle; +} + /****************************************************************************/ /* Pull Request */ /****************************************************************************/ diff --git a/src/test/scala/view/GitBucketHtmlSerializerSpec.scala b/src/test/scala/view/GitBucketHtmlSerializerSpec.scala index 5b49c88..687db70 100644 --- a/src/test/scala/view/GitBucketHtmlSerializerSpec.scala +++ b/src/test/scala/view/GitBucketHtmlSerializerSpec.scala @@ -27,28 +27,28 @@ } "escapeTaskList" should { - "convert '- [ ] ' to 'task: :'" in { + "convert '- [ ] ' to '* task: :'" in { val before = "- [ ] aaaa" val after = escapeTaskList(before) - after mustEqual "task: : aaaa" + after mustEqual "* task: : aaaa" } - "convert ' - [ ] ' to 'task: :'" in { + "convert ' - [ ] ' to ' * task: :'" in { val before = " - [ ] aaaa" val after = escapeTaskList(before) - after mustEqual "task: : aaaa" + after mustEqual " * task: : aaaa" } "convert only first '- [ ] '" in { val before = " - [ ] aaaa - [ ] bbb" val after = escapeTaskList(before) - after mustEqual "task: : aaaa - [ ] bbb" + after mustEqual " * task: : aaaa - [ ] bbb" } - "convert '- [x] ' to 'task: :'" in { + "convert '- [x] ' to '* task:x:'" in { val before = " - [x] aaaa" val after = escapeTaskList(before) - after mustEqual "task:x: aaaa" + after mustEqual " * task:x: aaaa" } "convert multi lines" in { @@ -60,8 +60,8 @@ val after = escapeTaskList(before) after mustEqual """ tasks -task:x: aaaa -task: : bbb +* task:x: aaaa +* task: : bbb """ }