/usr/bin/s9htmlify is in scheme9 2017.11.09-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #! /usr/bin/s9 -f
; htmlify -- convert plain text files to HTML
; by Nils M Holm, 2010
; Placed in the Public Domain
;
; Usage: htmlify -t [file ...]
(load-from-library "parse-optionsb.scm")
(define (emit-newlines n)
(if (not (zero? n))
(begin (newline)
(emit-newlines (- n 1)))))
(define (htmlify trim)
(let loop ((c (read-char))
(nnl 0)
(lead #t))
(if (eof-object? c)
(if trim
(newline)
(emit-newlines nnl))
(begin (if (char=? (integer->char 10) c)
(loop (read-char) (+ 1 nnl) lead)
(begin (if (or (not trim)
(not lead))
(emit-newlines nnl))
(cond ((char=? #\< c)
(display "<")
(loop (read-char) 0 #f))
((char=? #\> c)
(display ">")
(loop (read-char) 0 #f))
((char=? #\& c)
(display "&")
(loop (read-char) 0 #f))
(else
(write-char c)
(loop (read-char) 0 #f)))))))))
(define trim-lead (option #\t #f))
(define show-help (option #\h #f))
(define options `(,trim-lead
,show-help))
(define (usage)
(display "Usage: htmlify [-t] [file ...]")
(newline))
(let ((files (parse-options! (sys:command-line) options usage)))
(if (opt-val show-help)
(begin (display-usage
`(""
,usage
""
"Convert plain text files to HTML"
""
"-t trim leading and trailing blank lines"
""))
(sys:exit 0)))
(if (null? files)
(htmlify (opt-val trim-lead))
(for-each (lambda (file)
(with-input-from-file
file
(lambda ()
(htmlify (opt-val trim-lead)))))
files)))
|