Handle task lists that start with numbers
This commit is contained in:
parent
2cd4c1420a
commit
7503033650
@ -23,7 +23,7 @@ import java.util.regex.Pattern;
|
|||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
class TaskListBlockParser extends AbstractBlockParser {
|
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*([-*+]|\\d+[.)])\\s+\\[(x|X|\\s)]\\s+(.*)");
|
||||||
|
|
||||||
private final TaskListBlock block = new TaskListBlock();
|
private final TaskListBlock block = new TaskListBlock();
|
||||||
|
|
||||||
@ -88,9 +88,9 @@ class TaskListBlockParser extends AbstractBlockParser {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
listItem = new TaskListItem()
|
listItem = new TaskListItem()
|
||||||
.done(isDone(matcher.group(1)))
|
.done(isDone(matcher.group(2)))
|
||||||
.indent(item.indent / 2);
|
.indent(item.indent / 2);
|
||||||
inlineParser.parse(matcher.group(2), listItem);
|
inlineParser.parse(matcher.group(3), listItem);
|
||||||
block.appendChild(listItem);
|
block.appendChild(listItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ input: |-
|
|||||||
+ [ ] First plus
|
+ [ ] First plus
|
||||||
+ [x] Second plus
|
+ [x] Second plus
|
||||||
+ [X] Third plus
|
+ [X] Third plus
|
||||||
|
1. [x] Number with dot
|
||||||
|
3) [ ] Number
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- task-list: "First"
|
- task-list: "First"
|
||||||
@ -45,3 +47,11 @@ output:
|
|||||||
- task-list: "Third plus"
|
- task-list: "Third plus"
|
||||||
blockIdent: 1
|
blockIdent: 1
|
||||||
done: true
|
done: true
|
||||||
|
- text: "\n"
|
||||||
|
- task-list: "Number with dot"
|
||||||
|
blockIdent: 1
|
||||||
|
done: true
|
||||||
|
- text: "\n"
|
||||||
|
- task-list: "Number"
|
||||||
|
blockIdent: 1
|
||||||
|
done: false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user