Commit Diff
Diff:
588b55fbdbdb143bad22870345f7d91d8e7b7bf5
4800325e843eb78d81f26caa2e281fd33257405c
Commit:
4800325e843eb78d81f26caa2e281fd33257405c
Tree:
dc89ef2e0cd5cfb4024f0ca08fe0cade5b92534f
Author:
aartaka <aartaka@protonmail.com>
Date:
Mon Jan 17 09:29:35 2022 UTC
Message:
gemtext: Enrich gemtext classes definitions.

This adds:
- :type options.
- :documentation options.
- :accessor options.
- Class predicates.
Wherever applicable.
commit - 588b55fbdbdb143bad22870345f7d91d8e7b7bf5
commit + 4800325e843eb78d81f26caa2e281fd33257405c
blob - 564a9499b29181fc2547d366882a4af7c680f7a7
blob + 94de3e9649d71506720e08bfbbc32011c1ab3138
--- gemtext.lisp
+++ gemtext.lisp
@@ -1,14 +1,24 @@
(in-package #:phos/gemtext)
(defclass element ()
- ((text :initarg :text
- :initform "")))
+ ((text :initform ""
+ :initarg :text
+ :accessor text
+ :type string)))
(defclass title (element)
- ((level :initarg :level)))
+ ((level :initarg :level
+ :accessor level
+ :type integer
+ :documentation "The nesting level of the title.
+Synonymous to the HTML heading levels, i.e. level 1 is <h1> tag, level 2 is <h2> tag etc.")))
+
(defclass link (element)
- ((url :initarg :url)))
+ ((url :initform nil
+ :initarg :url
+ :accessor url
+ :type (or null string))))
(defclass item (element)
())
@@ -20,8 +30,25 @@
())
(defclass verbatim (element)
- ((alt :initarg :alt)))
+ ((alt :initform nil
+ :initarg :alt
+ :accessor alt
+ :type (or null string)
+ :documentation "The alternative text for the verbatim block.
+Is usually put at the same line as the opening backquotes.
+
+Can be a programming language name or alternative text for, e.g., ASCII art.")))
+
+(defun element-p (element) (typep element 'element))
+(defun title-p (title) (typep title 'title))
+(defun link-p (link) (typep link 'link))
+(defun item-p (item) (typep item 'item))
+(defun paragraph-p (paragraph) (typep paragraph 'paragraph))
+(defun blockquote-p (blockquote) (typep blockquote 'blockquote))
+(defun verbatim-p (verbatim) (typep verbatim 'verbatim))
+
+
(defun make-link (url &optional text)
(make-instance 'link :url (quri:uri url)
:text text))
blob - b040249f5068643784924c935564d691b1afd7b4
blob + 5e7d00632ccd96b9f5c3965433a154c3c58cc3c2
--- package.lisp
+++ package.lisp
@@ -8,6 +8,7 @@
(:nicknames :gemtext)
(:use #:cl #:trivia)
(:export :element :title :link :item :blockquote :paragraph :verbatim
+ :element-p :title-p :link-p :item-p :blockquote-p :paragraph-p :verbatim-p
:text :url :alt :level
:parse :parse-string :unparse :line-eq))
Omar Polo