Racket users,
I’m trying to read a scheme file, decorate a bit of window dressing
around the edges, and write the expressions to a new file. I’ve got the
basic mechanism working with (read . . .) and (pretty-write . . .), but
of course that doesn’t preserve linebreaks. So now I’m trying to
improve it to preserve linebreaks. It would be nice to preserve all
whitespace, but I'll settle for linebreaks. The racket docs seem to
suggest it is possible:
2.6 Rendering Syntax Objects with Formatting
(require syntax/to-string) package: base
procedure
(syntax->string stx-list) → string?
stx-list : (and/c syntax? stx-list?)
Builds a string with newlines and indenting according to the source
locations in stx-list; the outer pair of parens are not rendered
from stx-list.
However, when I evaluate:
(syntax->string (read-syntax "mystring" (open-input-string
"(comment\n \"hello world\"\n line)")))
I get:
"comment\"hello world\"line"
which has no whitespace at all, not even the whitespace that is
necessary to separate the original tokens.
I get a similar behavior if I read-syntax from a file and apply
syntax->string to those values.
Does anyone know how to get syntax->string to recover the original
whitespace?
I'm using Racket 8.0 cs on Ubuntu 20.
Thanks in advance,
Jeff Henrikson
--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/95dd99f5-2d04-a607-ed11-bc235095eeb7%40gmail.com.