Index: code-docs/dust.scrbl ================================================================== --- code-docs/dust.scrbl +++ code-docs/dust.scrbl @@ -101,21 +101,22 @@ @examples[#:eval dust-eval (tx-strs '(p [[class "intro"]] (em "I’m not opening the safe") ", Wilson remembers thinking."))] -@defproc[(make-tag-predicate [sym symbol?]) (-> any/c boolean?)] +@defproc[(make-tag-predicate [sym symbol?] ...) (-> any/c boolean?)] Returns a function (or @italic{predicate}) that returns @racket[#t] if its argument is -a @racket[_txexpr] whose tag is @racket[_sym]. This predicate is useful for passing as the +a @racket[_txexpr] whose tag matches any @racket[_sym]. This predicate is useful for passing as the @racket[_pred] expression in functions @racket[splitf-txexpr] and @racket[findf-txexpr]. -@examples[#:eval dust-eval -(define is-aside? (make-tag-predicate 'aside)) +@examples[#:eval dust-eval +(define is-aside? (make-tag-predicate 'aside 'sidebar)) (is-aside? '(q "I am not mad, Sir Topas. I say to you this house is dark.")) -(is-aside? '(aside "How smart a lash that speech doth give my Conscience?"))] +(is-aside? '(aside "How smart a lash that speech doth give my Conscience?")) +(is-aside? '(sidebar "Many copies that we use today are conflated texts."))] @defproc[(first-words [txprs (listof txexpr?)] [n exact-nonnegative-integer?]) string?] Given a list of tagged X-expressions, returns a string containing the first @racket[_n] words found in the string elements of @racket[_txprs], or all of the words if there are less than @racket[_n] Index: dust.rkt ================================================================== --- dust.rkt +++ dust.rkt @@ -136,12 +136,12 @@ (cond [(pair? result) (cadr result)] [else missing])) ;; Returns a function will test if a txexpr's tag matches the given symbol. -(define (make-tag-predicate tagsym) - (lambda (tx) (and (txexpr? tx) (equal? tagsym (get-tag tx))))) +(define (make-tag-predicate . tagsyms) + (lambda (tx) (if (and (txexpr? tx) (member (get-tag tx) tagsyms)) #t #f))) (define (tx-strs xpr) (cond [(txexpr? xpr) (apply string-append (map tx-strs (get-elements xpr)))] [(string? xpr) xpr]