mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(gfmCodeBlocks): allow the info string in gfmCodeBlocks to contain spaces
The line with the opening code fence may optionally contain some text following the code fence (the info string); this is trimmed of leading and trailing whitespace and can contain multiple words (but not newlines). Closes #856
This commit is contained in:
parent
5a84b1cdf0
commit
67114255ad
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -20,9 +20,13 @@ showdown.subParser('makehtml.githubCodeBlocks', function (text, options, globals
|
|||
|
||||
text += '¨0';
|
||||
|
||||
text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) {
|
||||
text = text.replace(/(?:^|\n) {0,3}(```+|~~~+) *([^\n\t`~]*)\n([\s\S]*?)\n {0,3}\1/g, function (wholeMatch, delim, language, codeblock) {
|
||||
var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
|
||||
|
||||
// if the language has spaces followed by some other chars, according to the spec we should just ignore everything
|
||||
// after the first space
|
||||
language = language.trim().split(' ')[0];
|
||||
|
||||
// First parse the github code block
|
||||
codeblock = showdown.subParser('makehtml.encodeCode')(codeblock, options, globals);
|
||||
codeblock = showdown.subParser('makehtml.detab')(codeblock, options, globals);
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<pre><code class="json language-json">{
|
||||
"custom": true
|
||||
}
|
||||
</code></pre>
|
||||
<pre><code class="json language-json">{
|
||||
"custom": false
|
||||
}
|
||||
</code></pre>
|
|
@ -0,0 +1,11 @@
|
|||
```json custom data
|
||||
{
|
||||
"custom": true
|
||||
}
|
||||
```
|
||||
|
||||
```json custom data
|
||||
{
|
||||
"custom": false
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user