[racket] Scribble: how can I produce a straight quote within @racketfont?

From: Matthew Butterick (mb at mbtype.com)
Date: Mon Jul 14 03:06:01 EDT 2014

Thank you, that works.

FWIW I'm always tripped up by the fact that the `racket___font` functions decode their arguments by default. IMHO if text is to be formatted to look like code, that ought to imply literal handling of characters.

I've noticed a variant of this problem in the TeX typesetting of both Dybvig's Scheme book and SICP (see http://tex.stackexchange.com/a/178779).


On Jul 13, 2014, at 10:10 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> I would have suggested the `literal` pattern, but I see that
> `racketfont` and `tt` (the former defined using the latter) are weird
> and misdocumented: they apply the 'tt style only to string arguments,
> and not uniformly to all given content.
> 
> I think that you want
> 
> (define (racketfont* . args)
>   (element 'tt args))
> 
> This `racketfont*` refrains from calling `decode-content`, which is the
> step that converts quotes to curly quotes.
> 
> At Sun, 13 Jul 2014 11:11:09 -0700, Matthew Butterick wrote:
>> In Scribble, the @racketfont tag decodes its content, so this markup:
>> 
>>> @racketfont{◊(select 'h1 doc)}
>> 
>> Will render as this (with a curly quote in front of h1):
>> 
>>> ◊(select ’h1 doc)
>> 
>> 
>> But I want this (straight quote, not curly)
>> 
>>> ◊(select 'h1 doc)
>> 
>> 
>> @verbatim is not the answer, because it will create a line break.
>> 
>> @literal seems like it should be the answer:
>> 
>>> @racketfont{◊(select @literal{'}h1 doc)}
>> 
>> But oddly, even though @literal is nested inside @racketfont, the resulting 
>> markup doesn't reflect this, and renders as if the Scribble had been written 
>> this way:
>> 
>>> @racketfont{◊(select} @literal{'}@racketfont{h1 doc)}
>> 
>> 
>> Meaning, the @literal content adopts the formatting of the enclosing block, not 
>> the @racketfont span.
>> 
>> Hence the question: how can I force a literal character within @racketfont that 
>> actually adopts the formatting of @racketfont.
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users



Posted on the users mailing list.