@dedbox Issue 1: How are you creating the evaluator for examples? If you make a sandbox evaluator, then the default is to create a new inspector, so results will be transparent outside the sandbox where they’re rendered. You can set sandbox-make-inspector
to current-inspector
to avoid that. Issue 2: Difficult to say without more information, but it’s possible that you’re using #,
and it’s interpreted as an examples
escape instead of a require syntax unquote. If that’s it, you use use #:escape
to pick a different escape form.
@mflatt issue 1 resolved, and issue 2 is back on my radar. Thanks!
Is it possible for make-evaluator
to require a submodule in the same file? This isn’t working: (module m racket)
(parameterize
([sandbox-security-guard current-security-guard])
(make-evaluator 'racket #:requires '('m)))
It gives require: unknown module
module name: #<resolved-module-path:'m>
Setting all parameters to the trusted sandbox configuration values gives the same error
The 'm
style to access a relative submodule only works in static positions, like require
. For a dynamic context, like calling make-evaluator
, you’ll need to provide an absolute module path. The quote-module-path
form from syntax/location
may be the right way to go.
@mflatt that did the trick! Now I can make Scribble MWEs.
Issue 2 resolved! I was using the #:lang
argument instead of #:eval
since yesterday.
:sweat_smile:
I like how with Python a multi-line string is easily formed with triple quotes: str = “”"multiple lined string”“” I’ve been using heredocs with Racket: (define str #<<EOF multiple lined string EOF ) but that’s a lot less elegant (IMHO), and more syntax-y (meaning less obvious what’s going on).
Is there a better way to do multi-line strings in Racket? Perhaps a way to map the heredoc behavior to triple quotes?
@me1 I personally prefer to use at-exp reader for that
@~a{first line
second line
third line}
@~a will give you what you need once at-exp is enabled
here is a nice overview of what you can do with at-exp in regards to strings: http://www.greghendershott.com/2015/08/at-expressions.html
those regexps look very perly
Thanks. I’ll try to get it working better with SublimeREPL in Sublime Text (my main environment). That is, “#lang” doesn’t work it seems.
I do like the triple-quote method, too; is there a simple way to replicate that behavior?
The reason being that sometimes when I’m editing the company wiki I want to parse a copy-pasted bit and run a script on the string really quickly, and every complication slows things. :disappointed:
That would be a reader extension, I think
(chapter 17 in the Racket Guide)
@me1 probably reader extension is the way as @dedbox said, as to your #lang not working - to set up racket to use different language you would start your racket with the following command e.g.: racket -I typed/racket
the problem is I don’t know how to add the reader extension so it would work: racket -I at-exp racket
doesn’t work
hmmm
for right now at least I made a macOS Keyboard Maestro macro: (define x KEYBOARD_MAESTRO_MACRO[#<<EOF {{paste}} EOF ) ]
still not quite as elegant as something like triple quotes, though, since in files themselves all the heredocs are very syntax-y
triple quotes would also “work” here :wink: : (define multi-line #<<"""
Some multi-line
string literal.
"""
)
hmmm, great point!
added :emacs: and :racket-flat: emojis