summaryrefslogtreecommitdiff
path: root/src/clarktown/correctors/atx_heading_block.clj
blob: a7925729505d05867a715bd76acc50e05d72c121 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(ns clarktown.correctors.atx-heading-block
  (:require
    [clojure.string :as string]))


(defn empty-line-above?
  [lines line index]
  (and (string/starts-with? (string/trim line) "#")
       (> index 0)
       (not (= (-> (nth lines (- index 1))
                   string/trim) ""))))


(defn empty-line-below?
  [lines line index]
  (and (string/starts-with? (string/trim line) "#")
       (< index (- (count lines) 1))
       (not (= (-> (nth lines (+ index 1))
                   string/trim) ""))))