add a rule to handle #<unspecified> in sxml trees

this lets us use ,(when ...) when constructing sxml for
optionally-present elements.
This commit is contained in:
pho4cexa 2022-12-12 09:29:06 -08:00 committed by m455
parent c0fcd0bebc
commit 37ef2922e8

View file

@ -15,6 +15,7 @@
srfi-1 ;; list utils srfi-1 ;; list utils
srfi-13 ;; string utils srfi-13 ;; string utils
srfi-14 ;; charsets srfi-14 ;; charsets
symbol-utils ;; (unspecified-value)
) )
(define CLONE-URL (or (get-environment-variable "REPO2HTML_CLONE_URL") "git://git.example.com")) (define CLONE-URL (or (get-environment-variable "REPO2HTML_CLONE_URL") "git://git.example.com"))
@ -124,13 +125,13 @@
(h2 ,repository-name) (h2 ,repository-name)
(p "clone url:" ,CLONE-URL "/" ,repository-name) (p "clone url:" ,CLONE-URL "/" ,repository-name)
(nav (nav
,(if readme-file ,(when readme-file
`(a (@ href ,relative-root "index.html") "about") "") `(a (@ href ,relative-root "index.html") "about"))
(a (@ href ,relative-root "files.html") "files") (a (@ href ,relative-root "files.html") "files")
,(if license-file ,(when license-file
`(a (@ href ,relative-root ,license-file ".html") "license") "") `(a (@ href ,relative-root ,license-file ".html") "license"))
,(if issues-present? ,(when issues-present?
`(a (@ href ,relative-root "ISSUES.html") "issues") "") `(a (@ href ,relative-root "ISSUES.html") "issues"))
(a (@ href ,relative-root "commits.html") "commits") (a (@ href ,relative-root "commits.html") "commits")
(a (@ href ,relative-root "contributors.html") "contributors"))) (a (@ href ,relative-root "contributors.html") "contributors")))
(hr) (hr)
@ -241,7 +242,14 @@
(with-output-to-file (make-pathname html-repo-path filename) (with-output-to-file (make-pathname html-repo-path filename)
(lambda () (lambda ()
(display "<!DOCTYPE html>\n") (display "<!DOCTYPE html>\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) (create-directory html-repo-path #t)
;; special files ;; special files