diff options
Diffstat (limited to 'src/clarktown/correctors/code_block.clj')
| -rw-r--r-- | src/clarktown/correctors/code_block.clj | 24 |
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) "")))) |
