diff --git a/pollen/private/main-base.rkt b/pollen/private/main-base.rkt index 2decefe..471098d 100644 --- a/pollen/private/main-base.rkt +++ b/pollen/private/main-base.rkt @@ -9,7 +9,7 @@ (define (make-parse-proc parser-mode root-proc) (cond [(eq? parser-mode default-mode-pagetree) decode-pagetree] - [(eq? parser-mode default-mode-markup) (λ (xs) (apply root-proc xs))] + [(eq? parser-mode default-mode-markup) (λ (xs) (apply root-proc (remove-voids xs)))] [(eq? parser-mode default-mode-markdown) (λ (xs) (let* ([xs (stringify xs)] [xs ((dynamic-require 'markdown 'parse-markdown) xs)] diff --git a/pollen/private/splice.rkt b/pollen/private/splice.rkt index d33b7eb..a3ab1d5 100644 --- a/pollen/private/splice.rkt +++ b/pollen/private/splice.rkt @@ -20,12 +20,12 @@ (let loop ([x x]) (if (list? x) ; don't exclude `attrs?` here, because it will exclude valid splice input like '((@ "foo")) (apply append (map (λ (x) (let ([proc (if (spliceable? x) ; drop the splice-signal from front with `cdr` - cdr - list)] - [x (if (not (attrs? x)) ; don't recur on attributes, so null strings are not spliced within - (loop x) - x)]) - (proc x))) (filter not-null-string? x))) + cdr + list)] + [x (if (not (attrs? x)) ; don't recur on attributes, so null strings are not spliced within + (loop x) + x)]) + (proc x))) (filter not-null-string? x))) x))) (module+ test @@ -52,4 +52,20 @@ (module+ test (check-equal? (strip-empty-attrs '(p ())) '(p)) (check-equal? (strip-empty-attrs '(p () "foo")) '(p "foo")) - (check-equal? (strip-empty-attrs '(p () (em () "foo") "bar")) '(p (em "foo") "bar"))) \ No newline at end of file + (check-equal? (strip-empty-attrs '(p () (em () "foo") "bar")) '(p (em "foo") "bar"))) + + +;; used with pollen/markup to suppress void arguments, +;; consistent with how pollen/pre and pollen/markdown handle them +(define (remove-voids x) + (let loop ([x x]) + (if (pair? x) + (for/list ([xi (in-list x)] + #:unless (void? xi)) + (loop xi)) + x))) + +(module+ test + (check-equal? (remove-voids (list 1 2 3 (void))) '(1 2 3)) + (check-equal? (remove-voids (list 1 (void) 2 3 (list 4 5 6 (void)))) '(1 2 3 (4 5 6))) + (check-equal? (remove-voids (void)) (void))) \ No newline at end of file diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index 1b79c02..2210766 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1511248782 +1511711794 diff --git a/pollen/test/test-langs.rkt b/pollen/test/test-langs.rkt index 4ec9d05..ce07fa1 100644 --- a/pollen/test/test-langs.rkt +++ b/pollen/test/test-langs.rkt @@ -15,19 +15,22 @@ (module test-pre pollen/pre - "hello world") + "hello world" + (void)) (require (prefix-in pre: 'test-pre)) (check-equal? pre:doc "hello world") (module test-markup pollen/markup - "hello world") + "hello world" + (void)) (require (prefix-in markup: 'test-markup)) (check-equal? markup:doc '(root "hello world")) (module test-markdown pollen/markdown - "hello world") + "hello world" + (void)) (require (prefix-in markdown: 'test-markdown)) (check-equal? markdown:doc '(root (p "hello world")))