Default args to eliminate-whitespace

This commit is contained in:
Jay McCarthy 2010-06-21 12:43:53 -06:00
parent d6b20a51d2
commit 801419693a
3 changed files with 11 additions and 4 deletions

View File

@ -550,6 +550,12 @@ END
(test-suite
"eliminate-whitespace"
(test-equal? "Defaults"
(with-output-to-string
(lambda ()
(write-xml/content ((eliminate-whitespace) (read-xml/element (open-input-string "<html>\n<p>Hey</p></html>"))))))
"<html>\n<p>Hey</p></html>")
(test-eliminate-whitespace empty identity "<html>\n<p>Hey</p></html>" "<html>\n<p>Hey</p></html>")
(test-eliminate-whitespace/exn empty not "<html>\n<p>Hey</p></html>" "not allowed to contain text")
(test-eliminate-whitespace/exn empty truer "<html>\n<p>Hey</p></html>" "not allowed to contain text")

View File

@ -1,10 +1,11 @@
#lang racket
(require "structures.rkt")
(provide/contract
[eliminate-whitespace ((listof symbol?) (boolean? . -> . boolean?) . -> . (element? . -> . element?))])
[eliminate-whitespace (() ((listof symbol?) (boolean? . -> . boolean?)) . ->* . (element? . -> . element?))])
;; eliminate-whitespace : (listof Symbol) (Bool -> Bool) -> Element -> Element
(define (eliminate-whitespace special eliminate-special?)
(define (eliminate-whitespace [special empty]
[eliminate-special? (λ (x) x)])
(letrec ([blank-it
(lambda (el)
(let ([name (element-name el)]

View File

@ -269,8 +269,8 @@ Converts an @tech{X-expression} into a string containing XML.}
Converts XML represented with a string into an @tech{X-expression}.}
@defproc[((eliminate-whitespace [tags (listof symbol?)]
[choose (boolean? . -> . boolean?)])
@defproc[((eliminate-whitespace [tags (listof symbol?) empty]
[choose (boolean? . -> . boolean?) (λ (x) x)])
[elem element?])
element?]{