From b2a293e42c0e9d5e8522a2c1a1218dbc39741950 Mon Sep 17 00:00:00 2001 From: ryneeverett Date: Wed, 30 Dec 2015 11:33:31 -0500 Subject: [PATCH] Support >3 backticks in github-flavored fences. --- mkcodes.py | 2 +- tests/data/some.md | 6 ++++++ tests/test.py | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mkcodes.py b/mkcodes.py index eb237af..51388aa 100644 --- a/mkcodes.py +++ b/mkcodes.py @@ -29,7 +29,7 @@ def default_state(): def github_codeblocks(filename, safe): codeblocks = [] codeblock_re = r'^```.*' - codeblock_open_re = r'^```(py|python){0}$'.format('' if safe else '?') + codeblock_open_re = r'^```(`*)(py|python){0}$'.format('' if safe else '?') with open(filename, 'r') as f: block = [] diff --git a/tests/data/some.md b/tests/data/some.md index 17e7417..890ad9d 100644 --- a/tests/data/some.md +++ b/tests/data/some.md @@ -13,3 +13,9 @@ bar = False Some daring-fireball-flavored code: baz = None + +More than 3 backticks is allowed: + +`````py +backticks = range(5, 7) +``````` diff --git a/tests/test.py b/tests/test.py index df22095..07f1e34 100644 --- a/tests/test.py +++ b/tests/test.py @@ -39,6 +39,9 @@ def test_github_safe(self): self.call('--github', '--safe') self.assertOutput("""\ bar = False + + + backticks = range(5, 7) """) def test_markdown_unsafe(self): @@ -54,6 +57,9 @@ def test_github_unsafe(self): bar = False + + + backticks = range(5, 7) """) @@ -77,6 +83,9 @@ def test_multiple(self): 'tests/data/some.md', 'tests/data/other.md']) self.assertFileEqual('tests/some.py', """\ bar = False + + + backticks = range(5, 7) """) self.assertFileEqual('tests/other.py', """\ qux = 4