Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(github-style-codeblock): add support for spaces before language #569

Merged
merged 1 commit into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
126 changes: 63 additions & 63 deletions dist/showdown.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/subParsers/makehtml/githubCodeBlocks.js
Original file line number Diff line number Diff line change
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)(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n\1/g, function (wholeMatch, delim, language, codeblock) {
var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';

// First parse the github code block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<p>And some HTML</p>
<pre><code class="html language-html">&lt;div&gt;HTML!&lt;/div&gt;
</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>
<pre><code>some code
</code></pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ And some HTML
<div>HTML!</div>
```

And some CSS with spaces before the language declaration

``` css
body {
font-size: 1.5em;
}
```

Use more than 3 backticks

`````
Expand Down