~subsetpark/pantagruel-web

ref: b4e464a2a8130999c4af6ba5ba434bc49378295d pantagruel-web/index.janet -rw-r--r-- 1.2 KiB
b4e464a2 — Zach Smith Add build 1 year, 6 days ago
                                                                                
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
(defn render-pantagruel
  [pant]
  (defn replace-unicode
    [line]
    (->> line
         (string/replace-all "all" "∀")
         (string/replace-all "_" "-")
         (string/replace-all "=>" "⇒")
         (string/replace-all "<=" "⇐")
         (string/replace-all "->" "→")
         (string/replace-all "---" "<hr>")
         (string/replace-all ";" "<hr><hr>")))

  (defn render-line
    [line]
    (if-not (string/has-prefix? "//" line)
      (string (replace-unicode line) "<br>")
      (bagatto/markdown->html (string "> " (string/trim line "/")))))

  (as-> pant .
        (string/split "\n" .)
        (filter (complement empty?) .)
        (map render-line .)
        (string/join . "\n")))

(def data {:index {:attrs {:title "Pantagruel: An Extremely Lightweight Specification Language"}}
           :pant {:src "index.pant"
                  :attrs bagatto/parse-base}
           :static {:src (bagatto/* "static/*")
                    :attrs bagatto/parse-base}})

(def site {:index {:dest "site/index.html"
                   :out (bagatto/renderer "/index")}
           :static {:each :static
                    :dest (bagatto/path-copier "site/static")}})