commit 5d750cb8221cca83b8aeccd4405926b08fef3143 from: aartaka date: Thu Jan 13 19:38:12 2022 UTC gemtext.lisp: Add blockquote support. commit - 59eabf3e4744859e2fd707b688425bd616d621bb commit + 5d750cb8221cca83b8aeccd4405926b08fef3143 blob - b1d981d0047eddca3cb1ff8a71a620b9c2916602 blob + bbe76f528a0364ebb1880c80b3e1e2d7371e5d87 --- gemtext.lisp +++ gemtext.lisp @@ -15,6 +15,9 @@ (defclass paragraph (element) ()) +(defclass blockquote (element) + ()) + (defclass verbatim (element) ((alt :initarg :alt))) @@ -40,6 +43,11 @@ (match (cl-ppcre:split "\\s+" s :limit 2) ((list _ text) (make-instance 'item :text text)))) +(defun parse-blockquote (s) + "Parse a line into a blockquote." + (match (cl-ppcre:split "\\s+" s :limit 2) + ((list _ text) (make-instance 'blockquote :text text)))) + (defun parse-line (s) (if (string= s "") (make-instance 'paragraph :text s) @@ -47,6 +55,7 @@ (#\# (parse-title s)) (#\= (parse-link s)) (#\* (parse-item s)) + (#\> (parse-blockquote s)) (otherwise (make-instance 'paragraph :text s))))) (defmacro markerp (line) @@ -114,3 +123,7 @@ (defmethod unparse ((v verbatim) stream) (with-slots (alt text) v (format stream "```~a~%~a```~%" alt text))) + +(defmethod unparse ((b blockquote) stream) + (with-slots (text) b + (format stream "> ~a~%" text)))