I’m trying to typeset some passages with code blocks. How have people typeset source code with Pollen? I’d like to see some examples of how people have gone about solving this.
Specifically, I’m actually writing up some documentation for some Pollen commands I built for a very particular use case, and I’d like to show a side-by-side of commands and their effects. I’d love to be able to write a macro that does something this:
◊source-and-effect|{◊link["https://example.com"]{link text}}|
and I would then write source-and-effect
to render the literal source code in a pre
block and then the effect of typesetting that on the right. I’ve written a macro kinda like this:
(define-syntax (docs-example stx)
(syntax-parse stx
[(_ cmd)
(eprintf "cmd: ~a" (syntax->datum #'cmd))
#`(code-and-render
#,(format "~a" (syntax->datum #'cmd))
#,(read (open-input-string (syntax->datum #'cmd))))]))
and it almost works, but stx
gets the Racket syntax of course. So, I really need to put everything in quotes. But I’d like to not have to escape every "
in the source because those will be in a lot of examples for keyword arguments and whatnot.
Is there something like Scribble’s @codeblock
for typesetting stuff verbatim? There’s a great example in this section of the Scribble docs, where a @codeblock
command has another code block command within it. I haven’t been able to find anything in the Pollen docs—maybe my search-fu has fallen short…
Thanks in advance for any help.