Skip to content

Commit 347c131

Browse files
committed
Don't match multi-line task titles
1 parent 5075255 commit 347c131

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/schedule_parser.janet

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@
99
:title (* "# " (some (+ :w+ :s+)))
1010
:tasks (group (any :task))
1111
:task (replace (* "- " :task-title :task-schedule (? "\n")) ,task/build-scheduled-task)
12-
:task-title (replace (capture (some (if-not "(" 1))) ,string/trim)
12+
:task-title (replace (capture (some (if-not (+ "(" "\n") 1))) ,string/trim)
1313
:task-schedule (* "(" (replace (capture (some (+ :w+ :s+ "-"))) ,string/trim) ")")})
1414

15+
(defn- task-lines-count
16+
```
17+
Returns the number of lines that start with '-' in the schedule string.
18+
```
19+
[schedule-string]
20+
(length (filter (fn [line] (string/has-prefix? "-" line))
21+
(string/split "\n" schedule-string))))
22+
1523
## —————————————————————————————————————————————————————————————————————————————
1624
## Public Interface
1725

@@ -28,5 +36,10 @@
2836
(let [tasks (first parse-result)]
2937
(if (empty? tasks)
3038
{:errors ["Schedule is empty"]}
31-
{:tasks tasks}))
39+
(do
40+
(if (= (length tasks) (task-lines-count schedule-string))
41+
{:tasks tasks}
42+
{:errors [(string "Schedule can not be parsed - last parsed task is \""
43+
((last tasks) :title)
44+
"\"")]}))))
3245
{:errors ["Schedule can not be parsed"]})))

0 commit comments

Comments
 (0)