ah finally fixed the image prefix for index.html thing

This commit is contained in:
pho4cexa 2023-01-16 15:17:58 -08:00
parent e6d77be6a5
commit 12790c87e4

View file

@ -146,13 +146,19 @@
inner inner
(alist-update-in '(@ href) (cons adjust-relative (append linkurl '(".html"))) inner equal?)))) (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) (define (adjust-relative-src adjust-relative inner)
(let* ((srcurl (alist-ref-in '(@ src) inner equal?)) (let* ((srcurl (caar (alist-ref-in '(@ src) inner equal?)))
(srcurl-startswith (cute string-prefix? <> (car srcurl)))) (srcurl-startswith (cute string-prefix? <> srcurl)))
(if (if
(any srcurl-startswith '("/" "http://" "https://")) (or (not adjust-relative)
(not srcurl)
(any srcurl-startswith '("/" "http://" "https://")))
inner 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) (define (sxml-html-rules adjust-relative)
`(;; assign all headings an id so you can link to them `(;; assign all headings an id so you can link to them
@ -213,7 +219,7 @@
(define-values (_ _ basename extension _) (define-values (_ _ basename extension _)
(pathparts source-file)) (pathparts source-file))
(define (image-link) (define (image-link)
`(p (img (@ src ,basename ,extension)))) `(p (img (@ (src (,(string-append basename extension)))))))
(define (plaintext) (define (plaintext)
`(pre ,(git-file->string source-file))) `(pre ,(git-file->string source-file)))
(define (binary) (define (binary)