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)