From d933c8f10db2f2637bbc4b5c9a729873fce4d314 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 23 Sep 2021 14:53:52 +0530 Subject: gnbug: Accommodate DOS line endings in gemtext files. * gnbug (get-line-dos-or-unix): New function. (file-details): Use get-line-dos-or-unix instead of get-line. --- gnbug | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gnbug') diff --git a/gnbug b/gnbug index ac6ebbd..1bc682a 100755 --- a/gnbug +++ b/gnbug @@ -108,6 +108,14 @@ strings, and return them as a list." "Remove PREFIX from STR." (substring str (string-length prefix))) +(define (get-line-dos-or-unix port) + "Read line from PORT. This differs from `get-line' in (rnrs io +ports) in that it also supports DOS line endings." + (let ((line (get-line port))) + (if (eof-object? line) + line + (string-trim-right line #\return)))) + (define (file-details file) "Return a hashtable of details extracted from gemini FILE." (let ((result (make-eq-hashtable))) @@ -157,7 +165,7 @@ strings, and return them as a list." (hashtable-set! result 'title (remove-prefix "# " line))))))) (const #t) - get-line + get-line-dos-or-unix port))) result)) -- cgit v1.2.3