inline attrs in split-attrs-and-children
This commit is contained in:
parent
3138f7f7c5
commit
008fca8ed7
1 changed files with 16 additions and 0 deletions
|
@ -86,6 +86,8 @@
|
|||
((hash-table-p (first attrs-and-children))
|
||||
(values (make-attrs :alist (hash-alist (first attrs-and-children)))
|
||||
(flatten (rest attrs-and-children))))
|
||||
((vectorp (first attrs-and-children))
|
||||
(append-inline-attrs attrs-and-children))
|
||||
((keywordp (first attrs-and-children))
|
||||
(loop for thing on attrs-and-children by #'cddr
|
||||
for (k v) = thing
|
||||
|
@ -97,6 +99,20 @@
|
|||
(t
|
||||
(values (make-attrs :alist nil) (flatten attrs-and-children)))))
|
||||
|
||||
(defun append-inline-attrs (attrs-and-children)
|
||||
(let* ((inline-attrs (coerce (first attrs-and-children 'list)))
|
||||
(id (getf inline-attrs :id))
|
||||
(class (getf inline-attrs :class)))
|
||||
(multiple-value-bind (attrs children)
|
||||
(split-attrs-and-children (rest attrs-and-children))
|
||||
(when (and id (not (attr attrs :id)))
|
||||
(setf (attr attrs :id) id))
|
||||
(when class
|
||||
(if-let (other-class (attr attrs :class))
|
||||
(setf (attr attrs :class) (format nil "~a ~a" class other-class))
|
||||
(setf (attr attrs :class) class)))
|
||||
(values attrs children))))
|
||||
|
||||
(defun collect-until-dot-or-sharp (string)
|
||||
(let ((pos (position-if (lambda (c) (or (char= c #\.) (char= c #\#))) string)))
|
||||
(if pos
|
||||
|
|
Loading…
Reference in a new issue