Sha256: d18b9c1799d9d3e768bc25fc5d79384a54f61accaff5cc231b5b09f319315ac1

Contents?: true

Size: 1.32 KB

Versions: 17

Compression:

Stored size: 1.32 KB

Contents

(require '[clojure.string :as str])

(defn slugify [text]
  (-> text
      (clojure.string/lower-case)
      (clojure.string/replace " " "-")
      (clojure.string/replace #"[^a-z0-9\-_]" "")))

(defn remove-code-blocks [content]
  (let [code-block-regex #"(?s)```.*?```"]
    (clojure.string/replace content code-block-regex "")))

(defn process-line [line]
  (when-let [[_ hashes title] (re-find #"^(\#{2,}) (.+)" line)]
    (let [link (slugify title)]
      {:level (count hashes) :title title :link link})))

(defn create-index [content]
  (let [processed-content (remove-code-blocks content)
        processed-lines (->> processed-content
                             clojure.string/split-lines
                             (map process-line)
                             (remove nil?))]
    (->> processed-lines
         (map (fn [{:keys [level title link]}]
                (str (apply str (repeat (* 4 (- level 2)) " "))
                     "- ["
                     title
                     "](#"
                     link
                     ")")))
         (clojure.string/join "\n"))))


(let [content         (slurp "template.md")
      index           (create-index content)
      updated-content (clojure.string/replace content "{index}" index)]
  (spit "README.md" updated-content)
  (println "README.md successfully generated."))

Version data entries

17 entries across 17 versions & 5 rubygems

Version Path
gemini-ai-3.2.0 tasks/generate-readme.clj
cohere-ai-1.0.2 tasks/generate-readme.clj
maritaca-ai-1.0.1 tasks/generate-readme.clj
gemini-ai-3.1.3 tasks/generate-readme.clj
mistral-ai-1.1.2 tasks/generate-readme.clj
ollama-ai-1.0.1 tasks/generate-readme.clj
ollama-ai-1.0.0 tasks/generate-readme.clj
mistral-ai-1.1.1 tasks/generate-readme.clj
gemini-ai-3.1.2 tasks/generate-readme.clj
gemini-ai-3.1.1 tasks/generate-readme.clj
maritaca-ai-1.0.0 tasks/generate-readme.clj
cohere-ai-1.0.1 tasks/generate-readme.clj
cohere-ai-1.0.0 tasks/generate-readme.clj
mistral-ai-1.1.0 tasks/generate-readme.clj
mistral-ai-1.0.0 tasks/generate-readme.clj
gemini-ai-3.1.0 tasks/generate-readme.clj
gemini-ai-3.0.0 tasks/generate-readme.clj