Index: code-docs/dust.scrbl ================================================================== --- code-docs/dust.scrbl +++ code-docs/dust.scrbl @@ -53,15 +53,10 @@ every Pollen document in @racket[series-path]. The pagenodes themselves point to the rendered @tt{.html} targets of the source documents. @section{Metas and @code{txexpr}s} -@defproc[(attr-present? [name symbol?] [attrs (listof pair?)]) boolean?] - -Shortsightedly redundant to @code{attrs-have-key?}. Returns @code{#t} if @racket[_name] is one of -the attributes present in @racket[_attrs], otherwise returns @code{#f}. - @defproc[(maybe-attr [key symbol?] [attrs txexpr-attrs?] [missing-expr any/c ""]) any/c] Find the value of @racket[_key] in the supplied list of attributes, returning the value of @racket[_missing-expr] if it’s not there. Index: dust.rkt ================================================================== --- dust.rkt +++ dust.rkt @@ -35,11 +35,10 @@ (provide maybe-meta ; Select from (current-metas) or default value ("") if not available maybe-attr ; Return an attribute’s value or a default ("") if not available series-noun ; Retrieve noun-singular from current 'series meta, or "" series-title ; Retrieve title of series in current 'series meta, or "" series-pagenode - attr-present? ; Test if an attribute is present make-tag-predicate tx-strs ymd->english ymd->dateformat default-authorname @@ -102,14 +101,10 @@ (define (series-pagetree) `(root ,@(include-in-pagetree series-path ".poly.pm"))) ;; ~~~ Convenience functions for tagged x-expressions ~~~ -(define (attr-present? name attrs) - (for/or ([attr-pair (in-list attrs)]) - (equal? name (car attr-pair)))) - (define (maybe-attr name attrs [missing ""]) (define result (assoc name attrs)) (cond [(pair? result) (cadr result)] [else missing])) @@ -132,12 +127,10 @@ (parameterize ([current-metas test-metas]) (check-equal? (maybe-meta 'name) "Fiver") ; present meta (check-equal? (maybe-meta 'age) "") ; missing meta (check-equal? (maybe-meta 'age 2) 2)) ; alternate default value - (check-equal? (attr-present? 'name test-attrs) #t) - (check-equal? (attr-present? 'dingus test-attrs) #f) (check-equal? (maybe-attr 'rank test-attrs) "Chief") (check-equal? (maybe-attr 'dingus test-attrs) "") (check-equal? (maybe-attr 'dingus test-attrs "zippy") "zippy")) ;; Return the first N words out of a list of txexprs. This function will unpack the strings out of @@ -223,11 +216,11 @@ "_" (uri-encode (maybe-attr 'author (get-attrs txpr) default-authorname)))) ;; Extract the last disposition (if any), and the ID of the disposing note, out of a list of notes (define (notes->last-disposition-values txprs) - (define (contains-disposition? tx) (attr-present? 'disposition (get-attrs tx))) + (define (contains-disposition? tx) (attrs-have-key? tx 'disposition)) (define disp-notes (filter contains-disposition? txprs)) (cond [(not (empty? disp-notes)) (define latest-disposition-note (last disp-notes)) (values (attr-ref latest-disposition-note 'disposition) (build-note-id latest-disposition-note))]