diff options
| author | Asko Nõmm <84135165+askonomm@users.noreply.github.com> | 2022-04-30 12:12:28 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-30 12:12:28 +0300 |
| commit | faf11bf88b598d55f81899784c7c16e32a8d415d (patch) | |
| tree | 287468b35b2815a7164225883669e070bde39b63 /src/clarktown/engine.clj | |
| parent | d6e39c016e16b60b85b60898e93eda8d2c6f00db (diff) | |
| parent | ee7ab7fd1163a1a8444e16017793eb32a0eb08ee (diff) | |
Merge pull request #25 from askonomm/issue-22
Improve ATX heading blocks
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 |
