~subsetpark/pantagruel-web

pantagruel-web/index.janet -rw-r--r-- 1.3 KiB
f1039a14 — Zach Smith Update meta name. 2 months 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
36
37
38
39
(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 class=chapter-separator>`)
         (string/replace-all ";" `<hr class=where>`)
         (string/replace-all "\t" "&emsp;")))

  (defn render-line
    [line]
    (if-not (string/has-prefix? "//" line)
      (let [replaced (replace-unicode line)
            line-end (if (string/has-suffix? ">" replaced) "" "<br>")]
        (string replaced line-end))
      (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")}})