(define (re-sub re to string)
(regexp-substitute/global #f re string 'pre to 'post))
+(define (re-sub-alist string alist)
+ (re-sub (caar alist) (cdar alist)
+ (if (pair? (cdr alist))
+ (re-sub-alist string (cdr alist))
+ string)))
+
(define (open-tag tag attrs exceptions)
(define (candidate? x)
(not (memq (car x) exceptions)))
(symbol->string sym)
"=\""
-
(let ((s (call-with-output-string (lambda (port) (display val port)))))
- ;; ugh
- (re-sub
- "\"" """
- (re-sub
- "<" "<"
- (re-sub
- ">" ">"
- (re-sub
- "'" "'"
- (re-sub
- "&" "&" s))))))
-
+ (re-sub-alist s '(("\"" . """)
+ ("<" . "<")
+ (">" . ">")
+ ("'" . "'")
+ ("&" . "&"))))
+
"\""
)))