From 9fe05d3aeefedd0d96606f18ec1fa0415b500b32 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 10 Mar 2023 21:40:18 -0500 Subject: fix: links display correctly when text is after them --- main.scm | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'main.scm') diff --git a/main.scm b/main.scm index f6a049c..0027a30 100644 --- a/main.scm +++ b/main.scm @@ -183,8 +183,13 @@ (let ([r "(https://[^ ]*)"]) (if (irregex-search r content) (let* ([starts-with-link (= 0 (irregex-match-start-index (irregex-search r content)))] - [texts (map (cut list 'div '(@ [class "content-text"]) <>) (irregex-split r content))] - [links (map (lambda (x) `(a (@ [href ,x] [class "content-link"]) ,x)) (irregex-extract r content))]) + [texts (map (cut list 'span <>) (irregex-split r content))] + [links (map (lambda (x) + `(a (@ [href ,x] + [target "_blank"] + [rel "noreferrer"]) + ,x)) (irregex-extract r content))]) + (display `(,texts ,links)) (define (go xs ys take-y?) (cond [(and (not (null-list? ys)) take-y?) @@ -250,14 +255,17 @@ )) (define (page inner) - (with-output-to-string (lambda () - (sxml-display-as-html - `(html (head - (link (@ [rel "stylesheet"] [href "/style.css"])) - (meta (@ [name "viewport"] [content "width=device-width, initial-scale=1"]))) - (body - ,inner - )))))) + (string-append + "" + (with-output-to-string + (lambda () + (sxml-display-as-html + `(html (head + (link (@ [rel "stylesheet"] [href "/style.css"])) + (meta (@ [name "viewport"] [content "width=device-width, initial-scale=1"]))) + (body + ,inner + ))))))) (define login-form `(form (@ [class "login-form"] [action "/login"] [method "POST"]) -- cgit v1.2.3