mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(gfm-codeblock): add support for spaces before language declaration
One or more spaces before the language declaration of a code block is supported by Github. E.g. ``` html <div>HTML!</div> ``` ``` html <div>HTML!</div> ``` ```html <div>HTML!</div> ``` Closes #569
This commit is contained in:
parent
e80a548c9b
commit
1f0242c6ea
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,7 +20,7 @@ showdown.subParser('makehtml.githubCodeBlocks', function (text, options, globals
|
||||||
|
|
||||||
text += '¨0';
|
text += '¨0';
|
||||||
|
|
||||||
text = text.replace(/(?:^|\n)(```+|~~~+)([^\s`~]*)\n([\s\S]*?)\n\1/g, function (wholeMatch, delim, language, codeblock) {
|
text = text.replace(/(?:^|\n)(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n\1/g, function (wholeMatch, delim, language, codeblock) {
|
||||||
var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
|
var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
|
||||||
|
|
||||||
// First parse the github code block
|
// First parse the github code block
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
<p>And some HTML</p>
|
<p>And some HTML</p>
|
||||||
<pre><code class="html language-html"><div>HTML!</div>
|
<pre><code class="html language-html"><div>HTML!</div>
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
<p>And some CSS with spaces before the language declaration</p>
|
||||||
|
<pre><code class="css language-css">body {
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
</code></pre>
|
||||||
<p>Use more than 3 backticks</p>
|
<p>Use more than 3 backticks</p>
|
||||||
<pre><code>some code
|
<pre><code>some code
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
|
@ -13,6 +13,14 @@ And some HTML
|
||||||
<div>HTML!</div>
|
<div>HTML!</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
And some CSS with spaces before the language declaration
|
||||||
|
|
||||||
|
``` css
|
||||||
|
body {
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Use more than 3 backticks
|
Use more than 3 backticks
|
||||||
|
|
||||||
`````
|
`````
|
||||||
|
|
Loading…
Reference in New Issue
Block a user