From 2cd4c1420a980b2a0e645687add8624ab5b52f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Rutkowski?= Date: Sun, 17 Feb 2019 19:02:41 +0100 Subject: [PATCH] Handle task lists that start with * or + symbol --- .../markwon/tasklist/TaskListBlockParser.java | 2 +- .../src/test/resources/tests/task-list.yaml | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 markwon/src/test/resources/tests/task-list.yaml diff --git a/markwon/src/main/java/ru/noties/markwon/tasklist/TaskListBlockParser.java b/markwon/src/main/java/ru/noties/markwon/tasklist/TaskListBlockParser.java index 4c2ab99a..6b0c7aaa 100644 --- a/markwon/src/main/java/ru/noties/markwon/tasklist/TaskListBlockParser.java +++ b/markwon/src/main/java/ru/noties/markwon/tasklist/TaskListBlockParser.java @@ -23,7 +23,7 @@ import java.util.regex.Pattern; @SuppressWarnings("WeakerAccess") class TaskListBlockParser extends AbstractBlockParser { - private static final Pattern PATTERN = Pattern.compile("\\s*-\\s+\\[(x|X|\\s)\\]\\s+(.*)"); + private static final Pattern PATTERN = Pattern.compile("\\s*[-*+]\\s+\\[(x|X|\\s)\\]\\s+(.*)"); private final TaskListBlock block = new TaskListBlock(); diff --git a/markwon/src/test/resources/tests/task-list.yaml b/markwon/src/test/resources/tests/task-list.yaml new file mode 100644 index 00000000..ebde6ab8 --- /dev/null +++ b/markwon/src/test/resources/tests/task-list.yaml @@ -0,0 +1,47 @@ +input: |- + - [ ] First + - [x] Second + - [X] Third + * [ ] First star + * [x] Second star + * [X] Third star + + [ ] First plus + + [x] Second plus + + [X] Third plus + +output: + - task-list: "First" + blockIdent: 1 + done: false + - text: "\n" + - task-list: "Second" + blockIdent: 1 + done: true + - text: "\n" + - task-list: "Third" + blockIdent: 1 + done: true + - text: "\n" + - task-list: "First star" + blockIdent: 1 + done: false + - text: "\n" + - task-list: "Second star" + blockIdent: 1 + done: true + - text: "\n" + - task-list: "Third star" + blockIdent: 1 + done: true + - text: "\n" + - task-list: "First plus" + blockIdent: 1 + done: false + - text: "\n" + - task-list: "Second plus" + blockIdent: 1 + done: true + - text: "\n" + - task-list: "Third plus" + blockIdent: 1 + done: true