diff options
author | Arun Isaac | 2021-09-23 01:03:41 +0530 |
---|---|---|
committer | Arun Isaac | 2021-09-23 14:16:47 +0530 |
commit | e903921f464ab1929063f776074a06093685a140 (patch) | |
tree | 94d72149374dde2163f5ccee4c7d3b6ab154c400 | |
parent | a38d033f0e3f8b936e450e91afd1736ab263454f (diff) | |
download | gn-gemtext-e903921f464ab1929063f776074a06093685a140.tar.gz |
gnbug: Abstract out string prefix removal.
* gnbug (remove-prefix): New function.
(file-details): Use remove-prefix.
-rwxr-xr-x | gnbug | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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))) |