summaryrefslogtreecommitdiff
path: root/src/clarktown/correctors/atx_heading_block.clj
diff options
context:
space:
mode:
authorAsko Nõmm <84135165+askonomm@users.noreply.github.com>2022-04-30 12:12:28 +0300
committerGitHub <noreply@github.com>2022-04-30 12:12:28 +0300
commitfaf11bf88b598d55f81899784c7c16e32a8d415d (patch)
tree287468b35b2815a7164225883669e070bde39b63 /src/clarktown/correctors/atx_heading_block.clj
parentd6e39c016e16b60b85b60898e93eda8d2c6f00db (diff)
parentee7ab7fd1163a1a8444e16017793eb32a0eb08ee (diff)
Merge pull request #25 from askonomm/issue-22
Improve ATX heading blocks
Diffstat (limited to 'src/clarktown/correctors/atx_heading_block.clj')
-rw-r--r--src/clarktown/correctors/atx_heading_block.clj11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/clarktown/correctors/atx_heading_block.clj b/src/clarktown/correctors/atx_heading_block.clj
index 361b9b9..a2a948b 100644
--- a/src/clarktown/correctors/atx_heading_block.clj
+++ b/src/clarktown/correctors/atx_heading_block.clj
@@ -1,6 +1,7 @@
(ns clarktown.correctors.atx-heading-block
(:require
- [clojure.string :as string]))
+ [clojure.string :as string]
+ [clarktown.matchers.heading-block :refer [is-atx-heading?]]))
(defn- in-code-block?
@@ -19,12 +20,12 @@
there's no empty newline above, we need to create one, and
so this function must then return `true`."
[lines line index]
- (and (string/starts-with? (string/trim line) "#")
+ (and (is-atx-heading? (string/trim line))
(> index 0)
(not (= (-> (nth lines (- index 1))
string/trim) ""))
- (not (in-code-block? lines index))))
-
+ (not (in-code-block? lines index))))
+
(defn empty-line-below?
"Determines whether there's a need for an empty new line
@@ -33,7 +34,7 @@
there's no empty newline below, we need to create one, and
so this function must then return `true`."
[lines line index]
- (and (string/starts-with? (string/trim line) "#")
+ (and (is-atx-heading? line)
(< index (- (count lines) 1))
(not (= (-> (nth lines (+ index 1))
string/trim) ""))