summaryrefslogtreecommitdiff
path: root/gnbug
diff options
context:
space:
mode:
authorArun Isaac2021-09-23 01:03:41 +0530
committerArun Isaac2021-09-23 14:16:47 +0530
commite903921f464ab1929063f776074a06093685a140 (patch)
tree94d72149374dde2163f5ccee4c7d3b6ab154c400 /gnbug
parenta38d033f0e3f8b936e450e91afd1736ab263454f (diff)
downloadgn-gemtext-e903921f464ab1929063f776074a06093685a140.tar.gz
gnbug: Abstract out string prefix removal.
* gnbug (remove-prefix): New function. (file-details): Use remove-prefix.
Diffstat (limited to 'gnbug')
-rwxr-xr-xgnbug8
1 files changed, 6 insertions, 2 deletions
diff --git a/gnbug b/gnbug
index acf02af..caa474a 100755
--- a/gnbug
+++ b/gnbug
@@ -96,6 +96,10 @@ strings, and return them as a list."
(map (cut string-trim-both <>)
(string-split str #\,)))
+(define (remove-prefix prefix str)
+ "Remove PREFIX from STR."
+ (substring str (string-length prefix)))
+
(define (file-details file)
"Return a hashtable of details extracted from gemini FILE."
(let ((result (make-eq-hashtable)))
@@ -108,13 +112,13 @@ strings, and return them as a list."
((string-prefix? "* assigned:" line)
(hashtable-append! result 'assigned
(comma-split
- (substring line (string-length "* assigned:")))))
+ (remove-prefix "* assigned:" line))))
;; The first level one heading is the
;; title.
((string-prefix? "# " line)
(unless (hashtable-contains? result 'title)
(hashtable-set! result 'title
- (substring line (string-length "# "))))))))
+ (remove-prefix "# " line)))))))
(const #t)
read-line
port)))