diff --git a/pollen/scribblings/setup.scrbl b/pollen/scribblings/setup.scrbl index c38dae6..92156f7 100644 --- a/pollen/scribblings/setup.scrbl +++ b/pollen/scribblings/setup.scrbl @@ -149,7 +149,9 @@ If the cache can't find a certain file on the watchlist, it will be ignored. The @defoverridable[index-pages (listof string?)]{List of strings that the project server will use as directory default pages, in order of priority. Has no effect on command-line rendering operations. Also has no effect on your live web server (usually that's a setting you need to make in an @tt{.htaccess} configuration file).} But with this setting, you can simulate the behavior of your live server, so that internal index-page URLs work correctly. - + @defoverridable[trim-whitespace? boolean?)]{Predicate that controls whether the Pollen source reader trims whitespace from the beginning of a @racket[doc] export. You might set this to @racket[#false] if you're using Pollen as a preprocessor for another programming language and you want to preserve leading whitespace accurately. + + @pollen-history[#:added "1.5"]} @section{Parameters} diff --git a/pollen/test/data/whitespace/pollen.rkt b/pollen/test/data/whitespace/pollen.rkt new file mode 100644 index 0000000..0b7928d --- /dev/null +++ b/pollen/test/data/whitespace/pollen.rkt @@ -0,0 +1,7 @@ +#lang racket/base +(require pollen/setup) +(provide (all-defined-out)) + +(module setup racket/base + (provide (all-defined-out)) + (define trim-whitespace? #false)) \ No newline at end of file diff --git a/pollen/test/data/whitespace/whitespace-test.txt.pp b/pollen/test/data/whitespace/whitespace-test.txt.pp new file mode 100644 index 0000000..79f4617 --- /dev/null +++ b/pollen/test/data/whitespace/whitespace-test.txt.pp @@ -0,0 +1,10 @@ +#lang pollen + + + + + + + + +one \ No newline at end of file diff --git a/pollen/test/test-trim-whitespace.rkt b/pollen/test/test-trim-whitespace.rkt new file mode 100644 index 0000000..830c200 --- /dev/null +++ b/pollen/test/test-trim-whitespace.rkt @@ -0,0 +1,11 @@ +#lang at-exp racket/base +(require rackunit pollen/setup racket/runtime-path pollen/render) + +;; define-runtime-path only allowed at top level +(define-runtime-path whitespace-dir "data/whitespace") +(define-runtime-path whitespace-source "data/whitespace/whitespace-test.txt.pp") + +(parameterize ([current-directory whitespace-dir] + [current-project-root whitespace-dir] + [current-output-port (open-output-string)]) + (check-equal? (render whitespace-source) "\n\n\n\n\n\n\n\n\none")) \ No newline at end of file