Skip to content

Commit 828c32f

Browse files
committed
fix(gfm-codeblocks): leading space no longer breaks gfm codeblocks
Now GFM Code Blocks can have up to 3 spaces before the backticks Closes #523
1 parent dfeb1e2 commit 828c32f

File tree

7 files changed

+40
-5
lines changed

7 files changed

+40
-5
lines changed

dist/showdown.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/subParsers/githubCodeBlocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ showdown.subParser('githubCodeBlocks', function (text, options, globals) {
2020

2121
text += '¨0';
2222

23-
text = text.replace(/(?:^|\n)(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n\1/g, function (wholeMatch, delim, language, codeblock) {
23+
text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) {
2424
var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
2525

2626
// First parse the github code block
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<pre><code class="javascript language-javascript">var test = test;
2+
function foo() {
3+
return 'bar';
4+
}
5+
</code></pre>
6+
<pre><code class="javascript language-javascript">var test = test;
7+
function foo() {
8+
return 'bar';
9+
}
10+
</code></pre>
11+
<pre><code class="javascript language-javascript">var test = test;
12+
function foo() {
13+
return 'bar';
14+
}
15+
</code></pre>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
```javascript
2+
var test = test;
3+
function foo() {
4+
return 'bar';
5+
}
6+
```
7+
8+
```javascript
9+
var test = test;
10+
function foo() {
11+
return 'bar';
12+
}
13+
```
14+
15+
```javascript
16+
var test = test;
17+
function foo() {
18+
return 'bar';
19+
}
20+
```

0 commit comments

Comments
 (0)