diff options
| author | Asko Nõmm <ano@ano.ee> | 2022-04-30 12:09:32 +0300 |
|---|---|---|
| committer | Asko Nõmm <ano@ano.ee> | 2022-04-30 12:09:32 +0300 |
| commit | ee7ab7fd1163a1a8444e16017793eb32a0eb08ee (patch) | |
| tree | 287468b35b2815a7164225883669e070bde39b63 /src/clarktown/engine.clj | |
| parent | 258fda339e9a5bf3b2cfc2f8dea28c4c02b28073 (diff) | |
Close #22, Close #23
Diffstat (limited to 'src/clarktown/engine.clj')
| -rw-r--r-- | src/clarktown/engine.clj | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/clarktown/engine.clj b/src/clarktown/engine.clj index deca176..eaa0fb0 100644 --- a/src/clarktown/engine.clj +++ b/src/clarktown/engine.clj @@ -69,13 +69,20 @@ lines))) +(defn- remove-excess-newlines + "Replaces all occurences of 3 or more concecutive newlines into + two newlines." + [markdown] + (string/replace markdown #"\n{3,}" "\n\n")) + + (defn- correct-markdown "Corrects invalid Markdown for the parser." [markdown given-correctors] - (let [lines (string/split-lines markdown)] - (->> lines - (correct-block-separations (:block-separations given-correctors)) - (string/join \newline)))) + (->> (string/split-lines markdown) + (correct-block-separations (:block-separations given-correctors)) + (string/join \newline) + (remove-excess-newlines))) (defn- find-parser-by-block |
