◊(Local Yarn Code "Diff")

Differences From Artifact [295a2ae6]:

To Artifact [10bc504c]:


1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
1
2



3


4
5
6
7
8
9
10
11























-
-
-
+
-
-








-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
#lang racket/base

(require pollen/decode
         txexpr
         yarn/markup
(require yarn/markup)
         yarn/string
         yarn/tools)

(provide
 (all-defined-out)
 (all-from-out yarn/markup))

(module+ setup
  (provide block-tags)
  (define block-tags blocks-elements))

;; Customized paragraph decoder replaces single newlines within paragraphs
;; with single spaces instead of <br> tags. Allows for “semantic line wrapping”.
(define (decode-hardwrapped-paragraphs xs)
  (define (no-linebreaks xs)
    (decode-linebreaks xs " "))
  (decode-paragraphs xs 'paragraph #:linebreak-proc no-linebreaks))

(define (root . elems)
  (validate-txexpr `(test ,@elems))
  (check-title elems)
  `(document ,@(decode-hardwrapped-paragraphs elems)))

(define (check-title elems)
  (cond
    [(and (not (meta-set? 'title))
          ((tx-is? 'poetry #:has-attrs 'title) (car elems)))
     (set-meta 'title (format "‘~a’" (attr-ref (car elems) 'title)))
     (set-meta 'title-supplied? #t)]
    [(not (meta-set? 'title))
     (set-meta 'title (first-words elems 5))]))