(defun mikkelsen-to-html (name)
(let (
(lines nil)
)
(with-open-file (instream name)
(loop
(if (peek-char nil instream)
(setf lines (append lines (list (read-line instream))))
(return))))
(with-open-file (outstream (concatenate 'string name ".html")
:direction :output)
(main-html-file outstream name lines))
(with-open-file (outstream (concatenate 'string name "_syntax.html")
:direction :output)
(syntax-html-file outstream name (extract-syntax lines)))
(with-open-file (outstream (concatenate 'string name "_description.html")
:direction :output)
(description-html-file outstream name (extract-description lines)))
(with-open-file (outstream (concatenate 'string name "_examples.html")
:direction :output)
(examples-html-file outstream name (extract-examples lines)))
(with-open-file (outstream (concatenate 'string name "_comments.html")
:direction :output)
(comments-html-file outstream name (extract-comments lines)))
))
(defun main-html-file (outstream name lines)
(format outstream "~%")
(format outstream "
~%")
(format outstream "~a~%" name)
(format outstream
"~%")
(format outstream "~%")
(format outstream "~%")
(format outstream "~a~%" name)
(format outstream "~%
~%~%")
(format outstream "
~%")
(format outstream "type: ~a~%"
(from-string-list "type: " lines))
(format outstream "location: ~a~%"
(from-string-list "location: " lines))
(format outstream "source file: ~a~%"
(from-string-list "source file: " lines))
(format outstream "Common LISP Compatible: ~a~%"
(from-string-list "Common LISP Compatible: " lines))
(format outstream "supported on: ~a~%"
(from-string-list "supported on: " lines))
(format outstream "~%~%
~%
~%")
(format outstream "~%")
(format outstream "- SYNTAX~%"
(concatenate 'string name "_syntax.html"))
(format outstream "
- DESCRIPTION~%"
(concatenate 'string name "_description.html"))
(format outstream "
- EXAMPLES~%"
(concatenate 'string name "_examples.html"))
(format outstream "
- Comments~%"
(concatenate 'string name "_comments.html"))
(format outstream "
~%")
(format outstream "~%
~%
~%")
(format outstream "Jan de Leeuw
~%UCLA Statistics Program
~%deleeuw@stat.ucla.edu~%~%")
(format outstream "~%")
(format outstream "~%")
)
(defun syntax-html-file (outstream name lines)
(format outstream "~%")
(format outstream "~%")
(format outstream "~a_syntax~%" name)
(format outstream "~%")
(format outstream "~%")
(format outstream "~%")
(format outstream "~a SYNTAX~%" name)
(format outstream "~%
~%~%
~%")
(dotimes (i (length lines))
(format outstream "~a~%" (elt lines i)))
(format outstream "
~%~%
~%
~%")
(format outstream "Jan de Leeuw
~%UCLA Statistics Program
~%deleeuw@stat.ucla.edu~%~%")
(format outstream "~%")
(format outstream "~%")
)
(defun description-html-file (outstream name lines)
(format outstream "~%")
(format outstream "~%")
(format outstream "~a_description~%" name)
(format outstream "~%")
(format outstream "~%")
(format outstream "~%")
(format outstream "~a DESCRIPTION~%" name)
(format outstream "~%
~%~%
~%")
(dotimes (i (length lines))
(format outstream "~a~%" (elt lines i)))
(format outstream "
~%~%
~%
~%")
(format outstream "Jan de Leeuw
~%UCLA Statistics Program
~%deleeuw@stat.ucla.edu~%~%")
(format outstream "~%")
(format outstream "~%")
)
(defun examples-html-file (outstream name lines)
(format outstream "~%")
(format outstream "~%")
(format outstream "~a_examples~%" name)
(format outstream "~%")
(format outstream "~%")
(format outstream "~%")
(format outstream "~a EXAMPLES~%" name)
(format outstream "~%
~%~%
~%")
(dotimes (i (length lines))
(format outstream "~a~%" (elt lines i)))
(format outstream "
~%~%
~%
~%")
(format outstream "Jan de Leeuw
~%UCLA Statistics Program
~%deleeuw@stat.ucla.edu~%~%")
(format outstream "~%")
(format outstream "~%")
)
(defun comments-html-file (outstream name lines)
(format outstream "~%")
(format outstream "~%")
(format outstream "~a_comments~%" name)
(format outstream "~%")
(format outstream "~%")
(format outstream "~%")
(format outstream "~a Comments~%" name)
(format outstream "~%
~%~%
~%")
(dotimes (i (length lines))
(format outstream "~a~%" (elt lines i)))
(format outstream "
~%~%
~%
~%")
(format outstream "Jan de Leeuw
~%UCLA Statistics Program
~%deleeuw@stat.ucla.edu~%~%")
(format outstream "~%")
(format outstream "~%")
)
(defun extract-syntax (lines)
(let* (
(l1 (first (which (mapcar
#'(lambda (x) (string-equal "SYNTAX" x)) lines))))
(l2 (first (which (mapcar
#'(lambda (x) (string-equal "DESCRIPTION" x)) lines))))
(mm (select lines (rest (+ l1 (iseq (- l2 l1))))))
)
(select mm (which (mapcar #'(lambda (x) (string-not-equal "" x)) mm)))
))
(defun extract-description (lines)
(let* (
(l1 (first (which (mapcar
#'(lambda (x) (string-equal "DESCRIPTION" x)) lines))))
(l2 (first (which (mapcar
#'(lambda (x) (string-equal "EXAMPLES" x)) lines))))
(mm (select lines (rest (+ l1 (iseq (- l2 l1))))))
)
(select mm (which (mapcar #'(lambda (x) (string-not-equal "" x)) mm)))
))
(defun extract-examples (lines)
(let* (
(l1 (first (which (mapcar
#'(lambda (x) (string-equal "EXAMPLES" x)) lines))))
(l2 (first (which (mapcar
#'(lambda (x) (string-equal "Comments" x)) lines))))
(mm (select lines (rest (+ l1 (iseq (- l2 l1))))))
)
(select mm (which (mapcar #'(lambda (x) (string-not-equal "" x)) mm)))
))
(defun extract-comments (lines)
(let* (
(ll (first (which (mapcar
#'(lambda (x) (string-equal "Comments" x)) lines))))
(mm (select lines (rest (+ ll (iseq (- (length lines) ll))))))
)
(select mm (which (mapcar #'(lambda (x) (string-not-equal "" x)) mm)))
))