From bda58b585e797cbb21379c3425a9c5c47944b353 Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Wed, 20 Apr 2016 10:46:13 -0700 Subject: [PATCH] Fixing plain text HTML output. --- highlight.scm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/highlight.scm b/highlight.scm index 9961f60..d6155ce 100644 --- a/highlight.scm +++ b/highlight.scm @@ -1,4 +1,4 @@ -(import chicken scheme) +(import chicken scheme data-structures) (use colorize irregex srfi-13 files) (define *file* (cadr (argv))) @@ -65,10 +65,17 @@ ((html) 'html) (else #f))) +;; based on string-translate* example from CHICKEN Scheme docs +(define (text->html text) + (string-translate* + text + '(("<" . "<") (">" . ">") ("\"" . """) + (" " . " ") ("'" . "'")) )) + (let ((type (or (guess-type-by-emacs-major-mode-variable *file-contents*) (guess-type-by-file-extension *file*)))) (if (not type) - (begin (display *file-contents*) (exit 0)) + (begin (display (text->html *file-contents*)) (exit 0)) (begin (display "