summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/html.scm16
-rw-r--r--tests/html.scm11
2 files changed, 14 insertions, 13 deletions
diff --git a/src/html.scm b/src/html.scm
index 107b78c..7c0485f 100644
--- a/src/html.scm
+++ b/src/html.scm
@@ -109,9 +109,6 @@
uri
path))
-(define css media)
-(define js media)
-
(define* (person name #:key (email "")
(uri "")
#:allow-other-keys)
@@ -136,12 +133,15 @@
,(post-content-html post))))
(define (render-style style)
- ;; TODO it escapes the contents!! if added inline :(
- `(link (@(rel stylesheet)
- (href ,(media-uri style)))))
+ (if (media? style)
+ `(link (@(rel stylesheet)
+ (href ,(media-uri style))))
+ `(style ,(lambda () (display style)))))
+
(define (render-script script)
- ;; TODO it escapes the contents!! if added inline :(
- `(script (@(src ,(media-uri script)))))
+ (if (media? script)
+ `(script (@(src ,(media-uri script))))
+ `(script ,(lambda () (display script)))))
(define (render-index index)
`(html
diff --git a/tests/html.scm b/tests/html.scm
index c5a5967..ca041f4 100644
--- a/tests/html.scm
+++ b/tests/html.scm
@@ -13,9 +13,11 @@
#:description "Este es mi feed"
#:uri "https://feed.elenq.tech/index.html"
#:styles (list
- (html:css "this.css" #:uri "/this.css")
- (html:css "that.css" #:uri "/that.css"))
- #:scripts (list (html:js "script.js" #:uri "/script.js"))
+ "body {color: grey}"
+ (html:media "that.css" #:uri "/that.css"))
+ #:scripts (list
+ "console.log(\"HOLA\")"
+ (html:media "script.js" #:uri "/script.js"))
#:author me
#:posts (list
(html:post #:title "first entry"
@@ -29,7 +31,6 @@
(let ((html-index (with-output-to-string (lambda () (html:render index)))))
(test-assert (string=? html-index
- "<!DOCTYPE html><html><head><meta author=\"Ekaitz\" /><meta charset=\"utf-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /><meta name=\"description\" content=\"Este es mi feed\" /><link rel=\"stylesheet\" href=\"/this.css\" /><link rel=\"stylesheet\" href=\"/that.css\" /></head><body><article class=\"post\" id=\"first-entry\"><h2>first entry</h2><time datetime=\"2023-03-01T00:00:00+0100\" pubdate=\"#t\">2023-03-01T00:00:00+0100</time><address class=\"author\"><a rel=\"author\">Ekaitz</a></address><section class=\"summary\"><p>Este es el resumen</p></section><section class=\"content\"><p>Este es el contenido</p></section></article><script src=\"/script.js\" /></body></html>")))
-
+ "<!DOCTYPE html><html><head><meta author=\"Ekaitz\" /><meta charset=\"utf-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /><meta name=\"description\" content=\"Este es mi feed\" /><style>body {color: grey}</style><link rel=\"stylesheet\" href=\"/that.css\" /></head><body><article class=\"post\" id=\"first-entry\"><h2>first entry</h2><time datetime=\"2023-03-01T00:00:00+0100\" pubdate=\"#t\">2023-03-01T00:00:00+0100</time><address class=\"author\"><a rel=\"author\">Ekaitz</a></address><section class=\"summary\"><p>Este es el resumen</p></section><section class=\"content\"><p>Este es el contenido</p></section></article><script>console.log(\"HOLA\")</script><script src=\"/script.js\" /></body></html>")))
(test-end "HTML index page")