Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5da4d0b

Browse files
committed
Merge pull request trentm#145 from trentm/nick-fenced-indentation
Don't parse code block inside another code block
2 parents a12f79a + f2c4b4f commit 5da4d0b

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

lib/markdown2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,9 @@ def _do_code_blocks(self, text):
15641564
)+
15651565
)
15661566
((?=^[ ]{0,%d}\S)|\Z) # Lookahead for non-space at line-start, or end of doc
1567+
# Lookahead to make sure this block isn't already in a code block.
1568+
# Needed when syntax highlighting is being used.
1569+
(?![^<]*\</code\>)
15671570
''' % (self.tab_width, self.tab_width),
15681571
re.M | re.X)
15691572
return code_block_re.sub(self._code_block_sub, text)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="codehilite"><pre><code><span class="k">def</span> <span class="nf">foo</span><span class="p">():</span>
2+
<span class="k">print</span> <span class="s">&quot;foo&quot;</span>
3+
4+
<span class="k">print</span> <span class="s">&quot;bar&quot;</span>
5+
</code></pre></div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"extras": ["fenced-code-blocks"]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extra fenced-code-blocks pygments indentation
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```python
2+
def foo():
3+
print "foo"
4+
5+
print "bar"
6+
```

0 commit comments

Comments
 (0)