~subsetpark/subsetpark

ref: ac79ff1f88326f6bfe89dbc9540fc15ff318a67a subsetpark/notes.janet -rw-r--r-- 830 bytes
ac79ff1f — Zach Smith Drop the 'of course', it's redundant 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(defn- matcher [topic] (peg/compile topic))
(defn- highlight-replacement [topic] (string/format "`%s`" topic))
(defn- link-replacement [topic] (string/format "[%s][]" topic))
(defn- link-destination [topic] (string/format "[%s]: %s" topic (string topic ".html")))
(defn- titlify [topic] (string/replace-all "_" " " topic))

(defn parse-note [src attrs]
  (let [path (attrs :path)
        base (path/basename path)
        ext (path/ext base)
        topic (string/replace ext "" base)]
    (merge-into attrs {"peg" (matcher topic)
                       "highlight-replacement" (highlight-replacement topic)
                       "link-replacement" (link-replacement topic)
                       "link-destination" (link-destination topic)
                       "title" (titlify topic)
                       "topic" topic})))