diff options
| author | Asko Nõmm <asko@bien.ee> | 2021-12-02 01:48:41 -0300 |
|---|---|---|
| committer | Asko Nõmm <asko@bien.ee> | 2021-12-02 01:48:41 -0300 |
| commit | 790dec05b269d13dbdf73fa645fc67e2d5f286f9 (patch) | |
| tree | b1dd2d3c4fc167f2db5b4f9aa86bb248586f8bc1 /src/clarktown/parsers/bold.clj | |
| parent | 91582aef1718f662e6fbe3e2dc17111fbb0ae9d8 (diff) | |
Add bold parser
Diffstat (limited to 'src/clarktown/parsers/bold.clj')
| -rw-r--r-- | src/clarktown/parsers/bold.clj | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/clarktown/parsers/bold.clj b/src/clarktown/parsers/bold.clj new file mode 100644 index 0000000..5840a6e --- /dev/null +++ b/src/clarktown/parsers/bold.clj @@ -0,0 +1,18 @@ +(ns clarktown.parsers.bold + (:require + [clojure.string :as string])) + + +(defn render + "Renders all occuring bold text as bold." + [block] + (loop [block block + matches (-> (re-seq #"\*\*.*?\*\*" block) + distinct)] + (if (empty? matches) + block + (let [match (first matches) + value (subs match 2 (- (count match) 2)) + replacement (str "<strong>" value "</strong>")] + (recur (string/replace block match replacement) + (drop 1 matches)))))) |
