summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAsko Nõmm <asko@bien.ee>2022-04-22 22:09:09 +0300
committerAsko Nõmm <asko@bien.ee>2022-04-22 22:09:09 +0300
commit2b530b7c4e53596ce17e24f3fab42ab2f3c52ba8 (patch)
tree8fae8a6f5def201b24c62c10e83df3b6ccb942fb /src
parentc3cbae915e1858c2e0b4c013205753fd6e1f548e (diff)
Implement tests for correctors
Diffstat (limited to 'src')
-rw-r--r--src/clarktown/correctors/code_block.clj24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/clarktown/correctors/code_block.clj b/src/clarktown/correctors/code_block.clj
index e767390..fcda19b 100644
--- a/src/clarktown/correctors/code_block.clj
+++ b/src/clarktown/correctors/code_block.clj
@@ -5,23 +5,23 @@
(defn empty-line-above?
[lines line index]
- (and (= (string/trim line) "```")
- (> index 0)
- (->> (take index lines)
- (filter #(= (string/trim %) "```"))
- count
- odd?)
- (not (= (-> (nth lines (- index 1))
- string/trim) ""))))
+ (let [occurences (->> (take index lines)
+ (filter #(string/starts-with? (string/trim %) "```"))
+ count)]
+ (and (string/starts-with? (string/trim line) "```")
+ (> index 0)
+ (even? occurences)
+ (not (= (-> (nth lines (- index 1))
+ string/trim) "")))))
(defn empty-line-below?
[lines line index]
- (and (= (string/trim line) "```")
+ (and (string/starts-with? (string/trim line) "```")
(< index (- (count lines) 1))
(->> (take index lines)
- (filter #(= (string/trim %) "```"))
+ (filter #(string/starts-with? (string/trim %) "```"))
count
- even?)
+ odd?)
(not (= (-> (nth lines (+ index 1))
- string/trim) "")))) \ No newline at end of file
+ string/trim) ""))))