Skip to content

Commit

Permalink
Delete html-string-p and related logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
aadcg committed Jan 15, 2024
1 parent 613454f commit bf3431c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 35 deletions.
4 changes: 1 addition & 3 deletions source/mode/message.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ Mainly used on `list-messages' page."
(:h1 "Messages")
(:ul
(loop for message in (reverse (nyxt:messages-content *browser*))
collect (if (html-string-p message)
(:li (:raw message))
(:li (:pre message)))))))
collect (:li (:pre message))))))
10 changes: 0 additions & 10 deletions source/spinneret-tags.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@

(in-package :spinneret)

(deftag :mayberaw (body attrs &rest keys &key &allow-other-keys)
"Spinneret's :raw, but with HTML escaping if BODY _does not_ look like HTML."
;; Because (declare (ignorable ...)) doesn't work.
(let ((attrs attrs)
(keys keys))
(declare (ignorable attrs keys))
`(:raw (if (nyxt:html-string-p (progn ,@body))
(progn ,@body)
(escape-string (progn ,@body))))))

(defun %nstyle-body (forms)
(reduce #'uiop:strcat
(mapcar (lambda (f) (typecase f
Expand Down
12 changes: 5 additions & 7 deletions source/status.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ Augment this with `style' of STATUS, if necessary."
collect
(let ((mode mode))
(alex:when-let ((formatted-mode (mode-status status mode)))
(if (html-string-p formatted-mode)
(:raw formatted-mode)
(:nbutton
:buffer status
:text formatted-mode
:title (format nil "Describe ~a" mode)
`(describe-class :class (quote ,(name mode))))))))))
(:nbutton
:buffer status
:text formatted-mode
:title (format nil "Describe ~a" mode)
`(describe-class :class (quote ,(name mode)))))))))
"")))

(defun modes-string (buffer)
Expand Down
15 changes: 0 additions & 15 deletions source/types.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,6 @@ Unlike `(cons TYPE *)', it checks all the elements.
'(member :character :word :sentence :line :paragraph :lineboundary
:sentenceboundary :paragraphboundary :documentboundary))

(export-always 'html-string-p)
(defun html-string-p (string)
"Check whether the STRING is an HTML string:
- Having proper starting/ending tags.
- Being parseable with Plump."
(serapeum:and-let*
((string string)
(-p (stringp string))
(trimmed (string-trim serapeum:whitespace string))
(has-closing-tag (ppcre:scan "</\\w+>$" trimmed))
(html (ignore-errors (plump:parse trimmed)))
(single-child (serapeum:single (plump:children html)))
(child (elt (plump:children html) 0)))
(plump:element-p child)))

(export-always 'maybe)
(deftype maybe (&rest types)
"An optional/maybe type for a value that is either one of TYPES, or NIL."
Expand Down

0 comments on commit bf3431c

Please sign in to comment.