From 83f9c99cf1ce8f1af0ac5a77a329cc1d90be135f Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 2 Oct 2009 19:44:10 +0000 Subject: [PATCH] adjust para decoding to better work with @ notation svn: r16220 --- collects/scribblings/slideshow/slides.scrbl | 5 ++++- collects/slideshow/core.ss | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/collects/scribblings/slideshow/slides.scrbl b/collects/scribblings/slideshow/slides.scrbl index 4e59a18c5b..4b11e20a33 100644 --- a/collects/scribblings/slideshow/slides.scrbl +++ b/collects/scribblings/slideshow/slides.scrbl @@ -120,7 +120,10 @@ among the @scheme[element]s are decoded by performing the following substitutions: @litchar{---} @d=> @litchar["\u2014"], @litchar{--} @d=> @litchar["\u2013"], @litchar{``} @d=> @litchar["\u201C"], @litchar{''} @d=> @litchar["\u201D"], @litchar{'} @d=> -@litchar["\u2019"]. +@litchar["\u2019"]. In addition, to better work with +@schememodname[at-exp] notation, if an @scheme[element] is @scheme["\n"], +then it is dropped along with any spaces at the start of the next +element. Strings are split at spaces for word-wrapping to fit the page, and a space is added between elements. If a string element starts with one diff --git a/collects/slideshow/core.ss b/collects/slideshow/core.ss index 3797828ad2..709b0fee14 100644 --- a/collects/slideshow/core.ss +++ b/collects/slideshow/core.ss @@ -669,7 +669,7 @@ [else vl-append]) width (if decode? - (map decode s) + (decode s) s))]) (if fill? ((case align @@ -684,7 +684,23 @@ (define (decode s) (let loop ([s s]) (cond - [(list? s) (map loop s)] + [(list? s) + (map + decode + ;; Remove "\n", and also cancel extra spaces after "\n": + (let loop ([s s]) + (cond + [(null? s) null] + [(equal? (car s) "\n") + (let nloop ([s (cdr s)]) + (if (and (pair? s) + (string? (car s))) + (let ([a (regexp-replace #rx"^ +" (car s) "")]) + (if (string=? a "") + (nloop (cdr s)) + (loop (cons a (cdr s))))) + (loop s)))] + [else (cons (car s) (loop (cdr s)))])))] [(not (string? s)) s] [(regexp-match-positions #rx"---" s) => (lambda (m)