summaryrefslogtreecommitdiff
path: root/gnbug
diff options
context:
space:
mode:
authorArun Isaac2021-09-23 14:53:52 +0530
committerArun Isaac2021-09-23 14:53:52 +0530
commitd933c8f10db2f2637bbc4b5c9a729873fce4d314 (patch)
treeac871c730e8131864bb50b803a8bd72a93c21eff /gnbug
parent3e2b4aca15e8e230461d7ff1e33c86f155a160b8 (diff)
downloadgn-gemtext-d933c8f10db2f2637bbc4b5c9a729873fce4d314.tar.gz
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.
Diffstat (limited to 'gnbug')
-rwxr-xr-xgnbug10
1 files changed, 9 insertions, 1 deletions
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))