diff options
| author | Asko Nõmm <84135165+askonomm@users.noreply.github.com> | 2022-04-15 19:57:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-15 19:57:49 +0200 |
| commit | 361712bea3c7130fa3526063a51f9dc0d1130c56 (patch) | |
| tree | 70b08a04aa7261c64ccb4f21f1b4bc34d86b1a2a /src/clarktown/parsers | |
| parent | 58970486f0c0fdb9470ef28e510f5c90060e2ced (diff) | |
| parent | ce96dd264fd2385303f48259e5e8d1431d22b91d (diff) | |
Merge pull request #15 from askonomm/fix-issue-14-and-issue-13
Implement Markdown correction mechanism
Diffstat (limited to 'src/clarktown/parsers')
| -rw-r--r-- | src/clarktown/parsers/code_block.clj | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/clarktown/parsers/code_block.clj b/src/clarktown/parsers/code_block.clj index 388776f..c6ecfea 100644 --- a/src/clarktown/parsers/code_block.clj +++ b/src/clarktown/parsers/code_block.clj @@ -16,13 +16,15 @@ (let [language (->> block (re-find #"\`\`\`(\w+)") second) - code (as-> block n - (string/replace-first n #"\`\`\`(\w+)?\n" "") - (subs n 0 (- (count n) 4)) - (string/replace n #"&" "&") - (string/replace n #"<" "<") - (string/replace n #">" ">") - (string/trim n))] + lines (string/split-lines block) + block* (->> (next lines) + (take (- (count lines) 2)) + (string/join \newline)) + code (-> block* + (string/replace #"&" "&") + (string/replace #"<" "<") + (string/replace #">" ">") + string/trim)] (if language (str "<pre><code class=\"language-" language "\">" code "</code></pre>") (str "<pre><code>" code "</code></pre>")))) |
