Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tivie committed Sep 15, 2018
1 parent 26abc7a commit 6259f37
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/subParsers/makehtml/githubCodeBlocks.js
Expand Up @@ -20,7 +20,7 @@ showdown.subParser('makehtml.githubCodeBlocks', function (text, options, globals

text += '¨0';

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

// First parse the github code block
Expand Down
@@ -0,0 +1,15 @@
<pre><code class="javascript language-javascript">var test = test;
function foo() {
return 'bar';
}
</code></pre>
<pre><code class="javascript language-javascript">var test = test;
function foo() {
return 'bar';
}
</code></pre>
<pre><code class="javascript language-javascript">var test = test;
function foo() {
return 'bar';
}
</code></pre>
@@ -0,0 +1,20 @@
```javascript
var test = test;
function foo() {
return 'bar';
}
```

```javascript
var test = test;
function foo() {
return 'bar';
}
```

```javascript
var test = test;
function foo() {
return 'bar';
}
```

0 comments on commit 6259f37

Please sign in to comment.