diff options
| author | Asko Nõmm <ano@ano.ee> | 2022-04-30 13:11:13 +0300 |
|---|---|---|
| committer | Asko Nõmm <ano@ano.ee> | 2022-04-30 13:11:13 +0300 |
| commit | 2e548f1bc696db90d11024600d5ccce73131135f (patch) | |
| tree | 08fe69fe0a4de92ac65a81612ee21dfb60834977 | |
| parent | ee7ab7fd1163a1a8444e16017793eb32a0eb08ee (diff) | |
Allow an ATX heading block to precede with up to 3 spaces
| -rw-r--r-- | src/clarktown/matchers/heading_block.clj | 2 | ||||
| -rw-r--r-- | test/clarktown/renderers/heading_block_test.clj | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/clarktown/matchers/heading_block.clj b/src/clarktown/matchers/heading_block.clj index 1a9a451..7cf931d 100644 --- a/src/clarktown/matchers/heading_block.clj +++ b/src/clarktown/matchers/heading_block.clj @@ -6,7 +6,7 @@ (defn is-atx-heading? "Determines whether the given block is a atx heading." [block] - (re-matches #"^\#{1,6}\s.*" block)) + (re-matches #"^\s{0,3}?\#{1,6}\s.*" block)) (defn is-settext-heading? diff --git a/test/clarktown/renderers/heading_block_test.clj b/test/clarktown/renderers/heading_block_test.clj index 7647b53..8f229fb 100644 --- a/test/clarktown/renderers/heading_block_test.clj +++ b/test/clarktown/renderers/heading_block_test.clj @@ -35,7 +35,20 @@ (testing "No H tag when there is no space between # characters and value" (is (= "#This is not a heading block." - (heading-block/render "#This is not a heading block." nil nil))))) + (heading-block/render "#This is not a heading block." nil nil)))) + + (testing "ATX heading can precede up to 3 spaces" + (is (= "<h1>This is a heading.</h1>" + (heading-block/render " # This is a heading." nil nil))) + (is (= "<h1>This is a heading.</h1>" + (heading-block/render " # This is a heading." nil nil))) + (is (= "<h1>This is a heading.</h1>" + (heading-block/render " # This is a heading." nil nil)))) + + (testing "But no more than 3 spaces" + (is (= " # This is a heading." + (heading-block/render " # This is a heading." nil nil))))) + (deftest settext-heading-renderer-text |
