aboutsummaryrefslogtreecommitdiff
path: root/licentia/source/program/licentia/document.lux
blob: 95c14e2311e3319130eb45161351f815480186aa (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)))