diff options
author | Case Duckworth | 2023-08-28 23:20:53 -0500 |
---|---|---|
committer | Case Duckworth | 2023-08-28 23:20:53 -0500 |
commit | 8701fe064a6b56e203f6a452d65d18216f18777e (patch) | |
tree | f50ab4d60acbd09986114b473c16445c2e30e43f | |
parent | Add unprintable helper functions (diff) | |
download | schmaltz-8701fe064a6b56e203f6a452d65d18216f18777e.tar.gz schmaltz-8701fe064a6b56e203f6a452d65d18216f18777e.zip |
Change render semantics
Now `render` outputs to the current output port, not a string. `render->string` and `render-string->string` added to output to a string.
-rw-r--r-- | schmaltz.sld | 2 | ||||
-rw-r--r-- | schmaltz.sls | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/schmaltz.sld b/schmaltz.sld index 31ed610..e47defb 100644 --- a/schmaltz.sld +++ b/schmaltz.sld | |||
@@ -1,6 +1,8 @@ | |||
1 | (define-library (schmaltz) | 1 | (define-library (schmaltz) |
2 | (export render | 2 | (export render |
3 | render-string | 3 | render-string |
4 | render->string | ||
5 | render-string->string | ||
4 | ;; Configuration | 6 | ;; Configuration |
5 | render-specials | 7 | render-specials |
6 | render-unprintables | 8 | render-unprintables |
diff --git a/schmaltz.sls b/schmaltz.sls index 4afcf40..c47467a 100644 --- a/schmaltz.sls +++ b/schmaltz.sls | |||
@@ -46,6 +46,18 @@ | |||
46 | (lambda (port) | 46 | (lambda (port) |
47 | (render env port)))))) | 47 | (render env port)))))) |
48 | 48 | ||
49 | (define (render->string . args) | ||
50 | (call-with-port (open-output-string) | ||
51 | (lambda (out) | ||
52 | (apply render args) | ||
53 | (get-output-string out)))) | ||
54 | |||
55 | (define (render-string->string str . args) | ||
56 | (call-with-port (open-output-string) | ||
57 | (lambda (out) | ||
58 | (apply render-string args) | ||
59 | (get-output-string out)))) | ||
60 | |||
49 | ;;; Configuration | 61 | ;;; Configuration |
50 | 62 | ||
51 | (define render-environment | 63 | (define render-environment |
@@ -83,3 +95,4 @@ | |||
83 | 95 | ||
84 | (define (unprintable/backtrack ch) | 96 | (define (unprintable/backtrack ch) |
85 | (list ch #\#)) | 97 | (list ch #\#)) |
98 | (display (list->string (reverse acc)))) | ||