Fixing plain text HTML output.

master
Thomas Hintz 9 years ago
parent c65df73681
commit bda58b585e

@ -1,4 +1,4 @@
(import chicken scheme) (import chicken scheme data-structures)
(use colorize irregex srfi-13 files) (use colorize irregex srfi-13 files)
(define *file* (cadr (argv))) (define *file* (cadr (argv)))
@ -65,10 +65,17 @@
((html) 'html) ((html) 'html)
(else #f))) (else #f)))
;; based on string-translate* example from CHICKEN Scheme docs
(define (text->html text)
(string-translate*
text
'(("<" . "&lt;") (">" . "&gt;") ("\"" . "&quot;")
(" " . "&nbsp;") ("'" . "&#x27;")) ))
(let ((type (or (guess-type-by-emacs-major-mode-variable *file-contents*) (let ((type (or (guess-type-by-emacs-major-mode-variable *file-contents*)
(guess-type-by-file-extension *file*)))) (guess-type-by-file-extension *file*))))
(if (not type) (if (not type)
(begin (display *file-contents*) (exit 0)) (begin (display (text->html *file-contents*)) (exit 0))
(begin (begin
(display (display
"<style> "<style>

Loading…
Cancel
Save