/ traversal /
/traversal/pt.lisp
 1 (in-package #:oh-ducks.traversal)
 2 
 3 (defmethod unify::occurs-in-p ((var symbol) (pat chtml:pt) env)
 4   (declare (ignore var pat env))
 5   nil)
 6 
 7 ;;; general accessors
 8 
 9 (defmethod element-children ((element chtml:pt))
10   (remove-if (compose (rcurry #'member '(:pcdata :comment) :test #'eq) #'chtml:pt-name)
11              (chtml:pt-children element)))
12 
13 (defmethod element-parent ((element chtml:pt))
14   (chtml:pt-parent element))
15 
16 (defmethod element-attribute ((element-attribute symbol) (element chtml:pt))
17   (getf (chtml:pt-attrs element) element-attribute))
18 (defmethod element-attribute ((element-attribute string) (element chtml:pt))
19   (element-attribute (intern (string-upcase element-attribute) :keyword) element))
20 
21 (defmethod element-type ((element chtml:pt))
22   (chtml:pt-name element))
23 
24 (defmethod element-content ((element chtml:pt))
25   (mapcar (lambda (node)
26             (cond
27               ((eq :pcdata (chtml:pt-name node))
28                (chtml:pt-attrs node))
29               (t node)))
30           (remove-if (curry #'eq :comment)
31                      (chtml:pt-children element)
32                      :key #'chtml:pt-name)))