;;; A collection of utilities that simply the creation of HTML. ;;; ;;; Author: Samuel A. Rebelsky ;;; Version: 1.0 of October 2000 ;;; ;;; Contents: ;;; (html-bold string) ;; Convert a string to "bold" ;;; (html-paragraph string) ;;; Put a string in a paragraph ;;; (html-document title body) ;;; Build an HTML document. ;;; (list->html lst) ;;; Convert a list of strings to an equivalent HTML list. ;;; return ;;; Generate a carriage return. ;;; MANY OTHERS NOT YET DOCUMENTED ;;; return ;;; Clearer shorthand for a carriage return. (define return (string #\newline)) ;;; (html-block string) ;;; Build a block quote from a string. ;;; Pre: The argument is a string. ;;; Post: Returns a string that corresponds to the HTML for ;;; a block quote that contains the original string. (define html-block (lambda (str) (string-append "
" return str return "
"))) ;;; (html-bold string) ;;; Convert a string to bold. ;;; Pre: The argument is a string. ;;; Post: Returns a string that corresponds to the HTML for ;;; emboldening the original string. (define html-bold (lambda (str) (string-append "" str ""))) ;;; (html-italic string) ;;; Convert a string to italic. ;;; Pre: The argument is a string. ;;; Post: Returns a string that corresponds to the HTML for ;;; italicizing the original string. (define html-italic (lambda (str) (string-append "" str ""))) ;;; (html-document title body) ;;; Build an HTML document. ;;; Pre: The title is a plain-text string. The body contains valid HTML. ;;; Post: Returns valid HTML for a complete document. (define html-document (lambda (title body) (string-append "" return "" title "" return "" return body return "" return "" return))) ;;; (html-head string level) ;;; Create the appropriate level heading. ;;; Pre: The first argument is a string; the second is a ;; number between 1 and 6. ;;; Post: Returns HTML for the appropriate level heading. (define html-head (lambda (str level) (let ((tagtext (string-append "h" (number->string level)))) (string-append "<" tagtext ">" str "")))) ;;; (html-paragraph string) ;;; Put a string in a paragraph. ;;; Pre: The argument is a string. ;;; Post: Returns a string that corresponds to the HTML for ;;; a paragraph that contains the original string. (define html-paragraph (lambda (str) (string-append "

" str "

"))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Sample values (define test1 (html-document "Test" (html-paragraph "Test")))