From 2b530b7c4e53596ce17e24f3fab42ab2f3c52ba8 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Fri, 22 Apr 2022 22:09:09 +0300 Subject: Implement tests for correctors --- src/clarktown/correctors/code_block.clj | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/clarktown') 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) "")))) -- cgit v1.2.3