diff --git a/txexpr/scribblings/txexpr.scrbl b/txexpr/scribblings/txexpr.scrbl index e1ae72a..17e0f74 100644 --- a/txexpr/scribblings/txexpr.scrbl +++ b/txexpr/scribblings/txexpr.scrbl @@ -7,7 +7,7 @@ (for-label racket txexpr txexpr/stx xml rackunit)) @(define my-eval (make-base-eval)) -@(my-eval `(require txexpr xml rackunit)) +@(my-eval `(require racket/match txexpr xml rackunit)) @title{txexpr: Tagged X-expressions} @@ -229,6 +229,23 @@ Assemble a @racket[_txexpr] from its parts. If you don't have attributes, but yo (get-attrs tx) (get-elements tx)) ] +The @racket[txexpr] form can also be used as a match pattern: + +@examples[#:eval my-eval +(match '(div) + [(txexpr tag attrs elems) + (values tag attrs elems)]) +(match '(div "Hello" (p "World")) + [(txexpr tag attrs elems) + (values tag attrs elems)]) +(match '(div "Hello" (p "World")) + [(txexpr 'div attrs1 (list elems1 ... (txexpr 'p attrs2 elems2))) + (values attrs1 elems1 attrs2 elems2)]) +(match '(div ((id "top")) "Hello" (p "World")) + [(txexpr 'div attrs1 (list elems1 ... (txexpr 'p attrs2 elems2))) + (values attrs1 elems1 attrs2 elems2)]) +] + @defproc[ (txexpr* [tag txexpr-tag?]