commit 0276d7708733672f17b88aacd62a3092b0137019 from: Omar Polo date: Wed Nov 11 16:52:18 2020 UTC revert the relative-to hack was added only to ease the job of the UI, but it isn’t the right place. The UI should do that type of checks, the parsers shouldn’t mangle URIs. commit - 073b25eb0b22b8306c6e711aff1483a20be2f8f8 commit + 0276d7708733672f17b88aacd62a3092b0137019 blob - e60cb1bfca592cf15d1b03512995e0e754a48ee2 blob + b1d981d0047eddca3cb1ff8a71a620b9c2916602 --- gemtext.lisp +++ gemtext.lisp @@ -1,7 +1,5 @@ (in-package #:phos/gemtext) -(defparameter *relative-to* nil) - (defclass element () ((text :initarg :text))) @@ -28,13 +26,8 @@ :text text))) (defun make-link (url &optional text) - (if *relative-to* - (let ((u (quri:copy-uri *relative-to*))) - (setf (quri:uri-path u) url) - (make-instance 'link :url u - :text text)) - (make-instance 'link :url (quri:uri url) - :text text))) + (make-instance 'link :url (quri:uri url) + :text text)) (defun parse-link (s) "Parse a line into link." @@ -59,14 +52,9 @@ (defmacro markerp (line) `(uiop:string-prefix-p "```" ,line)) -(defun parse (in &optional relative-to) - "Parse gemtext from the stream IN. - -RELATIVE-TO is the base URL of the page, it is used to transform url -to absolute urls, if null the transformation does not happen." +(defun parse (in) + "Parse gemtext from the stream IN." (loop with doc = nil - with *relative-to* = (when relative-to - (quri:uri relative-to)) for line = (read-line in nil) unless line return (nreverse doc) @@ -86,11 +74,10 @@ to absolute urls, if null the transformation does not (parse-line line)) doc))) -(defun parse-string (str &optional relative-to) - "Parse the string STR as gemtext. See the documentation of `parse' -for more info." +(defun parse-string (str) + "Parse the string STR as gemtext." (with-input-from-string (s str) - (parse s relative-to))) + (parse s))) ;; (unparse ;; (with-open-file (stream #P"~/quicklisp/local-projects/phos/test.gmi")