
wow, thanks!

(although nw, my server side code is untyped, keeping the bookmark around)

:bow:

Is there a way to add numbered captions (or ‘counters’) with a frame to the source code (using codeblock
) in scribble? (The effects I want is just like the picture shown below)

I guess you could wrap the codeblock call in your own function with a counter in scope

@oldsin i think what @jerome.martin.dev is getting to is that it’s possible but you don’t get it out of the box.

Yes I see. I just thought there might be some high level API that gave me this ability.

@oldsin wish there was. I think everyone has their own features for their scribble documents - some have made it into pkgs but there has not been, afaik, a concerted effort to have a scribble-extras library to do these things.

Something like this (except I don’t remember the exact use for codeblock, this might be wrong but you get the idea): (define numbered-codeblock
(let ([counter 0])
(lambda (title code-text)
(set! counter (add1 counter))
(codeblock
#:title (format "Listing ~a: ~a" counter title)
code-text))))

Obviously, if such feature is really interesting to a lot of people, somebody can make a Pull Request and add it to the standard, but as @pocmatos said, a scribble-extra
lib might be a good experimenting ground too!

Appreciate for your detailed source!

You’re welcome :slightly_smiling_face: It’s obviously going to crash as codeblock is not used like this, but anyways…

Also, my code is a global state. Using the function in different scribble modules is gonna continue counting up from where it was in the previous document. If one needs a per-document counter, we need to make something a bit more complex, I guess with a syntax-parameter
.

You should copy this conversation into a blog post

Agreed! I started taking down some notes but there are enough questions I still have at the boundary that it would take some time to absorb.

Really I think just copy-and-paste would make an illuminating post

I realized I never answered this. identifier-transformer-binding is just identifier-binding at phase 1 (rather than phase 0).

Yeah! I saw this last night. I only have vague intuition about phases as “eh, they stratify expansion passes.” As you know (for anyone following along) there’s really readable documentation here: https://docs.racket-lang.org/guide/phases.html

I’m working on this along with annotating it with some more examples

FYI (with thanks to @ben for bringing the existence of typed/web-server/http
to my attention), some of its types were out-of-date, particularly for cookie-related functions. I’ve made updates in https://github.com/racket/typed-racket/pull/817

Also, apparently I didn’t read this: > More specifically, the typesetting of identifiers in the above grammar is significant. For example, the second case for expr is a syntax-object list whose first element is an identifier, where the identifier’s lexical information specifies a binding to the #%plain-lambda of the racket/base language (i.e., the identifier is free-identifier=? to one whose binding is #%plain-lambda).

One thing I wish I could assemble would be a systematic history of the development of the Racket macro system (dating back to Scheme, I suppose) with each different feature in boxes and links to the corresponding mailing list posts, papers, blog posts, commits, etc…

@philip.mcgrath ack, I fell behind with your work in web-server — I made some changes to the various response-generating functions, too (not the same as your changes) and ran into conflicts
