summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2021-09-23 01:02:35 +0530
committerArun Isaac2021-09-23 14:16:47 +0530
commita38d033f0e3f8b936e450e91afd1736ab263454f (patch)
tree529d8b43403727625489f7cef88c5b14c24d8a66
parentf7ed0ce8a3c9f23c31c71b47f344c9b90cfc30fb (diff)
downloadgn-gemtext-a38d033f0e3f8b936e450e91afd1736ab263454f.tar.gz
gnbug: Abstract out splitting on commas.
* gnbug (comma-split): New function. (file-details): Use comma-split.
-rwxr-xr-xgnbug12
1 files changed, 8 insertions, 4 deletions
diff --git a/gnbug b/gnbug
index 7e86438..acf02af 100755
--- a/gnbug
+++ b/gnbug
@@ -90,6 +90,12 @@ it is associated to the empty list."
(hashtable-update!
hashtable key (cut append <> new-values) '()))
+(define (comma-split str)
+ "Split string at commas, trim whitespace from both ends of the split
+strings, and return them as a list."
+ (map (cut string-trim-both <>)
+ (string-split str #\,)))
+
(define (file-details file)
"Return a hashtable of details extracted from gemini FILE."
(let ((result (make-eq-hashtable)))
@@ -101,10 +107,8 @@ it is associated to the empty list."
;; specify assignees.
((string-prefix? "* assigned:" line)
(hashtable-append! result 'assigned
- (map (cut string-trim-both <>)
- (string-split
- (substring line (string-length "* assigned:"))
- #\,))))))
+ (comma-split
+ (substring line (string-length "* assigned:")))))
;; The first level one heading is the
;; title.
((string-prefix? "# " line)