Move xml->string to a more proper place

This commit is contained in:
Eli Barzilay 2010-06-16 02:52:42 -04:00
parent 8694d7b8ae
commit 5da56167a9
3 changed files with 12 additions and 13 deletions

View File

@ -2,7 +2,7 @@
;; XML-like objects and functions, with rendering ;; XML-like objects and functions, with rendering
(require scribble/text) (require scribble/text racket/port)
;; ---------------------------------------------------------------------------- ;; ----------------------------------------------------------------------------
;; Represent attribute names as `foo:' symbols. They are made self-quoting in ;; Represent attribute names as `foo:' symbols. They are made self-quoting in
@ -61,6 +61,10 @@
(define (output-xml content [p (current-output-port)]) (define (output-xml content [p (current-output-port)])
(output (disable-prefix (with-writer (xml-writer) content)) p)) (output (disable-prefix (with-writer (xml-writer) content)) p))
(provide xml->string)
(define (xml->string content)
(with-output-to-string (lambda () (output-xml content))))
;; ---------------------------------------------------------------------------- ;; ----------------------------------------------------------------------------
;; Structs for xml data: elements, literals, entities ;; Structs for xml data: elements, literals, entities

View File

@ -26,13 +26,14 @@
@navbar-style @navbar-style
}) })
(define (xml->string content) (define (get-resource-text . args)
(regexp-replace* #rx" " (let ([str (xml->string (apply www:the-resources args))])
(with-output-to-string (lambda () (output-xml content))) ;; due to some obscure xml issue the `nbsp' entity is not recognized
"\\ ")) ;; in blogger pages
(regexp-replace* #rx" " str "\\ ")))
(define (racket-navbar) (xml->string (www:the-resources 'navbar #f))) (define (racket-navbar) (get-resource-text 'navbar #f))
(define (racket-favicon) (xml->string (www:the-resources 'favicon-headers))) (define (racket-favicon) (get-resource-text 'favicon-headers))
(provide blog) (provide blog)
(define blog (define blog

View File

@ -6,12 +6,6 @@
(define-context "stubs/dirlist" #:resources dnld:the-resources) (define-context "stubs/dirlist" #:resources dnld:the-resources)
(require racket/port)
(define (xml->string content)
(regexp-replace* #rx" "
(with-output-to-string (lambda () (output-xml content)))
"\\ "))
(define header+footer (define header+footer
(delay (regexp-split #rx"{{{BODY}}}" (delay (regexp-split #rx"{{{BODY}}}"
(xml->string @page[#:id 'browse-downloads (xml->string @page[#:id 'browse-downloads