better error & newline behavior

pull/170/head
Matthew Butterick 6 years ago
parent 4ac6a9b693
commit 7e7b800676

@ -11,7 +11,10 @@
(define is-meta-value? hash?)
(define is-doc-value? txexpr?)
(define+provide define-meta (λ xs "\n")) ;; newline will merge with surroundings
;; if `define-meta` is defined it will pop an error msg if the wrong number of args
;; even though this error will happen after macro expansion, when metas are extracted
;; empty string will merge with surroundings
(define+provide (define-meta k v) "")
(define+provide current-metas (make-parameter #f))

@ -37,7 +37,8 @@
(define (strip-leading-newlines doc)
;; drop leading newlines, as they're often the result of `defines` and `requires`
(or (memf (λ (ln) (not (equal? ln (setup:newline)))) doc) null))
(or (memf (λ (ln) (and (not (equal? ln (setup:newline)))
(not (equal? ln "")))) doc) null))
(define-syntax (pollen-module-begin stx)
@ -65,6 +66,6 @@
(require pollen/top pollen/core pollen/setup (submod "." META-MOD-ID))
(provide (all-defined-out) METAS-ID DOC-ID)
(define prev-metas (current-metas))
(and (current-metas METAS-ID) "\n") ; because newlines get stripped, voids don't
(and (current-metas METAS-ID) "") ; because empty strings get stripped, voids don't
(begin . EXPRS)
(and (current-metas prev-metas) "")))])) ; leave behind empty string, not void

@ -1 +1 @@
1519509395
1519530928

Loading…
Cancel
Save