From 8701fe064a6b56e203f6a452d65d18216f18777e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 28 Aug 2023 23:20:53 -0500 Subject: 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. --- schmaltz.sld | 2 ++ schmaltz.sls | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/schmaltz.sld b/schmaltz.sld index 31ed610..e47defb 100644 --- a/schmaltz.sld +++ b/schmaltz.sld @@ -1,6 +1,8 @@ (define-library (schmaltz) (export render render-string + render->string + render-string->string ;; Configuration render-specials render-unprintables diff --git a/schmaltz.sls b/schmaltz.sls index 4afcf40..c47467a 100644 --- a/schmaltz.sls +++ b/schmaltz.sls @@ -46,6 +46,18 @@ (lambda (port) (render env port)))))) +(define (render->string . args) + (call-with-port (open-output-string) + (lambda (out) + (apply render args) + (get-output-string out)))) + +(define (render-string->string str . args) + (call-with-port (open-output-string) + (lambda (out) + (apply render-string args) + (get-output-string out)))) + ;;; Configuration (define render-environment @@ -83,3 +95,4 @@ (define (unprintable/backtrack ch) (list ch #\#)) + (display (list->string (reverse acc)))) -- cgit 1.4.1-21-gabe81