Changeset 15851 in project


Ignore:
Timestamp:
09/13/09 13:16:34 (10 years ago)
Author:
sjamaan
Message:

Add whitespace normalization to work around the weird draft syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/estraier-client/estraier-client.scm

    r15850 r15851  
    4848
    4949(import chicken scheme)
    50 (use data-structures extras ports srfi-1 srfi-13 http-client uri-common intarweb)
     50(use data-structures extras ports regex srfi-1 srfi-13
     51     http-client uri-common intarweb)
    5152
    5253;; Exhaust input port with web-server's output (yes, confusing) and return void
     
    154155               (read-lines in)))))
    155156
     157;; Flatten all whitespace types to one regular whitespace.  Draft syntax
     158;; assigns special meaning to tabs/newlines but has no way to escape that.
     159(define (kill-special-whitespace str)
     160  (string-substitute '(+ whitespace) " " str))
     161
    156162(define (write-attributes outport attributes)
    157163  (for-each (lambda (attrib)
    158               (fprintf outport "~A=~A\r\n" (car attrib) (cdr attrib)))
     164              (fprintf outport "~A=~A\r\n"
     165                       (kill-special-whitespace (->string (car attrib)))
     166                       (kill-special-whitespace (->string (cdr attrib)))))
    159167            attributes))
    160168
     
    163171  (write-attributes outport attributes)
    164172  (fprintf outport "\r\n")
    165   ;; What if there's a newline in the text?
    166   (for-each (lambda (line) (fprintf outport "~A\r\n" line)) contents))
     173  (for-each (lambda (line)
     174              (fprintf outport "~A\r\n" (kill-special-whitespace line)))
     175            contents))
    167176
    168177(define (read-attributes inport)
Note: See TracChangeset for help on using the changeset viewer.