aboutsummaryrefslogtreecommitdiff
path: root/licentia/source/program/licentia/document.lux
blob: 94348f030e92d93495e87848f08be7fb7652cb1f (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
(.module:
  [library
   [lux (#- or and)
    [data
     ["." text
      ["%" format (#+ format)]]
     [collection
      ["." list ("#\." 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\map ..sentence)
       (text.join_with text.new_line)))

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

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

(type: .public Section
  {#title Text
   #content Text})

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