[racket] scribble/lp: comments stripped, how to stop?
I haven't used /lp myself. I am stuck here -- Matthias
On Apr 22, 2012, at 12:25 AM, Deren Dohoda wrote:
> Hi Matthias,
>
> I cannot seem to get it to work. I can get scribble to be happy, but
> not the scribble/lp file.
>
> First try: (somewhere in the middle of the file)
> @(begin
> #reader scribble/comment-reader
> (chunk <hs-from-xs>
> (define hs ; (xi+1) - xi
> (map - (rest xs) (drop-right xs 1)))))
> Second try:
> @chunk[<hs-from-xs>
> #reader scribble/comment-reader
> (define hs ; (xi+1) - xi
> (map - (rest xs) (drop-right xs 1)))]
>
> Both can be scribbled with the comment when included with (lp-include
> ...), but doesn't run when one runs the file itself. When the file is
> run, this error appears: "bad syntax (multiple expressions after
> identifier) in: (define hs (code:comment ..." The only place I can
> find code:comment defined is in
> "...Racket/collects/scribble/lp/lang/lang.rkt":
> (provide code:comment)
> (define-syntax (code:comment stx)
> (if (eq? (syntax-local-context) 'expression)
> (syntax (void))
> (syntax (define (f x) x))))
>
> It looks like it was supposed to strip the comment when being run.
> "...Racket/collects/scribble/comment-reader.rkt" does have
>
> (define (do-comment port recur)
> (let loop ()
> (when (equal? #\; (peek-char port))
> (read-char port)
> (loop)))
> (when (equal? #\space (peek-char port))
> (read-char port))
> `(code:comment
> (unsyntax ...
>
> So it seems like this is where code:comment is coming from, but for
> some reason the code:comments rule from lang.rkt isn't seeing it.
>
> Deren
>
> On Sat, Apr 21, 2012 at 9:07 PM, Matthias Felleisen
> <matthias at ccs.neu.edu> wrote:
>>
>> Do you use
>>
>> @;%
>> @(begin
>> #reader scribble/comment-reader
>> (racketblock
>> (place-image ROCKET X ... MTSCN)
>> ))
>> @;%
>>
>> to write down code blocks? It installs a reader that can cope with comments.
>>
>>
>>
>> On Apr 21, 2012, at 4:53 PM, Deren Dohoda wrote:
>>
>>> I have finally started learning scribble for use in literate
>>> programming to break away from noweb for Racket. It's quite excellent,
>>> I am glad to be making the switch. Thank everyone for their work. I
>>> miss the math of latex but it isn't a dealbreaker.
>>>
>>> However, part of writing code is commenting the code for reminders of
>>> why little bits are the way they are. The problem is that the scribble
>>> HTML output has stripped all comments from the chunks. I have tried
>>> digging down into scribble/lp but I must admit the guts are outside my
>>> ability to understand. I'm guessing it is because the reader has
>>> already stripped comments from the syntax by the time Racket gets to
>>> the "chunk" syntax rule. The one bit that seems to indicate it strips
>>> comments (code:comment) never seems to be used anywhere. I know that
>>> there are code examples with comments in the Racket documentation. Is
>>> there any way to keep code comments preserved in the scribbled view of
>>> chunks?
>>>
>>> Thanks,
>>> Deren
>>> ____________________
>>> Racket Users list:
>>> http://lists.racket-lang.org/users
>>