netzstaub

beatz & funkz

Wednesday, March 9, 2005

ecto

Ecto somehow managed to fuck up all the fixed-width text used for program code in the LISP entries. This will get fixed ASAP, sorry.

Update: it should be better now :). Here is the LISP sourcecode I used to cleanup the entries. I replace P entries with monospace font with PRE entries. This sourcecode uses the HTML pattern matcher which can be found at svn://bknr.net/trunk/bknr/src/html-match . It is a real memory abuser, and quite slow too, but it works :)

(defun load-file (file)
  (with-open-file (s file :direction :input)
    (let ((lines (loop for line = (read-line s nil 'eof)
                    until (eql line 'eof)
                    collect line)))
      (reduce #'(lambda (s1 s2) (concatenate 'string s1 s2)) lines :initial-value ""))))

(defun cleanup-ecto (file output-file)
  (let* ((body (cons :html
                    (net.html.parser:parse-html (load-file file))))
         (res (html-replace body
               (html-pattern ((:p :style "font-family:monospace;font-size:13pt;") ?body)
                             (cons :pre
                                   (html-replace ?body
                                                 (html-pattern :br (string #\Newline))))))))
    (with-open-file (s output-file :direction :output :if-exists :supersede)
      (net.html.generator:html-stream s
          (mapcar #'(lambda (x) (net.html.generator:html-print x s))
                  (cdr res))))))
posted by manuel at 3:44 pm  

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Powered by WordPress