<commit_before>(ns figwheel-sidecar.config-check.ansi
  (:require [clojure.string :as str]))

;; this is stolen from puget as up to date ansi lib is not really available
;; https://github.com/greglook/puget/blob/develop/src/puget/color/ansi.clj

(def sgr-code
  "Map of symbols to numeric SGR (select graphic rendition) codes."
  {:none        0
   :bold        1
   :underline   3
   :blink       5
   :reverse     7
   :hidden      8
   :strike      9
   :black      30
   :red        31
   :green      32
   :yellow     33
   :blue       34
   :magenta    35
   :cyan       36
   :white      37
   :fg-256     38
   :fg-reset   39
   :bg-black   40
   :bg-red     41
   :bg-green   42
   :bg-yellow  43
   :bg-blue    44
   :bg-magenta 45
   :bg-cyan    46
   :bg-white   47
   :bg-256     48
   :bg-reset   49})

(defn esc
  "Returns an ANSI escope string which will apply the given collection of SGR
  codes."
  [codes]
  (let [codes (map sgr-code codes codes)
        codes (str/join \; codes)]
    (str \u001b \[ codes \m)))

(defn escape
  "Returns an ANSI escope string which will enact the given SGR codes."
  [& codes]
  (esc codes))

(defn sgr
  "Wraps the given string with SGR escapes to apply the given codes, then reset
  the graphics."
  [string & codes]
  (str (esc codes) string (escape :none)))

(defn strip
  "Removes color codes from the given string."
  [string]
  (str/replace string #"\u001b\[[0-9;]*[mK]" ""))

(def ^:dynamic *enable-color* true)

(defmacro without-color [& body]
  `(binding [*enable-color* false]
     ~@body))

(defn color [text & codes]
  (if *enable-color*
    [:span [:pass (esc codes)] text [:pass (escape :none)]]
    text))
<commit_msg>add color to normal text<commit_after>(ns figwheel-sidecar.config-check.ansi
  (:require [clojure.string :as str]))

;; this is stolen from puget as up to date ansi lib is not really available
;; https://github.com/greglook/puget/blob/develop/src/puget/color/ansi.clj

(def sgr-code
  "Map of symbols to numeric SGR (select graphic rendition) codes."
  {:none        0
   :bold        1
   :underline   3
   :blink       5
   :reverse     7
   :hidden      8
   :strike      9
   :black      30
   :red        31
   :green      32
   :yellow     33
   :blue       34
   :magenta    35
   :cyan       36
   :white      37
   :fg-256     38
   :fg-reset   39
   :bg-black   40
   :bg-red     41
   :bg-green   42
   :bg-yellow  43
   :bg-blue    44
   :bg-magenta 45
   :bg-cyan    46
   :bg-white   47
   :bg-256     48
   :bg-reset   49})

(def ^:dynamic *enable-color* true)

(defn esc
  "Returns an ANSI escope string which will apply the given collection of SGR
  codes."
  [codes]
  (let [codes (map sgr-code codes codes)
        codes (str/join \; codes)]
    (str \u001b \[ codes \m)))

(defn escape
  "Returns an ANSI escope string which will enact the given SGR codes."
  [& codes]
  (esc codes))

(defn sgr
  "Wraps the given string with SGR escapes to apply the given codes, then reset
  the graphics."
  [string & codes]
  (str (esc codes) string (escape :none)))

(defn color-text [text & args]
  (if *enable-color*
    (apply sgr text args)
    text))

(defn strip
  "Removes color codes from the given string."
  [string]
  (str/replace string #"\u001b\[[0-9;]*[mK]" ""))

(defmacro without-color [& body]
  `(binding [*enable-color* false]
     ~@body))

(defn color [text & codes]
  (if *enable-color*
    [:span [:pass (esc codes)] text [:pass (escape :none)]]
    text))

{'fraction_non_alphanumeric': 0.12165660051768766, 'fraction_numerical': 0.03508771929824561, 'mean_word_length': 2.287334593572779, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5136117', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1251, 'n_words': 415}