#!/usr/bin/newlisp (define (indent strarg pfxarg) (replace "([^\r\n]+)([\r\n]+)" strarg (string (or pfxarg " ") $1 $2) 4)) (define (put-br strarg) (replace "([^\r\n]+)([\r\n]+)" strarg (string $1 "
" $2 ) 4)) (define (html) (let ((params (args))) (string "\n" (apply 'string params) "\n"))) (define (link-rel strarg) (string {\n")) (define (para) (let ((p (args))) (string "\n

" (apply 'string p) "

\n"))) (define (hr) "\n
\n") (define (tag-wrap-1 s1) (expand (fn () (let ((p (args))) (string "<" s1 ">" (apply 'string p) "\n"))) 's1)) (define h1 (tag-wrap-1 "h1")) (define h2 (tag-wrap-1 "h2")) (define h3 (tag-wrap-1 "h3")) (define td (tag-wrap-1 "td")) (define li (tag-wrap-1 "li")) (define title (tag-wrap-1 "title")) (define (tag-wrap-2 s1) (expand (fn () (let ((p (args))) (string "<" s1 ">\n" (indent (apply 'string p)) "\n"))) 's1)) (define head (tag-wrap-2 "head")) (define body (tag-wrap-2 "body")) (define table (tag-wrap-2 "table")) (define tr (tag-wrap-2 "tr")) (define ul (tag-wrap-2 "ul")) (define blockq (tag-wrap-2 "blockquote")) (load (first (2 (main-args)))) (setq v "") (dolist (verse verses) (push (para {} (put-br (replace {-} (replace {[ \t]*--[ \t]*} (replace {[ \t]*_[ \t]*} verse { } 0) {} 0) {} 0)) {}) v -1)) (write-file (string hymntitle ".html") (html (head (title "MP3 and PDF download: " hymntitle ". Text by " poet " and music by " composer) (link-rel "/style.css")) (body (h1 hymntitle) (para {Download: PDF | MP3 | OGG | MIDI}) (table (tr (td "Composer:") (td composer)) (tr (td "Poet:") (td poet))) v (hr) (para {Copyright © 2008 Ted Walther <ted@beautifulhymns.org>}) (para {Permission to use, copy, modify, and distribute the work distributed on this webpage for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.}) (para {THE WORK IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS WORK INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS WORK.})))) (exit 0)