Unfinished S-Expressions in scribbled code blocks

18 views
Skip to first unread message

Dominik Pantůček

unread,
Apr 12, 2020, 4:23:07 AM4/12/20
to Racket Users
Hello fellow Racketeers,

I've started a small side project and as a part of that I want to write
some articles interspersed with code. Scribble was a natural choice for
that task.

So I started with #lang scribble/manual as usual and after writing some
text, I tried to do something like the following:

====
#lang scribble/manual

... and here are the requires:

@racketblock{
(require
}

.. with the first one being this and we need that for ....

@racketblock{
(only-in ffi/unsafe ptr-set! _uint32)
}

...
====

Of course it renders the racketblocks as string, silly me. So I go for
@racketblock[] but that - in @-syntax translates to S-expressions with
"(require" (without the quotes) definitely not being a valid
S-expression. And therefore scribble cannot handle it.

Looking at [1] leaves me with an impression that it is not possible to
typeset parts of racket code in scribble. Only valid S-expressions (and
the #lang line, of course).

Using scribble/lp2 I can get closer to my wanted result, but really it
just works around the issue by forming valid S-expressions and expanding
chunks inside those.

What is the proper way of typesetting (in scribble) parts of racket code
which do not form complete S-expression?

And yes, I know this is rather strange requirement, but in this
particular case, I am pretty sure, I want to work with parts of
S-expressions without balanced parentheses. (Although the minimal
example definitely does not answer "why").

I assume I must have overlooked something, of course.


Cheers,
Dominik


[1] https://docs.racket-lang.org/scribble/scribble_manual_code.html

Sage Gerard

unread,
Apr 12, 2020, 11:22:29 AM4/12/20
to dominik....@trustica.cz, racket...@googlegroups.com
Does scribble/examples offer what you need?



-------- Original Message --------

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/d4473bd1-5b9c-b658-2989-df0a143d7ae9%40trustica.cz.

Dominik Pantůček

unread,
Apr 12, 2020, 1:01:26 PM4/12/20
to racket...@googlegroups.com

Ben Greenman

unread,
Apr 12, 2020, 1:22:11 PM4/12/20
to racket...@googlegroups.com
> What is the proper way of typesetting (in scribble) parts of racket code
> which do not form complete S-expression?

The proper way is to make a #lang (in particular, a `read-syntax`)
that deals with incomplete S-expressions.

I don't know if anyone has done / attempted this.

An improper way is to use `verbatim` for now and do without color:

```
#lang scribble/manual

@(define (mycode #:indent [indent 0] . content*)
(nested #:style 'code-inset (apply verbatim #:indent indent content*)))

... and here are the requires:

@mycode|{
(require
}|

.. with the first one being this and we need that for ....

@mycode[#:indent 2]|{
(only-in ffi/unsafe ptr-set! _uint32)
}|
```
Reply all
Reply to author
Forward
0 new messages