diff --git a/main.scm b/main.scm index d831c92..70961e0 100755 --- a/main.scm +++ b/main.scm @@ -105,18 +105,21 @@ (h5 . ,enumerate-tag) ;; if adjust-relative is true, all relative links should get prefixed with ;; the relative-root. - ,(if adjust-relative - `(a . - ,(lambda (t i) - `(,t . - ,(alist-update - '@ - (alist-update - 'href - `(,adjust-relative ,(alist-ref 'href (alist-ref '@ i))) - (alist-ref '@ i)) - i)))) - `(a . ,(lambda (t i) `(,t . ,i)))) + `(a . + ,(lambda (t i) + (let ((linkurl (alist-ref 'href (alist-ref '@ i)))) + `(,t . + ,(if (and adjust-relative + (not (string-prefix? "/" linkurl)) + (not (string-prefix? "https://" linkurl)) + (not (string-prefix? "http://" linkurl)) + (not (string-prefix? "mailto:" linkurl)) + (not (string-prefix? "https://" linkurl))) + + (alist-update '@ + (alist-update 'href `(,adjust-relative ,linkurl) (alist-ref '@ i)) + i) + i))))) ;; this copied from lowdown html-serialization-rules* because it ;; is for some reason not exported?? (*COMMENT* . ,(lambda (_ str) (list #\< "!--" str "--" #\>)))