aboutsummaryrefslogtreecommitdiff
path: root/licentia/source/program/licentia/document.lux
blob: 4a3253f769b6b21207d05852761614610acdc702 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(.using
 [library
  [lux {"-" or and}
   [data
    ["[0]" text
     ["%" format {"+" format}]]
    [collection
     ["[0]" list ("[1]#[0]" functor)]]]]])

(def: .public (quote text)
  (-> Text Text)
  (format text.double_quote text text.double_quote))

(def: .public (block content)
  (-> Text Text)
  (format content text.new_line text.new_line))

(def: .public (plural singular)
  (-> Text Text)
  (format singular "(s)"))

(def: .public (sentence content)
  (-> Text Text)
  (format content "."))

(def: .public paragraph
  (-> (List Text) Text)
  (|>> (list#each ..sentence)
       (text.interposed text.new_line)))

(template [<name> <word>]
  [(def: .public <name>
     (-> (List Text) Text)
     ... https://en.wikipedia.org/wiki/Serial_comma
     (text.interposed (format ", " <word> " ")))]

  [or     "or"]
  [and    "and"]
  [and/or "and/or"]
  )

(type: .public Section
  (Record
   [#title Text
    #content Text]))

(def: .public (section value)
  (-> Section Text)
  (format (..block (the #title value))
          (the #content value)))