Assuming you have GUI Easy installed (raco pkg install gui-easy), you might want to copy-paste the codeblock into DrRacket and run the example.
Punchline: you can't. The font has somehow transformed the ~, among other characters (including the lambda). DrRacket is able to reacquire the lambda, but not the ~ characters. Here's a hex dump of what I get:
The lambda became the sequence f0 9d 9c 86 and the ~ became e2 88 bc.
Does anyone know how I can configure Scribble (either via font or some other "really I mean it" mechanism) to produce copy-and-runnable code?
I suspect using racketmod0 from scribble/manual may be part of my issue, but I've gone through several different mechanisms to try to get good Racket figures in the PDF and this is what I've settled on for #lang-based figures.
I also see that <~ has been converted to \RktSym{{\Stttextless}$\sim$} in the LaTeX source; I'm certain that's part of the problem. I really want to just use a ~ character. (The conversion of < to {\Stttextless} doesn't seem to be a bother.)
Some intreprid digging which included copying and modifying scribble/run.rkt to add my own mixin wrappers around render-content and render-other to display certain inputs reveals the following chain (even when using #,(make-element symbol-color "<~")):
Eventually we get to the element that includes the <~; this is handed to the latex-renderer's render-content.
After some pre-processing, it calls (super render-content …) with the same element. Assuming that's base-renderer, the method calls (render-content (element-content i) …), which is (render-content "<~" …).
This repeats latex-renderer's pre-processing and (super render-content "<~" …).
Now, base-renderer calls (render-other "<~" …) because it has a string.
As pointed out, render-other in the LaTeX renderer cooperates with display-protected to turn ~ into $\sim$.
So, I think what I need is a way to bypass this and insert some other LaTeX command to generate a real tilde.
So, I think what I need is a way to bypass this and insert some other LaTeX command to generate a real tilde.
Inserting a real tilde is just what the Stackoverflow thread was about:
Since tilde is a special character in LaTeX, they needed some trickery (using catcode) to produce a real tilde. They needed it in order to copy/paste urls containing tilde. But the same trick ought to work in your context.
Yes, though I need to figure out / remind myself how to insert
arbitrary LaTeX in the document at the right places, hopefully without
making it too hard to type the code examples.
Aha! The following allowed me to use #,<~ and #,~> to get what I want, thanks to \textasciitilde{} producing something reasonable that also works with copy/paste:
How? The (make-element "textasciitilde" "") will be converted to \textasciitilde{} by the LaTeX renderer; then we just wrap it with < or > in the right position, and colored by the symbol-color style (which is what racketidfont uses, IIRC; I spent so much tme staring at scribble source I don't remember exactly how I found that style).
In Vim, the command :v/make-element/s/\v(#,)@<!(\<\~|\~\>)/#,&/ge will replace all non-unsyntaxed occurrences of the two arrows with unsyntaxed versions (at least, the ones not on lines containing make-element, which suffices in my case).
I think changing \sym to \textasciitilde is probably a good idea. We might also want to do something so that computer modern isn't the default tt font too? I thought that acmart doesn't use computer modern, tho?