@@ -40,10 +40,11 @@ ymd->english ymd->dateformat default-authorname default-title tx-strs + first-words build-note-id notes->last-disposition-values ) (define default-authorname "Joel Dueck") @@ -80,10 +81,17 @@ (cond [(txexpr? xpr) (apply string-append (map tx-strs (get-elements xpr)))] [(string? xpr) xpr] [else ""])) +(define (first-words str n) + (define trunc + (apply string-append + (add-between (take (string-split str) n) " "))) + ;; Remove trailing punctuation (commas, etc.) + (regexp-replace #px"\\W+$" trunc "")) + (module+ test (require rackunit) (define test-metas (hash 'name "Fiver" 'size "Small")) (define test-attrs '([name "Hazel"] [rank "Chief"]))