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
pull/587/head
Estevao Soares dos Santos 2018-09-15 14:58:50 +01:00
parent 26abc7a795
commit 6259f37bd6
3 changed files with 36 additions and 1 deletions

View File

@ -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

View File

@ -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>

View File

@ -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';
}
```