@@ -65,14 +65,22 @@ @defproc[(tx-strs [tx txexpr?]) string?] Finds all the strings from the @emph{elements} of @racket[_tx] (ignoring attributes) and concatenates them together. +@examples[#:eval dust-eval +(tx-strs '(p [[class "intro"]] + (em "I’m not opening the safe") ", Wilson remembers thinking."))] + @defproc[(first-words [str string?] [n exact-nonnegative-integer?]) string?] Returns a string containing the first @racket[_n] words of @racket[_str], removing any trailing -punctuation. +punctuation. It will trip on opening punctuation or punctuation surrounded by spaces. + +@examples[#:eval dust-eval +(first-words "Another time, perhaps." 2) +(first-words "‘One problem’ – it don’t always do punctuation right." 3)] @section{Article parsers and helpers} @defproc[(default-title [date string?]) string?] @@ -120,16 +128,17 @@ Given a list of tagged X-expressions (ideally a list of @code{note}s), returns two values: the value of the @racket['disposition] attribute for the last note that contains one, and the ID of that note. @examples[#:eval dust-eval -(define notelist (list '(note [[date "2018-02-19"] [disposition "* problematic"]] "First note") - '(note [[date "2018-03-19"]] "Second note") - '(note [[date "2018-04-19"] [disposition "† recanted"]] "Third note"))) -(notes->last-disposition-values notelist)] +(define notelist + (list + '(note [[date "2018-02-19"] [disposition "* problematic"]] "First note") + '(note [[date "2018-03-19"]] "Second note") + '(note [[date "2018-04-19"] [disposition "† recanted"]] "Third note"))) -;; Extract the last disposition (if any), and the ID of the disposing note, out of a list of notes +(notes->last-disposition-values notelist)] @section{Date formatters} @defproc[(ymd->english [ymd-string string?]) string?]