<commit_before>(ns dragon.blog.post.util
  (:require [clojure.string :as string]
            [dragon.config.core :as config]
            [dragon.event.system.core :as event]
            [dragon.event.tag :as tag]
            [dragon.util :as util]
            [markdown.core :as markdown]
            [selmer.parser :as selmer]
            [taoensso.timbre :as log]))

(defn md->html
  [system md]
  (markdown/md-to-html-string
   md
   :inhibit-separator (config/template-skip-marker system)))

(defn selmer->html
  [system content]
  (selmer/render content {}))

(defn md+selmer->html
  [system content]
  (->> content
       (md->html system)
       (selmer->html system)))

(defn selmer+md->html
  [system content]
  (->> content
       (selmer->html system)
       (md->html system)))

(defn convert-body!
  [system data content-type]
  (case content-type
    :md
      (update-in data [:body] (partial md->html system))
    :selmer
      (update-in data [:body] (partial selmer->html system))
    [:md :selmer]
      (update-in data [:body] (partial md+selmer->html system))
    [:selmer :md]
      (update-in data [:body] (partial selmer+md->html system))))

(defn join-excerpt
  [system words number]
  (let [excerpt (string/join (config/word-joiner system)
                             (take number words))]
    (if (string/ends-with? excerpt (config/sentence-end system))
      (str excerpt (config/period-ellipsis system))
      (str excerpt (config/ellipsis system)))))

(defn copy-original-body
  [data]
  (assoc data :body-orig (:body data)))
<commit_msg>Updated body conversion utility functions to handle data arg.<commit_after>(ns dragon.blog.post.util
  (:require [clojure.string :as string]
            [dragon.config.core :as config]
            [dragon.event.system.core :as event]
            [dragon.event.tag :as tag]
            [dragon.util :as util]
            [markdown.core :as markdown]
            [selmer.parser :as selmer]
            [taoensso.timbre :as log]))

(defn md->html
  [system md]
  (markdown/md-to-html-string
   md
   :inhibit-separator (config/template-skip-marker system)))

(defn selmer->html
  [system data content]
  (selmer/render content (assoc data :system system)))

(defn md+selmer->html
  [system data content]
  (->> content
       (md->html system)
       (selmer->html system data)))

(defn selmer+md->html
  [system data content]
  (->> content
       (selmer->html system data)
       (md->html system)))

(defn convert-body!
  [system data content-type]
  (case content-type
    :md
      (update-in data [:body] (partial md->html system))
    :selmer
      (update-in data [:body] (partial selmer->html system data))
    [:md :selmer]
      (update-in data [:body] (partial md+selmer->html system data))
    [:selmer :md]
      (update-in data [:body] (partial selmer+md->html system data))))

(defn join-excerpt
  [system words number]
  (let [excerpt (string/join (config/word-joiner system)
                             (take number words))]
    (if (string/ends-with? excerpt (config/sentence-end system))
      (str excerpt (config/period-ellipsis system))
      (str excerpt (config/ellipsis system)))))

(defn copy-original-body
  [data]
  (assoc data :body-orig (:body data)))

{'fraction_non_alphanumeric': 0.14334051061211936, 'fraction_numerical': 0.0, 'mean_word_length': 2.666290868094701, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7365463', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1068, 'n_words': 282}