Skip to content

Commit 4857413

Browse files
committed
Refactor contact parser
1 parent f3ffa8c commit 4857413

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/contact/parser.janet

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
(? (* (constant :last-contact) :last-contact)))
1313
,contact/build-contact)
1414
:name (* "# " (? (some :d)) (replace (capture (some (if-not "\n" 1))) ,string/trim) "\n")
15-
:detail (+ :category :birthday :other-detail)
16-
:category (* "- Category: " (constant :category) (capture (+ "A" "a" "B" "b" "C" "c" "D" "d")) "\n")
17-
:birthday (* "- Birthday: " (constant :birthday) (capture (* :d :d "-" :d :d)) "\n")
18-
:other-detail (* "- " (some (if-not ":" 1)) ": " (some (if-not "\n" 1)) "\n")
15+
:detail
16+
{:main (+ :category :birthday :other-detail)
17+
:category (* "- Category: " (constant :category) (capture (+ "A" "a" "B" "b" "C" "c" "D" "d")) "\n")
18+
:birthday (* "- Birthday: " (constant :birthday) (capture (* :d :d "-" :d :d)) "\n")
19+
:other-detail (* "- " (some (if-not ":" 1)) ": " (some (if-not "\n" 1)) "\n")}
1920
:last-contact (* "## " (replace :date ,d/parse))
2021
:date (capture (* :d :d :d :d "-" :d :d "-" :d :d))})
2122

0 commit comments

Comments
 (0)