Added configuration for diff2html

This commit is contained in:
2026-08-13 12:43:44 +02:00
parent d1fe41b5cc
commit 302dc06e89
3 changed files with 68 additions and 5 deletions
+37 -1
View File
@@ -6,10 +6,13 @@
xml
racket/string
"config.rkt"
"utils.rkt"
)
(provide diff->html
show->html)
show->html
config-diff2html
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helper functions
@@ -57,6 +60,39 @@
;; Exported functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (config-diff2html)
(define (checker f)
(λ (inp)
(let ((url (string-trim inp)))
(if (string=? url "")
(f)
(if (valid-http-or-file-url? url)
url
(begin
(displayln "! Not a valid url, please input a valid url")
#f)))))
)
(define (inp name f)
(input-prompt (string-join
(list
(format "Give the url for the ~a" name)
"Enter keeps the current value:"
(string-append " - " (f))
">")
"\n")
#:loop-until (checker f)))
(let ((h-css (inp "Highlighting CSS" highlight-css))
(d-css (inp "Diff2Html CSS" diff2html-min-css))
(d-js (inp "Diff2Html UI Javascript" diff2html-ui-min-js))
)
(cfg-set! 'diff 'highlight-css h-css)
(cfg-set! 'diff 'diff2html-min-css d-css)
(cfg-set! 'diff 'diff2html-ui-min-js d-js))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; goal : Render a Git diff in a temporary HTML file.
; pre : diff is a unified Git diff string.