[plt-scheme] PLT Source Browser

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sat Feb 4 12:54:53 EST 2006

Dave Herman wrote:
> Man oh man, is that beautiful! You just scored major hacker points. And 
> you even reused someone else's code? What's wrong with you?! ;)
> One request: any chance of syntax highlighting the doc.txt files too, 
> i.e., the same way that the Help Desk does? Presumably there's some 
> Scheme code in DrScheme that does this already that you could call. 
> Ideally, if it could even link any of the recognized cross-references to 
> the online version of the DrScheme docs, this would be really sweet. 
> (BTW, you'd use the info.ss file to determine what the doc files are, 
> just as PLaneT does.)

Sure, it just requires someone to write an doc.txt to xexpr
converter. Currently all txt-files are handled by handle-txt,
which reads from current-input-port and returns an xexpr.

(define (handle-txt)
   (let* ([s           (port->string (current-input-port))]
          [p           (open-input-string s)]
          [first-line  (read-line p)]
          [second-line (read-line p)])
     ; use first or second line as header?
     (let ([header
              ; if the first 4 (and likely all) characters
              ; are the same, use the second line in stead
              [(and (string? first-line)
                    (string? second-line)
                    (> (string-length first-line) 4)
                    (every?-ec (: c (substring first-line 0 4))
                               (char=? c (string-ref first-line 0))))
              [(string? first-line)
       ; remove underscores from header
       (let ([header (string-ec (: c header)
                                (if (not (char=? c #\_)))
           (h1 ,header)
           (pre ,s))))))

the relevant HelpDesk source file?

Jens Axel Søgaard

Posted on the users mailing list.