From 12790c87e4b57355f106e3700560959f374e9a85 Mon Sep 17 00:00:00 2001 From: pho4cexa Date: Mon, 16 Jan 2023 15:17:58 -0800 Subject: [PATCH] ah finally fixed the image prefix for index.html thing --- main.scm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main.scm b/main.scm index b945697..ca48df1 100755 --- a/main.scm +++ b/main.scm @@ -146,13 +146,19 @@ inner (alist-update-in '(@ href) (cons adjust-relative (append linkurl '(".html"))) inner equal?)))) +;; TODO FIXME for some reason, lowdown renders links differently than images: +;; (markdown->sxml "[x](x)") => ((p (a (@ (href "x")) "x"))) +;; (markdown->sxml "![x](x)") => ((p (img (@ (src ("x")) (alt "x"))))) + (define (adjust-relative-src adjust-relative inner) - (let* ((srcurl (alist-ref-in '(@ src) inner equal?)) - (srcurl-startswith (cute string-prefix? <> (car srcurl)))) + (let* ((srcurl (caar (alist-ref-in '(@ src) inner equal?))) + (srcurl-startswith (cute string-prefix? <> srcurl))) (if - (any srcurl-startswith '("/" "http://" "https://")) + (or (not adjust-relative) + (not srcurl) + (any srcurl-startswith '("/" "http://" "https://"))) inner - (alist-update-in '(@ src) (list adjust-relative srcurl) inner equal?)))) + (alist-update-in '(@ src) `((,(string-append adjust-relative srcurl))) inner equal?)))) (define (sxml-html-rules adjust-relative) `(;; assign all headings an id so you can link to them @@ -213,7 +219,7 @@ (define-values (_ _ basename extension _) (pathparts source-file)) (define (image-link) - `(p (img (@ src ,basename ,extension)))) + `(p (img (@ (src (,(string-append basename extension))))))) (define (plaintext) `(pre ,(git-file->string source-file))) (define (binary)