Skip to content

Commit

Permalink
fix(fenced codeblocks): add tilde as fenced code block delimiter
Browse files Browse the repository at this point in the history
Closes #456
  • Loading branch information
tivie committed Nov 11, 2017
1 parent 616a789 commit c956ede
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 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/githubCodeBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ showdown.subParser('githubCodeBlocks', function (text, options, globals) {

text += '¨0';

text = text.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g, function (wholeMatch, 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
6 changes: 6 additions & 0 deletions test/cases/github-style-codeblock.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@
<p>And some HTML</p>
<pre><code class="html language-html">&lt;div&gt;HTML!&lt;/div&gt;
</code></pre>
<p>Use more than 3 backticks</p>
<pre><code>some code
</code></pre>
<p>Use tilde as delimiter</p>
<pre><code>another piece of code
</code></pre>
12 changes: 12 additions & 0 deletions test/cases/github-style-codeblock.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ And some HTML
```html
<div>HTML!</div>
```

Use more than 3 backticks

`````
some code
`````

Use tilde as delimiter

~~~
another piece of code
~~~

0 comments on commit c956ede

Please sign in to comment.