|
|
@ -1,5 +1,5 @@
|
|
|
|
#lang racket/base
|
|
|
|
#lang racket/base
|
|
|
|
(require sugar txexpr racket/list racket/string pollen/world xml html racket/file racket/match pollen/html)
|
|
|
|
(require sugar txexpr racket/list racket/string pollen/world xml html racket/file racket/match pollen/html net/url racket/port)
|
|
|
|
|
|
|
|
|
|
|
|
(define (attrs->pollen attrs)
|
|
|
|
(define (attrs->pollen attrs)
|
|
|
|
(string-join (flatten (map (λ(pair) (list (format "'~a:" (car pair)) (format "\"~a\"" (cadr pair)))) attrs)) " "))
|
|
|
|
(string-join (flatten (map (λ(pair) (list (format "'~a:" (car pair)) (format "\"~a\"" (cadr pair)))) attrs)) " "))
|
|
|
@ -37,10 +37,17 @@
|
|
|
|
; xexpr-results will be a list with whitespace elements, so strip those out
|
|
|
|
; xexpr-results will be a list with whitespace elements, so strip those out
|
|
|
|
(xexpr->pollen #:p-breaks p-breaks (car (filter-not (λ(x) (and (string? x) (regexp-match #px"\\s+" x))) xexpr-results))))
|
|
|
|
(xexpr->pollen #:p-breaks p-breaks (car (filter-not (λ(x) (and (string? x) (regexp-match #px"\\s+" x))) xexpr-results))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract+provide (url->pollen url-or-string #:p-breaks [p-breaks #f])
|
|
|
|
|
|
|
|
(((or/c string? url?)) (#:p-breaks boolean?) . ->* . string?)
|
|
|
|
|
|
|
|
(define url (if (string? url-or-string) (string->url url-or-string) url-or-string))
|
|
|
|
|
|
|
|
(define url-result (port->string (get-pure-port url)))
|
|
|
|
|
|
|
|
(html->pollen url-result #:p-breaks p-breaks))
|
|
|
|
|
|
|
|
|
|
|
|
(module+ main
|
|
|
|
(module+ main
|
|
|
|
; (xexpr->pollen '(p "You are puppy"))
|
|
|
|
; (xexpr->pollen '(p "You are puppy"))
|
|
|
|
; (xexpr->pollen '(p ((class "foo")) "You are puppy"))
|
|
|
|
; (xexpr->pollen '(p ((class "foo")) "You are puppy"))
|
|
|
|
; (xexpr->pollen '(p ((class "foo")) "You are" "\n\n" "puppy"))
|
|
|
|
; (xexpr->pollen '(p ((class "foo")) "You are" "\n\n" "puppy"))
|
|
|
|
; (xexpr->pollen '(p ((class "foo")) "You are " (em "so") " puppy"))
|
|
|
|
; (xexpr->pollen '(p ((class "foo")) "You are " (em "so") " puppy"))
|
|
|
|
; (display (html->pollen #:p-breaks #t (file->string "index.html"))))
|
|
|
|
; (display (html->pollen #:p-breaks #t (file->string "index.html"))))
|
|
|
|
)
|
|
|
|
)
|