Artifact 14891b2741f9417739f833ac5dffdf69af5b98a6:


0000: 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 32 30 30  ;; Copyright 200
0010: 37 2d 32 30 31 31 2c 20 4d 61 74 74 68 65 77 20  7-2011, Matthew 
0020: 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b 20  Welland..;; .;; 
0030: 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73   This program is
0040: 20 6d 61 64 65 20 61 76 61 69 6c 61 62 6c 65 20   made available 
0050: 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47 50  under the GNU GP
0060: 4c 20 76 65 72 73 69 6f 6e 20 32 2e 30 20 6f 72  L version 2.0 or
0070: 0a 3b 3b 20 20 67 72 65 61 74 65 72 2e 20 53 65  .;;  greater. Se
0080: 65 20 74 68 65 20 61 63 63 6f 6d 70 61 6e 79 69  e the accompanyi
0090: 6e 67 20 66 69 6c 65 20 43 4f 50 59 49 4e 47 20  ng file COPYING 
00a0: 66 6f 72 20 64 65 74 61 69 6c 73 2e 0a 3b 3b 20  for details..;; 
00b0: 0a 3b 3b 20 20 54 68 69 73 20 70 72 6f 67 72 61  .;;  This progra
00c0: 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65 64  m is distributed
00d0: 20 57 49 54 48 4f 55 54 20 41 4e 59 20 57 41 52   WITHOUT ANY WAR
00e0: 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 74 20 65  RANTY; without e
00f0: 76 65 6e 20 74 68 65 0a 3b 3b 20 20 69 6d 70 6c  ven the.;;  impl
0100: 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 20  ied warranty of 
0110: 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20  MERCHANTABILITY 
0120: 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 41  or FITNESS FOR A
0130: 20 50 41 52 54 49 43 55 4c 41 52 0a 3b 3b 20 20   PARTICULAR.;;  
0140: 50 55 52 50 4f 53 45 2e 0a 0a 28 64 65 63 6c 61  PURPOSE...(decla
0150: 72 65 20 28 75 6e 69 74 20 68 74 6d 6c 2d 66 69  re (unit html-fi
0160: 6c 74 65 72 29 29 0a 28 72 65 71 75 69 72 65 2d  lter)).(require-
0170: 65 78 74 65 6e 73 69 6f 6e 20 72 65 67 65 78 29  extension regex)
0180: 0a 0a 3b 3b 20 0a 28 64 65 66 69 6e 65 20 28 73  ..;; .(define (s
0190: 3a 73 70 6c 69 74 2d 73 74 72 69 6e 67 20 73 74  :split-string st
01a0: 72 6e 67 20 64 65 6c 69 6d 29 0a 20 20 28 69 66  rng delim).  (if
01b0: 20 28 65 71 3f 20 28 73 74 72 69 6e 67 2d 6c 65   (eq? (string-le
01c0: 6e 67 74 68 20 73 74 72 6e 67 29 20 30 29 20 28  ngth strng) 0) (
01d0: 6c 69 73 74 20 73 74 72 6e 67 29 0a 20 20 20 20  list strng).    
01e0: 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68 65    (let loop ((he
01f0: 61 64 20 28 6d 61 6b 65 2d 73 74 72 69 6e 67 20  ad (make-string 
0200: 31 20 28 63 61 72 20 28 73 74 72 69 6e 67 2d 3e  1 (car (string->
0210: 6c 69 73 74 20 73 74 72 6e 67 29 29 29 29 0a 09  list strng))))..
0220: 09 20 28 74 61 69 6c 20 28 63 64 72 20 28 73 74  . (tail (cdr (st
0230: 72 69 6e 67 2d 3e 6c 69 73 74 20 73 74 72 6e 67  ring->list strng
0240: 29 29 29 0a 09 09 20 28 64 65 73 74 20 27 28 29  )))... (dest '()
0250: 29 0a 09 09 20 28 74 65 6d 70 20 22 22 29 29 0a  )... (temp "")).
0260: 09 28 63 6f 6e 64 20 28 28 65 71 75 61 6c 3f 20  .(cond ((equal? 
0270: 68 65 61 64 20 64 65 6c 69 6d 29 0a 09 20 20 20  head delim)..   
0280: 20 20 20 20 28 73 65 74 21 20 64 65 73 74 20 28      (set! dest (
0290: 61 70 70 65 6e 64 20 64 65 73 74 20 28 6c 69 73  append dest (lis
02a0: 74 20 74 65 6d 70 29 29 29 0a 09 20 20 20 20 20  t temp)))..     
02b0: 20 20 28 73 65 74 21 20 74 65 6d 70 20 22 22 29    (set! temp "")
02c0: 29 0a 09 20 20 20 20 20 20 28 28 6e 75 6c 6c 3f  )..      ((null?
02d0: 20 68 65 61 64 29 20 0a 09 20 20 20 20 20 20 20   head) ..       
02e0: 28 73 65 74 21 20 64 65 73 74 20 28 61 70 70 65  (set! dest (appe
02f0: 6e 64 20 64 65 73 74 20 28 6c 69 73 74 20 74 65  nd dest (list te
0300: 6d 70 29 29 29 29 0a 09 20 20 20 20 20 20 28 65  mp))))..      (e
0310: 6c 73 65 20 28 73 65 74 21 20 74 65 6d 70 20 28  lse (set! temp (
0320: 73 74 72 69 6e 67 2d 61 70 70 65 6e 64 20 74 65  string-append te
0330: 6d 70 20 68 65 61 64 29 29 29 29 20 3b 3b 20 65  mp head)))) ;; e
0340: 6e 64 20 69 66 0a 09 28 63 6f 6e 64 20 28 28 6e  nd if..(cond ((n
0350: 75 6c 6c 3f 20 74 61 69 6c 29 0a 09 20 20 20 20  ull? tail)..    
0360: 20 20 20 28 73 65 74 21 20 64 65 73 74 20 28 61     (set! dest (a
0370: 70 70 65 6e 64 20 64 65 73 74 20 28 6c 69 73 74  ppend dest (list
0380: 20 74 65 6d 70 29 29 29 20 64 65 73 74 29 0a 09   temp))) dest)..
0390: 20 20 20 20 20 20 28 65 6c 73 65 20 28 6c 6f 6f        (else (loo
03a0: 70 20 28 6d 61 6b 65 2d 73 74 72 69 6e 67 20 31  p (make-string 1
03b0: 20 28 63 61 72 20 74 61 69 6c 29 29 20 28 63 64   (car tail)) (cd
03c0: 72 20 74 61 69 6c 29 20 64 65 73 74 20 74 65 6d  r tail) dest tem
03d0: 70 29 29 29 29 29 29 0a 0a 3b 3b 20 61 6c 6c 6f  p))))))..;; allo
03e0: 77 65 64 2d 74 61 67 73 20 69 73 20 61 20 6c 69  wed-tags is a li
03f0: 73 74 20 6f 66 20 74 61 67 73 20 61 73 20 73 79  st of tags as sy
0400: 6d 62 6f 6c 73 3a 0a 3b 3b 20 20 20 27 28 61 20  mbols:.;;   '(a 
0410: 62 20 63 65 6e 74 65 72 20 70 20 61 29 0a 3b 3b  b center p a).;;
0420: 20 70 61 72 73 69 6e 67 20 69 73 20 73 69 6d 70   parsing is simp
0430: 6c 69 73 74 69 63 20 61 6e 64 20 74 68 65 20 72  listic and the r
0440: 65 73 70 6f 6e 73 65 20 63 6f 6e 73 65 72 76 61  esponse conserva
0450: 74 69 76 65 0a 3b 3b 20 69 66 20 61 20 3c 20 69  tive.;; if a < i
0460: 73 20 66 6f 75 6e 64 20 77 69 74 68 6f 75 74 20  s found without 
0470: 74 68 65 20 74 61 67 20 61 6e 64 20 63 6c 6f 73  the tag and clos
0480: 69 6e 67 20 3e 20 74 68 65 6e 0a 3b 3b 20 74 68  ing > then.;; th
0490: 65 20 3c 20 6f 72 20 3e 20 69 73 20 72 65 70 6c  e < or > is repl
04a0: 61 63 65 64 20 77 69 74 68 20 26 6c 74 3b 20 6f  aced with &lt; o
04b0: 72 20 26 67 74 3b 20 77 69 74 68 6f 75 74 20 0a  r &gt; without .
04c0: 3b 3b 20 65 76 65 6e 20 74 72 79 69 6e 67 20 68  ;; even trying h
04d0: 61 72 64 20 74 6f 20 66 69 67 75 72 65 20 6f 75  ard to figure ou
04e0: 74 20 69 66 20 74 68 65 72 65 20 69 73 20 61 20  t if there is a 
04f0: 6c 65 67 69 74 20 74 61 67 20 0a 3b 3b 20 62 75  legit tag .;; bu
0500: 72 69 65 64 20 69 6e 20 74 68 65 20 74 65 78 74  ried in the text
0510: 20 73 6f 6d 65 77 68 65 72 65 2e 0a 3b 3b 20 61   somewhere..;; a
0520: 20 6c 69 73 74 20 6f 66 20 73 74 72 69 6e 67 73   list of strings
0530: 20 69 73 20 72 65 74 75 72 6e 65 64 2e 0a 3b 3b   is returned..;;
0540: 0a 3b 3b 20 4e 4f 54 45 53 0a 3b 3b 20 31 2e 20  .;; NOTES.;; 1. 
0550: 63 61 73 65 20 69 73 20 69 6d 70 6f 72 74 61 6e  case is importan
0560: 74 20 69 6e 20 74 68 65 20 61 6c 6c 6f 77 65 64  t in the allowed
0570: 2d 74 61 67 73 20 6c 69 73 74 21 0a 3b 3b 20 32  -tags list!.;; 2
0580: 2e 20 6f 6e 6c 79 20 22 73 6f 6c 69 64 22 20 74  . only "solid" t
0590: 61 67 73 20 61 72 65 20 73 75 70 70 6f 72 74 65  ags are supporte
05a0: 64 20 69 2e 65 2e 20 3c 61 20 68 72 65 66 3d 22  d i.e. <a href="
05b0: 66 6f 6f 22 3e 20 77 69 6c 6c 20 6e 6f 74 20 77  foo"> will not w
05c0: 6f 72 6b 3f 0a 3b 3b 0a 0a 3b 3b 20 28 73 3a 63  ork?.;;..;; (s:c
05d0: 67 69 2d 6f 75 74 20 28 65 76 61 6c 20 28 73 3a  gi-out (eval (s:
05e0: 6f 75 74 70 75 74 20 28 73 3a 68 74 6d 6c 2d 66  output (s:html-f
05f0: 69 6c 74 65 72 20 22 68 65 6c 6c 6f 3c 62 3e 67  ilter "hello<b>g
0600: 6f 6f 64 62 79 65 3c 2f 62 3e 3c 62 3e 20 65 68  oodbye</b><b> eh
0610: 22 20 27 28 61 20 62 20 69 29 29 29 29 0a 0a 3b  " '(a b i))))..;
0620: 3b 20 73 74 72 61 74 65 67 79 0a 3b 3b 20 31 2e  ; strategy.;; 1.
0630: 20 63 6f 6e 76 65 72 74 20 5c 6e 20 74 6f 20 3c   convert \n to <
0640: 6c 69 6e 65 66 65 65 64 3e 0a 3b 3b 20 32 2e 20  linefeed>.;; 2. 
0650: 53 70 6c 69 74 20 6f 6e 20 22 3c 22 0a 3b 3b 20  Split on "<".;; 
0660: 33 2e 20 53 70 6c 69 74 20 6f 6e 20 22 3e 22 0a  3. Split on ">".
0670: 3b 3b 20 34 2e 20 46 69 78 0a 28 64 65 66 69 6e  ;; 4. Fix.(defin
0680: 65 20 28 73 3a 68 74 6d 6c 2d 66 69 6c 74 65 72  e (s:html-filter
0690: 20 69 6e 70 75 74 2d 74 65 78 74 20 61 6c 6c 6f   input-text allo
06a0: 77 65 64 2d 74 61 67 73 29 0a 20 20 28 6c 65 74  wed-tags).  (let
06b0: 2a 20 28 28 74 6f 6b 73 20 20 20 28 73 3a 73 74  * ((toks   (s:st
06c0: 72 2d 3e 74 6f 6b 73 20 69 6e 70 75 74 2d 74 65  r->toks input-te
06d0: 78 74 29 29 0a 09 20 28 74 6d 70 20 20 20 20 28  xt)).. (tmp    (
06e0: 73 3a 74 6f 6b 73 2d 3e 73 74 6d 6c 20 27 28 73  s:toks->stml '(s
06f0: 3a 6e 75 6c 6c 29 20 23 66 20 74 6f 6b 73 20 61  :null) #f toks a
0700: 6c 6c 6f 77 65 64 2d 74 61 67 73 29 29 0a 09 20  llowed-tags)).. 
0710: 28 72 65 73 20 20 20 20 28 63 61 72 20 74 6d 70  (res    (car tmp
0720: 29 29 0a 09 20 28 6e 78 74 74 61 67 20 28 63 61  )).. (nxttag (ca
0730: 64 72 20 74 6d 70 29 29 0a 09 20 28 72 65 6d 20  dr tmp)).. (rem 
0740: 20 20 20 28 63 61 64 64 72 20 74 6d 70 29 29 29     (caddr tmp)))
0750: 0a 20 20 20 20 72 65 73 29 29 0a 0a 28 64 65 66  .    res))..(def
0760: 69 6e 65 20 28 73 3a 68 74 6d 6c 2d 66 69 6c 74  ine (s:html-filt
0770: 65 72 2d 3e 73 74 72 69 6e 67 20 69 6e 70 75 74  er->string input
0780: 2d 74 65 78 74 20 61 6c 6c 6f 77 65 64 2d 74 61  -text allowed-ta
0790: 67 73 29 0a 20 20 28 6c 65 74 20 28 28 6f 73 74  gs).  (let ((ost
07a0: 72 20 28 6f 70 65 6e 2d 6f 75 74 70 75 74 2d 73  r (open-output-s
07b0: 74 72 69 6e 67 29 29 29 0a 20 20 20 20 3b 3b 3b  tring))).    ;;;
07c0: 20 28 73 3a 6f 75 74 70 75 74 2d 6e 65 77 20 6f   (s:output-new o
07d0: 73 74 72 20 28 73 3a 68 74 6d 6c 2d 66 69 6c 74  str (s:html-filt
07e0: 65 72 20 69 6e 70 75 74 2d 74 65 78 74 20 61 6c  er input-text al
07f0: 6c 6f 77 65 64 2d 74 61 67 73 29 29 0a 20 20 20  lowed-tags)).   
0800: 20 28 73 3a 6f 75 74 70 75 74 2d 6e 65 77 20 6f   (s:output-new o
0810: 73 74 72 20 28 63 61 72 20 28 65 76 61 6c 20 28  str (car (eval (
0820: 73 3a 68 74 6d 6c 2d 66 69 6c 74 65 72 20 69 6e  s:html-filter in
0830: 70 75 74 2d 74 65 78 74 20 61 6c 6c 6f 77 65 64  put-text allowed
0840: 2d 74 61 67 73 29 29 29 29 0a 20 20 20 20 28 73  -tags)))).    (s
0850: 74 72 69 6e 67 2d 63 68 6f 6d 70 20 28 67 65 74  tring-chomp (get
0860: 2d 6f 75 74 70 75 74 2d 73 74 72 69 6e 67 20 6f  -output-string o
0870: 73 74 72 29 29 29 29 20 3b 3b 20 64 6f 6e 27 74  str)))) ;; don't
0880: 20 6e 65 65 64 20 74 68 65 20 6c 69 6e 65 66 65   need the linefe
0890: 65 64 2c 20 63 6f 75 6c 64 20 73 74 6f 70 20 61  ed, could stop a
08a0: 64 64 69 6e 67 20 69 74 20 2e 2e 2e 0a 09 0a 3b  dding it ......;
08b0: 3b 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f  ;     (if (null?
08c0: 20 72 65 6d 29 0a 3b 3b 20 09 72 65 73 20 27 28   rem).;; .res '(
08d0: 29 29 0a 3b 3b 20 09 28 73 3a 74 6f 6b 73 2d 3e  )).;; .(s:toks->
08e0: 73 74 6d 6c 20 28 69 66 20 28 6c 69 73 74 3f 20  stml (if (list? 
08f0: 72 65 73 29 20 72 65 73 20 27 28 29 29 20 23 66  res) res '()) #f
0900: 20 72 65 6d 20 61 6c 6c 6f 77 65 64 2d 74 61 67   rem allowed-tag
0910: 73 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28  s))))..(define (
0920: 73 3a 73 74 72 2d 3e 74 6f 6b 73 20 73 74 72 29  s:str->toks str)
0930: 0a 20 20 28 61 70 70 6c 79 20 61 70 70 65 6e 64  .  (apply append
0940: 20 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 74   (map (lambda (t
0950: 6f 6b 29 0a 09 09 20 20 20 20 20 20 20 28 69 6e  ok)...       (in
0960: 74 65 72 73 70 65 72 73 65 20 28 73 3a 73 70 6c  tersperse (s:spl
0970: 69 74 2d 73 74 72 69 6e 67 20 74 6f 6b 20 22 3e  it-string tok ">
0980: 22 29 20 22 3e 22 29 29 20 0a 09 09 20 20 20 20  ") ">")) ...    
0990: 20 28 69 6e 74 65 72 73 70 65 72 73 65 20 28 73   (intersperse (s
09a0: 3a 73 70 6c 69 74 2d 73 74 72 69 6e 67 20 73 74  :split-string st
09b0: 72 20 22 3c 22 29 20 22 3c 22 29 29 29 29 0a 0a  r "<") "<"))))..
09c0: 28 64 65 66 69 6e 65 20 28 73 3a 74 61 67 2d 3e  (define (s:tag->
09d0: 73 74 6d 6c 20 74 61 67 29 0a 20 20 28 73 74 72  stml tag).  (str
09e0: 69 6e 67 2d 3e 73 79 6d 62 6f 6c 20 28 73 74 72  ing->symbol (str
09f0: 69 6e 67 2d 61 70 70 65 6e 64 20 22 73 3a 22 20  ing-append "s:" 
0a00: 28 73 79 6d 62 6f 6c 2d 3e 73 74 72 69 6e 67 20  (symbol->string 
0a10: 74 61 67 29 29 29 29 0a 0a 0a 28 64 65 66 69 6e  tag))))...(defin
0a20: 65 20 28 73 3a 74 6f 6b 73 2d 3e 73 74 6d 6c 20  e (s:toks->stml 
0a30: 72 65 73 20 74 61 67 20 72 65 6d 20 61 6c 6c 6f  res tag rem allo
0a40: 77 65 64 29 0a 20 20 3b 3b 20 28 70 72 69 6e 74  wed).  ;; (print
0a50: 20 22 74 61 67 3a 20 22 20 74 61 67 20 22 20 72   "tag: " tag " r
0a60: 65 6d 3a 20 22 20 72 65 6d 29 0a 20 20 28 69 66  em: " rem).  (if
0a70: 20 28 6e 75 6c 6c 3f 20 72 65 6d 29 0a 20 20 20   (null? rem).   
0a80: 20 20 20 28 6c 69 73 74 20 28 61 70 70 65 6e 64     (list (append
0a90: 20 72 65 73 20 28 69 66 20 74 61 67 0a 09 09 09   res (if tag....
0aa0: 20 20 20 20 28 6c 69 73 74 20 28 73 3a 74 61 67      (list (s:tag
0ab0: 2d 3e 73 74 6d 6c 20 74 61 67 29 29 0a 09 09 09  ->stml tag))....
0ac0: 09 27 28 29 29 29 20 23 66 20 27 28 29 20 61 6c  .'())) #f '() al
0ad0: 6c 6f 77 65 64 29 20 3b 3b 20 74 68 65 20 63 61  lowed) ;; the ca
0ae0: 73 65 20 6f 66 20 61 20 6c 6f 6e 65 20 74 61 67  se of a lone tag
0af0: 20 0a 20 20 20 20 20 20 3b 3b 20 68 61 6e 64 6c   .      ;; handl
0b00: 65 20 61 20 73 74 61 72 74 69 6e 67 20 74 61 67  e a starting tag
0b10: 0a 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28 74  .      (let* ((t
0b20: 6d 70 20 20 20 20 20 20 20 28 73 3a 75 70 74 6f  mp       (s:upto
0b30: 2d 74 61 67 20 72 65 6d 20 61 6c 6c 6f 77 65 64  -tag rem allowed
0b40: 29 29 0a 09 20 20 20 20 20 28 74 78 74 20 20 20  ))..     (txt   
0b50: 20 20 20 20 28 63 61 72 20 74 6d 70 29 29 20 20      (car tmp))  
0b60: 20 20 20 20 3b 3b 20 74 68 69 73 20 74 78 74 20      ;; this txt 
0b70: 67 6f 65 73 20 77 69 74 68 20 74 61 67 21 21 21  goes with tag!!!
0b80: 0a 09 20 20 20 20 20 28 6e 65 78 74 74 61 67 20  ..     (nexttag 
0b90: 20 20 28 63 61 64 72 20 74 6d 70 29 29 20 20 20    (cadr tmp))   
0ba0: 20 20 3b 3b 20 74 68 69 73 20 69 73 20 74 68 65    ;; this is the
0bb0: 20 4e 45 58 54 20 44 41 4d 4e 20 74 61 67 21 0a   NEXT DAMN tag!.
0bc0: 09 20 20 20 20 20 28 62 65 67 69 6e 2d 74 61 67  .     (begin-tag
0bd0: 20 28 63 61 64 64 72 20 74 6d 70 29 29 0a 09 20   (caddr tmp)).. 
0be0: 20 20 20 20 28 6e 65 77 72 65 6d 20 20 20 20 28      (newrem    (
0bf0: 63 61 64 64 64 72 20 74 6d 70 29 29 29 0a 09 3b  cadddr tmp)))..;
0c00: 3b 20 28 70 72 69 6e 74 20 22 74 78 74 3a 20 20  ; (print "txt:  
0c10: 20 20 20 20 20 20 22 20 74 78 74 20 22 5c 6e 6e        " txt "\nn
0c20: 65 78 74 74 61 67 3a 20 20 20 20 22 20 6e 65 78  exttag:    " nex
0c30: 74 74 61 67 20 22 5c 6e 62 65 67 69 6e 2d 74 61  ttag "\nbegin-ta
0c40: 67 3a 20 20 22 20 62 65 67 69 6e 2d 74 61 67 20  g:  " begin-tag 
0c50: 22 5c 6e 6e 65 77 72 65 6d 3a 20 20 20 20 20 22  "\nnewrem:     "
0c60: 20 6e 65 77 72 65 6d 20 22 5c 6e 72 65 73 3a 20   newrem "\nres: 
0c70: 20 20 20 20 20 20 20 22 20 72 65 73 20 22 5c 6e         " res "\n
0c80: 22 29 0a 09 28 69 66 20 62 65 67 69 6e 2d 74 61  ")..(if begin-ta
0c90: 67 20 3b 3b 20 6e 65 73 74 20 74 68 65 20 66 6f  g ;; nest the fo
0ca0: 6c 6c 6f 77 69 6e 67 20 73 74 75 66 66 0a 09 20  llowing stuff.. 
0cb0: 20 20 20 28 6c 65 74 2a 20 28 28 63 68 69 6c 64     (let* ((child
0cc0: 64 61 74 20 28 73 3a 74 6f 6b 73 2d 3e 73 74 6d  dat (s:toks->stm
0cd0: 6c 20 27 28 29 20 6e 65 78 74 74 61 67 20 6e 65  l '() nexttag ne
0ce0: 77 72 65 6d 20 61 6c 6c 6f 77 65 64 29 29 0a 09  wrem allowed))..
0cf0: 09 20 20 20 28 63 68 69 6c 64 20 20 20 20 28 63  .   (child    (c
0d00: 61 72 20 63 68 69 6c 64 64 61 74 29 29 0a 09 09  ar childdat))...
0d10: 20 20 20 28 6e 65 77 74 61 67 20 20 20 28 63 61     (newtag   (ca
0d20: 64 72 20 63 68 69 6c 64 64 61 74 29 29 0a 09 09  dr childdat))...
0d30: 20 20 20 28 6e 65 77 72 65 6d 32 20 20 28 63 61     (newrem2  (ca
0d40: 64 64 72 20 63 68 69 6c 64 64 61 74 29 29 0a 09  ddr childdat))..
0d50: 09 20 20 20 28 61 6c 6c 6f 77 65 64 20 20 28 63  .   (allowed  (c
0d60: 61 64 64 64 72 20 63 68 69 6c 64 64 61 74 29 29  adddr childdat))
0d70: 29 20 3b 3b 20 79 61 2c 20 69 74 20 73 68 6f 75  ) ;; ya, it shou
0d80: 6c 64 6e 27 74 20 68 61 76 65 20 63 68 61 6e 67  ldn't have chang
0d90: 65 64 0a 09 20 20 20 20 20 20 28 69 66 20 74 61  ed..      (if ta
0da0: 67 20 0a 09 09 20 20 28 73 3a 74 6f 6b 73 2d 3e  g ...  (s:toks->
0db0: 73 74 6d 6c 20 28 61 70 70 65 6e 64 20 72 65 73  stml (append res
0dc0: 20 28 6c 69 73 74 20 28 61 70 70 65 6e 64 20 28   (list (append (
0dd0: 6c 69 73 74 20 28 73 3a 74 61 67 2d 3e 73 74 6d  list (s:tag->stm
0de0: 6c 20 74 61 67 29 29 20 63 68 69 6c 64 20 28 6c  l tag)) child (l
0df0: 69 73 74 20 74 78 74 29 29 29 29 0a 09 09 09 09  ist txt)))).....
0e00: 6e 65 77 74 61 67 20 6e 65 77 72 65 6d 32 20 61  newtag newrem2 a
0e10: 6c 6c 6f 77 65 64 29 0a 09 09 20 20 28 73 3a 74  llowed)...  (s:t
0e20: 6f 6b 73 2d 3e 73 74 6d 6c 20 28 61 70 70 65 6e  oks->stml (appen
0e30: 64 20 72 65 73 20 28 6c 69 73 74 20 74 78 74 29  d res (list txt)
0e40: 20 63 68 69 6c 64 29 0a 09 09 09 09 6e 65 77 74   child).....newt
0e50: 61 67 20 6e 65 77 72 65 6d 32 20 61 6c 6c 6f 77  ag newrem2 allow
0e60: 65 64 29 29 29 0a 09 20 20 20 20 3b 3b 20 69 74  ed)))..    ;; it
0e70: 20 6d 75 73 74 20 68 61 76 65 20 62 65 65 6e 20   must have been 
0e80: 61 6e 20 65 6e 64 20 74 61 67 0a 09 20 20 20 20  an end tag..    
0e90: 28 6c 69 73 74 20 28 61 70 70 65 6e 64 20 72 65  (list (append re
0ea0: 73 20 28 6c 69 73 74 20 0a 09 09 09 20 20 20 20  s (list ....    
0eb0: 20 20 20 28 69 66 20 74 61 67 0a 09 09 09 09 20     (if tag..... 
0ec0: 20 20 28 6c 69 73 74 20 28 73 3a 74 61 67 2d 3e    (list (s:tag->
0ed0: 73 74 6d 6c 20 74 61 67 29 20 74 78 74 29 0a 09  stml tag) txt)..
0ee0: 09 09 09 20 20 20 74 78 74 29 29 29 0a 09 09 20  ...   txt)))... 
0ef0: 20 23 66 0a 09 09 20 20 6e 65 77 72 65 6d 0a 09   #f...  newrem..
0f00: 09 20 20 61 6c 6c 6f 77 65 64 29 29 29 29 29 0a  .  allowed))))).
0f10: 0a 0a 3b 3b 20 22 3c 22 20 22 62 22 20 22 3e 22  ..;; "<" "b" ">"
0f20: 20 20 3d 3e 20 22 3c 62 3e 22 0a 3b 3b 20 22 3c    => "<b>".;; "<
0f30: 22 0a 3b 3b 20 28 64 65 66 69 6e 65 20 28 73 3a  ".;; (define (s:
0f40: 72 65 62 75 69 6c 64 2d 74 61 67 73 20 69 6e 70  rebuild-tags inp
0f50: 75 74 2d 6c 69 73 74 29 0a 0a 3b 3b 20 28 22 62  ut-list)..;; ("b
0f60: 6c 61 68 20 62 6c 61 68 22 20 22 3c 22 20 22 62  lah blah" "<" "b
0f70: 22 20 22 3e 22 20 22 6d 6f 72 65 20 73 74 75 66  " ">" "more stuf
0f80: 66 22 20 22 3c 22 20 22 69 22 20 22 3e 22 20 29  f" "<" "i" ">" )
0f90: 20 0a 3b 3b 20 20 20 20 20 3d 3e 20 28 22 62 6c   .;;     => ("bl
0fa0: 61 68 20 62 6c 61 68 22 20 62 20 23 74 20 28 20  ah blah" b #t ( 
0fb0: 22 6d 6f 72 65 20 73 74 75 66 66 22 20 22 3c 22  "more stuff" "<"
0fc0: 20 22 69 22 20 22 3e 22 20 29 29 0a 3b 3b 20 28   "i" ">" )).;; (
0fd0: 22 62 6c 61 68 20 62 6c 61 68 22 20 22 3c 22 20  "blah blah" "<" 
0fe0: 22 2f 62 22 20 22 3e 22 20 22 6d 6f 72 65 20 73  "/b" ">" "more s
0ff0: 74 75 66 66 22 20 22 3c 22 20 22 69 22 20 22 3e  tuff" "<" "i" ">
1000: 22 20 29 20 0a 3b 3b 20 20 20 20 20 3d 3e 20 28  " ) .;;     => (
1010: 22 62 6c 61 68 20 62 6c 61 68 22 20 62 20 23 66  "blah blah" b #f
1020: 20 28 20 22 6d 6f 72 65 20 73 74 75 66 66 22 20   ( "more stuff" 
1030: 22 3c 22 20 22 69 22 20 22 3e 22 20 29 29 0a 28  "<" "i" ">" )).(
1040: 64 65 66 69 6e 65 20 28 73 3a 75 70 74 6f 2d 74  define (s:upto-t
1050: 61 67 20 69 6e 6c 73 74 20 61 6c 6c 6f 77 65 64  ag inlst allowed
1060: 2d 74 61 67 73 29 0a 20 20 28 69 66 20 28 6e 75  -tags).  (if (nu
1070: 6c 6c 3f 20 69 6e 6c 73 74 29 20 69 6e 6c 73 74  ll? inlst) inlst
1080: 0a 20 20 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70  .      (let loop
1090: 20 28 28 74 6f 6b 20 20 28 63 61 72 20 69 6e 6c   ((tok  (car inl
10a0: 73 74 29 29 0a 09 09 20 28 74 61 69 6c 20 28 63  st))... (tail (c
10b0: 64 72 20 69 6e 6c 73 74 29 29 0a 09 09 20 28 70  dr inlst))... (p
10c0: 72 65 6c 20 22 22 29 29 20 3b 3b 20 63 72 65 61  rel "")) ;; crea
10d0: 74 65 20 61 20 73 74 72 69 6e 67 20 6f 72 20 61  te a string or a
10e0: 20 6c 69 73 74 20 6f 66 20 73 74 72 69 6e 67 20   list of string 
10f0: 70 61 72 74 73 3f 0a 09 28 69 66 20 28 73 74 72  parts?..(if (str
1100: 69 6e 67 3d 3f 20 74 6f 6b 20 22 3c 22 29 20 3b  ing=? tok "<") ;
1110: 3b 20 6d 69 67 68 74 20 68 61 76 65 20 61 20 74  ; might have a t
1120: 61 67 0a 09 20 20 20 20 28 69 66 20 28 3e 20 28  ag..    (if (> (
1130: 6c 65 6e 67 74 68 20 74 61 69 6c 29 20 31 29 20  length tail) 1) 
1140: 3b 3b 20 74 6f 20 62 65 20 61 20 74 61 67 2c 20  ;; to be a tag, 
1150: 6e 65 65 64 20 74 61 67 20 61 6e 64 20 63 6c 6f  need tag and clo
1160: 73 69 6e 67 20 22 3e 22 0a 09 09 28 6c 65 74 20  sing ">"...(let 
1170: 28 28 74 61 67 20 28 63 61 72 20 74 61 69 6c 29  ((tag (car tail)
1180: 29 0a 09 09 20 20 20 20 20 20 28 65 6e 64 20 28  )...      (end (
1190: 63 61 64 72 20 74 61 69 6c 29 29 0a 09 09 20 20  cadr tail))...  
11a0: 20 20 20 20 28 72 65 6d 20 28 63 64 64 72 20 74      (rem (cddr t
11b0: 61 69 6c 29 29 29 20 0a 09 09 20 20 28 69 66 20  ail))) ...  (if 
11c0: 28 73 74 72 69 6e 67 3d 3f 20 65 6e 64 20 22 3e  (string=? end ">
11d0: 22 29 20 3b 3b 20 79 65 70 2c 20 69 74 20 69 73  ") ;; yep, it is
11e0: 20 70 72 6f 62 61 62 6c 79 20 61 20 74 61 67 0a   probably a tag.
11f0: 09 09 20 20 20 20 20 20 28 6c 65 74 2a 20 28 28  ..      (let* ((
1200: 74 72 69 6d 2d 74 61 67 20 28 69 66 20 20 28 73  trim-tag (if  (s
1210: 74 72 69 6e 67 3d 3f 20 22 2f 22 20 28 73 75 62  tring=? "/" (sub
1220: 73 74 72 69 6e 67 20 74 61 67 20 30 20 31 29 29  string tag 0 1))
1230: 0a 09 09 09 09 09 20 20 20 20 28 73 75 62 73 74  ......    (subst
1240: 72 69 6e 67 20 74 61 67 20 31 20 28 73 74 72 69  ring tag 1 (stri
1250: 6e 67 2d 6c 65 6e 67 74 68 20 74 61 67 29 29 20  ng-length tag)) 
1260: 23 66 29 29 0a 09 09 09 20 20 20 20 20 28 74 61  #f))....     (ta
1270: 67 2d 73 79 6d 20 20 28 73 74 72 69 6e 67 2d 3e  g-sym  (string->
1280: 73 79 6d 62 6f 6c 20 28 69 66 20 74 72 69 6d 2d  symbol (if trim-
1290: 74 61 67 20 74 72 69 6d 2d 74 61 67 20 74 61 67  tag trim-tag tag
12a0: 29 29 29 29 0a 09 09 09 28 69 66 20 28 6d 65 6d  ))))....(if (mem
12b0: 62 65 72 20 74 61 67 2d 73 79 6d 20 61 6c 6c 6f  ber tag-sym allo
12c0: 77 65 64 2d 74 61 67 73 29 0a 09 09 09 20 20 20  wed-tags)....   
12d0: 20 3b 3b 20 68 61 76 65 20 61 20 76 61 6c 69 64   ;; have a valid
12e0: 20 74 61 67 2c 20 72 65 62 75 69 6c 64 20 69 74   tag, rebuild it
12f0: 20 61 6e 64 20 72 65 74 75 72 6e 20 74 68 65 20   and return the 
1300: 72 65 73 75 6c 74 0a 09 09 09 20 20 20 20 28 6c  result....    (l
1310: 69 73 74 20 70 72 65 6c 20 74 61 67 2d 73 79 6d  ist prel tag-sym
1320: 20 28 69 66 20 74 72 69 6d 2d 74 61 67 20 23 66   (if trim-tag #f
1330: 20 23 74 29 20 72 65 6d 29 0a 09 09 09 20 20 20   #t) rem)....   
1340: 20 3b 3b 20 6e 6f 74 20 61 20 76 61 6c 69 64 20   ;; not a valid 
1350: 74 61 67 2c 20 63 6f 6e 76 65 72 74 20 22 3c 22  tag, convert "<"
1360: 20 61 6e 64 20 22 3e 22 20 61 6e 64 20 61 64 64   and ">" and add
1370: 20 61 6c 6c 20 74 6f 20 70 72 65 6c 0a 09 09 09   all to prel....
1380: 20 20 20 20 28 6c 65 74 20 28 28 6e 65 77 70 72      (let ((newpr
1390: 65 6c 20 28 73 74 72 69 6e 67 2d 61 70 70 65 6e  el (string-appen
13a0: 64 20 70 72 65 6c 20 22 26 6c 74 3b 22 20 74 61  d prel "&lt;" ta
13b0: 67 20 22 26 67 74 3b 22 29 29 29 0a 09 09 09 20  g "&gt;"))).... 
13c0: 20 20 20 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20       (if (null? 
13d0: 72 65 6d 29 28 6c 69 73 74 20 6e 65 77 70 72 65  rem)(list newpre
13e0: 6c 20 23 66 20 23 66 20 27 28 29 29 20 3b 3b 20  l #f #f '()) ;; 
13f0: 72 65 74 75 72 6e 20 6e 65 77 70 72 65 6c 20 2d  return newprel -
1400: 20 61 64 64 20 23 66 20 23 66 20 3f 3f 3f 0a 09   add #f #f ???..
1410: 09 09 09 20 20 28 6c 6f 6f 70 20 28 63 61 72 20  ...  (loop (car 
1420: 72 65 6d 29 28 63 64 72 20 72 65 6d 29 20 6e 65  rem)(cdr rem) ne
1430: 77 70 72 65 6c 29 29 29 29 29 0a 09 09 20 20 20  wprel)))))...   
1440: 20 20 20 3b 3b 20 73 6f 2c 20 69 74 20 77 61 73     ;; so, it was
1450: 6e 27 74 20 61 20 74 61 67 0a 09 09 20 20 20 20  n't a tag...    
1460: 20 20 28 6c 65 74 20 28 28 6e 65 77 70 72 65 6c    (let ((newprel
1470: 20 28 73 74 72 69 6e 67 2d 61 70 70 65 6e 64 20   (string-append 
1480: 70 72 65 6c 20 22 26 6c 74 3b 22 20 74 61 67 29  prel "&lt;" tag)
1490: 29 29 0a 09 09 09 28 69 66 20 28 6e 75 6c 6c 3f  ))....(if (null?
14a0: 20 74 61 69 6c 29 0a 09 09 09 20 20 20 20 28 6c   tail)....    (l
14b0: 69 73 74 20 6e 65 77 70 72 65 6c 20 23 66 20 23  ist newprel #f #
14c0: 66 20 27 28 29 29 0a 09 09 09 20 20 20 20 28 6c  f '())....    (l
14d0: 6f 6f 70 20 28 63 61 72 20 72 65 6d 29 28 63 64  oop (car rem)(cd
14e0: 72 20 72 65 6d 29 20 6e 65 77 70 72 65 6c 29 29  r rem) newprel))
14f0: 29 29 29 0a 09 09 3b 3b 20 74 6f 6f 20 73 68 6f  )))...;; too sho
1500: 72 74 20 74 6f 20 62 65 20 61 20 74 61 67 0a 09  rt to be a tag..
1510: 09 28 6c 69 73 74 20 28 61 70 70 6c 79 20 73 74  .(list (apply st
1520: 72 69 6e 67 2d 61 70 70 65 6e 64 20 70 72 65 6c  ring-append prel
1530: 20 22 26 6c 74 3b 22 20 74 61 69 6c 29 20 23 66   "&lt;" tail) #f
1540: 20 23 66 20 27 28 29 29 29 0a 09 20 20 20 20 28   #f '()))..    (
1550: 69 66 20 28 6e 75 6c 6c 3f 20 74 61 69 6c 29 20  if (null? tail) 
1560: 0a 09 09 3b 3b 20 77 65 27 72 65 20 64 6f 6e 65  ...;; we're done
1570: 0a 09 09 28 6c 69 73 74 20 28 73 74 72 69 6e 67  ...(list (string
1580: 2d 61 70 70 65 6e 64 20 70 72 65 6c 20 74 6f 6b  -append prel tok
1590: 29 20 23 66 20 23 66 20 27 28 29 29 0a 09 09 28  ) #f #f '())...(
15a0: 6c 6f 6f 70 20 28 63 61 72 20 74 61 69 6c 29 28  loop (car tail)(
15b0: 63 64 72 20 74 61 69 6c 29 28 73 74 72 69 6e 67  cdr tail)(string
15c0: 2d 61 70 70 65 6e 64 20 70 72 65 6c 20 74 6f 6b  -append prel tok
15d0: 29 29 29 29 29 29 29 0a 0a 0a 28 64 65 66 69 6e  )))))))...(defin
15e0: 65 20 28 73 3a 64 69 76 79 2d 75 70 2d 63 67 69  e (s:divy-up-cgi
15f0: 2d 73 74 72 20 69 6e 73 74 72 29 0a 20 20 28 6d  -str instr).  (m
1600: 61 70 20 28 6c 61 6d 62 64 61 20 28 78 29 20 28  ap (lambda (x) (
1610: 73 74 72 69 6e 67 2d 73 70 6c 69 74 20 78 20 22  string-split x "
1620: 3d 22 29 29 20 28 73 74 72 69 6e 67 2d 73 70 6c  =")) (string-spl
1630: 69 74 20 69 6e 73 74 72 20 22 26 22 29 29 29 0a  it instr "&"))).
1640: 0a 28 64 65 66 69 6e 65 20 28 73 3a 64 65 63 6f  .(define (s:deco
1650: 64 65 2d 73 74 72 20 69 6e 73 74 72 29 0a 20 20  de-str instr).  
1660: 28 6c 65 74 2a 20 28 28 61 62 63 20 28 73 74 72  (let* ((abc (str
1670: 69 6e 67 2d 73 75 62 73 74 69 74 75 74 65 20 22  ing-substitute "
1680: 5c 5c 2b 22 20 22 20 22 20 69 6e 73 74 72 20 23  \\+" " " instr #
1690: 74 29 29 0a 09 20 28 74 6f 6b 73 20 28 73 3a 73  t)).. (toks (s:s
16a0: 70 6c 69 74 2d 73 74 72 69 6e 67 20 61 62 63 20  plit-string abc 
16b0: 22 25 22 29 29 29 0a 20 20 20 20 28 69 66 20 28  "%"))).    (if (
16c0: 3c 20 28 6c 65 6e 67 74 68 20 74 6f 6b 73 29 20  < (length toks) 
16d0: 32 29 20 61 62 63 0a 09 28 6c 65 74 20 6c 6f 6f  2) abc..(let loo
16e0: 70 20 28 28 68 65 61 64 20 28 63 61 64 72 20 74  p ((head (cadr t
16f0: 6f 6b 73 29 29 0a 09 09 20 20 20 28 74 61 69 6c  oks))...   (tail
1700: 20 28 63 64 64 72 20 74 6f 6b 73 29 29 0a 09 09   (cddr toks))...
1710: 20 20 20 28 72 65 73 75 6c 74 20 28 63 61 72 20     (result (car 
1720: 74 6f 6b 73 29 29 29 0a 09 20 20 28 69 66 20 28  toks)))..  (if (
1730: 73 74 72 69 6e 67 3d 3f 20 68 65 61 64 20 22 22  string=? head ""
1740: 29 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 75  )..      (if (nu
1750: 6c 6c 3f 20 74 61 69 6c 29 0a 09 09 20 20 72 65  ll? tail)...  re
1760: 73 75 6c 74 0a 09 09 20 20 28 6c 6f 6f 70 20 28  sult...  (loop (
1770: 63 61 72 20 74 61 69 6c 29 28 63 64 72 20 74 61  car tail)(cdr ta
1780: 69 6c 29 20 72 65 73 75 6c 74 29 29 0a 09 20 20  il) result))..  
1790: 20 20 20 20 28 6c 65 74 2a 20 28 28 6b 65 79 20      (let* ((key 
17a0: 28 73 75 62 73 74 72 69 6e 67 20 68 65 61 64 20  (substring head 
17b0: 30 20 32 29 29 0a 09 09 20 20 20 20 20 28 72 65  0 2))...     (re
17c0: 6d 20 28 73 75 62 73 74 72 69 6e 67 20 68 65 61  m (substring hea
17d0: 64 20 32 20 28 73 74 72 69 6e 67 2d 6c 65 6e 67  d 2 (string-leng
17e0: 74 68 20 68 65 61 64 29 29 29 0a 09 09 20 20 20  th head)))...   
17f0: 20 20 28 6e 75 6d 20 28 73 74 72 69 6e 67 2d 3e    (num (string->
1800: 6e 75 6d 62 65 72 20 6b 65 79 20 31 36 29 29 0a  number key 16)).
1810: 09 09 20 20 20 20 20 28 63 68 20 20 28 69 66 20  ..     (ch  (if 
1820: 28 61 6e 64 20 28 6e 75 6d 62 65 72 3f 20 6e 75  (and (number? nu
1830: 6d 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  m).             
1840: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1850: 20 20 20 20 20 20 28 65 78 61 63 74 3f 20 6e 75        (exact? nu
1860: 6d 29 29 0a 09 09 09 20 20 20 20 20 20 28 69 6e  m))....      (in
1870: 74 65 67 65 72 2d 3e 63 68 61 72 20 6e 75 6d 29  teger->char num)
1880: 0a 09 09 09 20 20 20 20 20 20 23 66 29 29 20 3b  ....      #f)) ;
1890: 3b 20 74 68 69 73 20 69 73 20 61 6e 20 65 72 72  ; this is an err
18a0: 6f 72 2e 20 49 20 77 69 6c 6c 20 70 72 6f 62 61  or. I will proba
18b0: 62 6c 79 20 72 65 67 72 65 74 20 74 68 69 73 20  bly regret this 
18c0: 73 6f 6d 65 20 64 61 79 0a 09 09 20 20 20 20 20  some day...     
18d0: 28 63 68 73 74 72 20 20 28 69 66 20 63 68 20 28  (chstr  (if ch (
18e0: 6d 61 6b 65 2d 73 74 72 69 6e 67 20 31 20 63 68  make-string 1 ch
18f0: 29 20 22 22 29 29 0a 09 09 20 20 20 20 20 28 6e  ) ""))...     (n
1900: 65 77 72 65 73 20 28 69 66 20 63 68 0a 09 09 09  ewres (if ch....
1910: 09 20 28 73 74 72 69 6e 67 2d 61 70 70 65 6e 64  . (string-append
1920: 20 72 65 73 75 6c 74 20 63 68 73 74 72 20 72 65   result chstr re
1930: 6d 29 0a 09 09 09 09 20 28 73 74 72 69 6e 67 2d  m)..... (string-
1940: 61 70 70 65 6e 64 20 72 65 73 75 6c 74 20 68 65  append result he
1950: 61 64 29 29 29 29 0a 09 09 3b 3b 20 28 70 72 69  ad))))...;; (pri
1960: 6e 74 20 22 68 65 61 64 3a 20 22 20 68 65 61 64  nt "head: " head
1970: 20 22 20 6e 75 6d 3a 20 22 20 6e 75 6d 20 22 20   " num: " num " 
1980: 63 68 3a 20 7c 22 20 63 68 20 22 7c 20 63 68 73  ch: |" ch "| chs
1990: 74 72 3a 20 22 20 63 68 73 74 72 29 0a 09 09 28  tr: " chstr)...(
19a0: 69 66 20 28 6e 75 6c 6c 3f 20 74 61 69 6c 29 0a  if (null? tail).
19b0: 09 09 20 20 20 20 6e 65 77 72 65 73 0a 09 09 20  ..    newres... 
19c0: 20 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61     (loop (car ta
19d0: 69 6c 29 28 63 64 72 20 74 61 69 6c 29 20 6e 65  il)(cdr tail) ne
19e0: 77 72 65 73 29 29 29 29 29 29 29 29 0a 0a 28 64  wres))))))))..(d
19f0: 65 66 69 6e 65 20 28 73 3a 70 72 6f 63 65 73 73  efine (s:process
1a00: 2d 63 67 69 2d 69 6e 70 75 74 20 69 6e 73 74 72  -cgi-input instr
1a10: 29 0a 20 20 28 6d 61 70 20 28 6c 61 6d 62 64 61  ).  (map (lambda
1a20: 20 28 78 79 29 0a 20 20 20 20 20 20 20 20 20 28   (xy).         (
1a30: 6c 69 73 74 20 28 73 74 72 69 6e 67 2d 3e 73 79  list (string->sy
1a40: 6d 62 6f 6c 20 28 73 3a 64 65 63 6f 64 65 2d 73  mbol (s:decode-s
1a50: 74 72 20 28 63 61 72 20 78 79 29 29 29 0a 20 20  tr (car xy))).  
1a60: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 69 66               (if
1a70: 20 28 65 71 3f 20 28 6c 65 6e 67 74 68 20 78 79   (eq? (length xy
1a80: 29 20 31 29 20 0a 20 20 20 20 20 20 20 20 20 20  ) 1) .          
1a90: 20 20 20 20 20 20 20 20 20 22 22 0a 20 20 20 20           "".    
1aa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28                 (
1ab0: 73 3a 64 65 63 6f 64 65 2d 73 74 72 20 28 63 61  s:decode-str (ca
1ac0: 64 72 20 78 79 29 29 29 29 29 0a 20 20 20 20 20  dr xy))))).     
1ad0: 20 20 20 20 28 73 3a 64 69 76 79 2d 75 70 2d 63      (s:divy-up-c
1ae0: 67 69 2d 73 74 72 20 69 6e 73 74 72 29 29 29 0a  gi-str instr))).
1af0: 0a 3b 3b 20 66 6f 72 20 74 65 73 74 69 6e 67 20  .;; for testing 
1b00: 2d 2d 20 64 65 6c 65 74 6d 65 0a 3b 3b 20 28 64  -- deletme.;; (d
1b10: 65 66 69 6e 65 20 62 6c 61 68 20 22 70 6f 73 74  efine blah "post
1b20: 5f 74 69 74 6c 65 3d 25 32 42 25 32 42 25 32 42  _title=%2B%2B%2B
1b30: 25 32 42 25 32 42 25 32 42 25 32 42 25 32 42 25  %2B%2B%2B%2B%2B%
1b40: 32 42 25 32 42 25 32 42 68 65 6c 6c 6f 2d 2d 2d  2B%2B%2Bhello---
1b50: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2b 2b 2b 2b 2b  ----------++++++
1b60: 2b 2b 2b 2b 2b 25 32 36 25 32 36 25 32 36 25 32  +++++%26%26%26%2
1b70: 36 25 32 36 25 32 36 25 32 36 25 32 36 25 32 36  6%26%26%26%26%26
1b80: 25 34 30 25 34 30 25 34 30 25 34 30 25 34 30 25  %40%40%40%40%40%
1b90: 34 30 25 34 30 25 34 30 25 34 30 26 70 6f 73 74  40%40%40%40&post
1ba0: 5f 62 6f 64 79 3d 25 32 42 25 32 42 25 32 42 25  _body=%2B%2B%2B%
1bb0: 32 42 25 32 42 25 32 42 25 32 42 25 32 42 25 32  2B%2B%2B%2B%2B%2
1bc0: 42 25 32 42 25 32 42 68 65 6c 6c 6f 2d 2d 2d 2d  B%2B%2Bhello----
1bd0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2b 2b 2b 2b 2b 2b  ---------+++++++
1be0: 2b 2b 2b 2b 25 32 36 25 32 36 25 32 36 25 32 36  ++++%26%26%26%26
1bf0: 25 32 36 25 32 36 25 32 36 25 32 36 25 32 36 25  %26%26%26%26%26%
1c00: 34 30 25 34 30 25 34 30 25 34 30 25 34 30 25 34  40%40%40%40%40%4
1c10: 30 25 34 30 25 34 30 25 34 30 25 30 44 25 30 41  0%40%40%40%0D%0A
1c20: 25 30 44 25 30 41 25 32 42 25 32 42 25 32 42 25  %0D%0A%2B%2B%2B%
1c30: 32 42 25 32 42 25 32 42 25 32 42 25 32 42 25 32  2B%2B%2B%2B%2B%2
1c40: 42 25 32 42 25 32 42 68 65 6c 6c 6f 2d 2d 2d 2d  B%2B%2Bhello----
1c50: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2b 2b 2b 2b 2b 2b  ---------+++++++
1c60: 2b 2b 2b 2b 25 32 36 25 32 36 25 32 36 25 32 36  ++++%26%26%26%26
1c70: 25 32 36 25 32 36 25 32 36 25 32 36 25 32 36 25  %26%26%26%26%26%
1c80: 34 30 25 34 30 25 34 30 25 34 30 25 34 30 25 34  40%40%40%40%40%4
1c90: 30 25 34 30 25 34 30 25 34 30 25 30 44 25 30 41  0%40%40%40%0D%0A
1ca0: 25 30 44 25 30 41 25 30 44 25 30 41 25 32 42 25  %0D%0A%0D%0A%2B%
1cb0: 32 42 25 32 42 25 32 42 25 32 42 25 32 42 25 32  2B%2B%2B%2B%2B%2
1cc0: 42 25 32 42 25 32 42 25 32 42 25 32 42 68 65 6c  B%2B%2B%2B%2Bhel
1cd0: 6c 6f 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b  lo-------------+
1ce0: 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 25 32 36 25 32 36  ++++++++++%26%26
1cf0: 25 32 36 25 32 36 25 32 36 25 32 36 25 32 36 25  %26%26%26%26%26%
1d00: 32 36 25 32 36 25 34 30 25 34 30 25 34 30 25 34  26%26%40%40%40%4
1d10: 30 25 34 30 25 34 30 25 34 30 25 34 30 25 34 30  0%40%40%40%40%40
1d20: 26 6e 65 77 5f 70 6f 73 74 3d 53 75 62 6d 69 74  &new_post=Submit
1d30: 22 29 0a 3b 3b 20 28 64 65 66 69 6e 65 20 62 6c  ").;; (define bl
1d40: 61 68 32 20 22 70 6f 73 74 5f 74 69 74 6c 65 3d  ah2 "post_title=
1d50: 35 25 32 35 26 70 6f 73 74 5f 62 6f 64 79 3d 61  5%25&post_body=a
1d60: 6e 64 2b 31 30 25 32 35 26 6e 65 77 5f 70 6f 73  nd+10%25&new_pos
1d70: 74 3d 53 75 62 6d 69 74 22 29 0a                 t=Submit").