Expose deleted-signal with docs correction

The docs say that `(λ (x) null)` is the default `replace-proc` for `splitf-txexpr`.
This disagrees with the code, which uses `deleted-signal`. Since there
is a use case for conditionally removing elements, `(provide
deleted-signal)` and correct the docs.
pull/13/head
Sage Gerard 5 years ago
parent d3f16ceebe
commit 6226db2ceb

@ -6,6 +6,7 @@
(for-syntax racket/base syntax/parse)) (for-syntax racket/base syntax/parse))
(provide cdata? cdata valid-char? xexpr->string xexpr?) ; from xml (provide cdata? cdata valid-char? xexpr->string xexpr?) ; from xml
(provide empty) ; from racket/list (provide empty) ; from racket/list
(provide deleted-signal)
;; Section 2.2 of XML 1.1 ;; Section 2.2 of XML 1.1
;; (XML 1.0 is slightly different and more restrictive) ;; (XML 1.0 is slightly different and more restrictive)

@ -469,12 +469,18 @@ In practice, most @racket[_txexpr-element]s are strings. But it's unwise to pass
] ]
@deftogether[(
@defthing[deleted-signal symbol?]
@defproc[ @defproc[
(splitf-txexpr (splitf-txexpr
[tx txexpr?] [tx txexpr?]
[pred procedure?] [pred procedure?]
[replace-proc procedure? (λ (x) null)]) [replace-proc procedure? (λ (x) deleted-signal)])
(values txexpr? (listof txexpr-element?))] (values txexpr? (listof txexpr-element?))]
)]
Recursively descend through @racket[_txexpr] and extract all elements that match @racket[_pred]. Returns two values: a @racket[_txexpr] with the matching elements removed, and the list of matching elements. Sort of esoteric, but I've needed it more than once, so here it is. Recursively descend through @racket[_txexpr] and extract all elements that match @racket[_pred]. Returns two values: a @racket[_txexpr] with the matching elements removed, and the list of matching elements. Sort of esoteric, but I've needed it more than once, so here it is.
@examples[#:eval my-eval @examples[#:eval my-eval
@ -483,7 +489,7 @@ Recursively descend through @racket[_txexpr] and extract all elements that match
(splitf-txexpr tx is-meta?) (splitf-txexpr tx is-meta?)
] ]
Ordinarily, the result of the split operation is to remove the elements that match @racket[_pred]. But you can change this behavior with the optional @racket[_replace-proc] argument. Ordinarily, the result of the split operation is to remove the elements that match @racket[_pred]. This happens only when returning @racket[_deleted-signal]. You can change this behavior with the optional @racket[_replace-proc] argument.
@examples[#:eval my-eval @examples[#:eval my-eval
(define tx '(div "Wonderful day" (meta "weather" "good") "for a walk")) (define tx '(div "Wonderful day" (meta "weather" "good") "for a walk"))

Loading…
Cancel
Save