aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/licentia/document.lux
blob: b3787f2f294901bb7097c5ff1749ede39525ec15 (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
(.module:
  [lux (#- or and)
   [data
    ["." text
     ["%" format (#+ format)]]
    [collection
     ["." list ("#;." functor)]]]])

(def: #export (quote text)
  (-> Text Text)
  (format text.double-quote text text.double-quote))

(def: #export (block content)
  (-> Text Text)
  (format content text.new-line text.new-line))

(def: #export (plural singular)
  (-> Text Text)
  (format singular "(s)"))

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

(def: #export paragraph
  (-> (List Text) Text)
  (|>> (list;map ..sentence)
       (text.join-with text.new-line)))

(template [<name> <word>]
  [(def: #export <name>
     (-> (List Text) Text)
     (text.join-with (format ", " <word> " ")))]

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

(type: #export Section
  {#title Text
   #content Text})

(def: #export (section value)
  (-> Section Text)
  (format (block (get@ #title value))
          (get@ #content value)))