diff options
Diffstat (limited to '')
-rwxr-xr-x | script.scm | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -51,6 +51,11 @@ ("DH" bold) (_ identity))) +(define (push item stack) (cons item stack)) +(define (pop stack) (unless (null? stack) + (car+cdr stack))) +(define (peek stack) (if (null? stack) '() (car stack))) + (define (class-handlers class-str) (fold compose identity (map classmap (string-split class-str #\space)))) @@ -76,6 +81,28 @@ [,default (format #f "[|~a|]" default)] )) +;;; +;;; +;;; + +(define (fmt-tag tag) + (sxml-match tag + [(a #; (@ (class ,class)) ,text) + (underline text)] + + [(h1 (@ (class ,class)) ,nodes ...) + ((class-handlers class) + (bold (fmt-sub nodes)))] + + [(span (@ (class ,class)) ,nodes ...) + ((class-handlers class) + (fmt-sub nodes))] + + [,str (guard (string? str)) str] + + [,default (format #f "[|~a|]" default)] + )) + (define (parse-doc sxml) (sxml-match sxml [(*TOP* (div #; (span (@ (class "toprow")) ,top-row ...) @@ -83,6 +110,26 @@ spans ])) +'(span (@ (class "B")) + "A" + (span (@ (class "G")) + "B") + "C") + +;; => (blue A (green B) C) +;; => set-blue A set-green B unset-green/set-blue C unset-blue + +;; push blue : print-esc +;; print A +;; push green : print-esc +;; print B +;; pop : print-esc +;; print C +;; pop : print-esc + + + + (define (main args) (define d (call-with-input-file "100-2.html" xml->sxml)) (display (string-concatenate (map fmt-tag (parse-doc d)))) |