diff options
author | Arun Isaac | 2021-09-23 14:53:52 +0530 |
---|---|---|
committer | Arun Isaac | 2021-09-23 14:53:52 +0530 |
commit | d933c8f10db2f2637bbc4b5c9a729873fce4d314 (patch) | |
tree | ac871c730e8131864bb50b803a8bd72a93c21eff /gnbug | |
parent | 3e2b4aca15e8e230461d7ff1e33c86f155a160b8 (diff) | |
download | gn-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-x | gnbug | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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)) |