~subsetpark/bagatto

3820976c0cbb3214fb194f811dc8c3fdb2ab9ffd — Zach Smith 4 months ago ab40776 threads
Filter out empty strings in mmarkdown attributes
1 files changed, 11 insertions(+), 2 deletions(-)

M src/multimarkdown.janet
M src/multimarkdown.janet => src/multimarkdown.janet +11 -2
@@ 1,7 1,16 @@
(import sh)

(defn- metadata-keys [md] (->> (sh/$< echo ,(string md) | multimarkdown -m --) (string/trim) (string/split "\n")))
(defn- metadata-value [md key] (->> (sh/$< echo ,(string md) | multimarkdown -e ,key --) (string/trim)))
(defn- metadata-keys
  [md]
  (->> (sh/$< echo ,(string md) | multimarkdown -m --)
       (string/trim)
       (string/split "\n")
       (filter (complement empty?))))

(defn- metadata-value
  [md key]
  (->> (sh/$< echo ,(string md) | multimarkdown -e ,key --)
       (string/trim)))

(defn metadata [md]
  (let [keys (metadata-keys md)]