From 37ef2922e8ae6af89b1ee6568edde3dd6e95c67b Mon Sep 17 00:00:00 2001 From: pho4cexa Date: Mon, 12 Dec 2022 09:29:06 -0800 Subject: [PATCH] add a rule to handle # in sxml trees this lets us use ,(when ...) when constructing sxml for optionally-present elements. --- main.scm | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/main.scm b/main.scm index f1d2161..29543f7 100755 --- a/main.scm +++ b/main.scm @@ -15,6 +15,7 @@ srfi-1 ;; list utils srfi-13 ;; string utils srfi-14 ;; charsets + symbol-utils ;; (unspecified-value) ) (define CLONE-URL (or (get-environment-variable "REPO2HTML_CLONE_URL") "git://git.example.com")) @@ -124,13 +125,13 @@ (h2 ,repository-name) (p "clone url:" ,CLONE-URL "/" ,repository-name) (nav - ,(if readme-file - `(a (@ href ,relative-root "index.html") "about") "") + ,(when readme-file + `(a (@ href ,relative-root "index.html") "about")) (a (@ href ,relative-root "files.html") "files") - ,(if license-file - `(a (@ href ,relative-root ,license-file ".html") "license") "") - ,(if issues-present? - `(a (@ href ,relative-root "ISSUES.html") "issues") "") + ,(when license-file + `(a (@ href ,relative-root ,license-file ".html") "license")) + ,(when issues-present? + `(a (@ href ,relative-root "ISSUES.html") "issues")) (a (@ href ,relative-root "commits.html") "commits") (a (@ href ,relative-root "contributors.html") "contributors"))) (hr) @@ -241,7 +242,14 @@ (with-output-to-file (make-pathname html-repo-path filename) (lambda () (display "\n") - (SXML->HTML (template-wrap->sxml filename sxml))))) + (SXML->HTML + (pre-post-order* + (template-wrap->sxml filename sxml) + `((*text* . ,(lambda (trigger str) + (if (equal? str (unspecified-value)) + "" + ((alist-ref '*text* alist-conv-rules*) trigger str)))) + ,@alist-conv-rules*)))))) (create-directory html-repo-path #t) ;; special files