Skip to content

Commit

Permalink
Support >3 backticks in github-flavored fences.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryneeverett committed Dec 30, 2015
1 parent ea51600 commit b2a293e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mkcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
6 changes: 6 additions & 0 deletions tests/data/some.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ bar = False
Some daring-fireball-flavored code:

baz = None

More than 3 backticks is allowed:

`````py
backticks = range(5, 7)
```````
9 changes: 9 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -54,6 +57,9 @@ def test_github_unsafe(self):
bar = False
backticks = range(5, 7)
""")


Expand All @@ -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
Expand Down

0 comments on commit b2a293e

Please sign in to comment.