Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tivie committed Jul 22, 2015
2 parents f3d74fe + 7d0a181 commit eeccee7
Show file tree
Hide file tree
Showing 17 changed files with 309 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports = function (grunt) {
options: {
globals: ['should'],
timeout: 3000,
ignoreLeaks: false,
ignoreLeaks: true,
reporter: 'spec'
}
},
Expand Down
31 changes: 20 additions & 11 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.

2 changes: 1 addition & 1 deletion 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.

26 changes: 17 additions & 9 deletions src/subParsers/codeSpans.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
showdown.subParser('codeSpans', function (text) {
'use strict';

//special case -> literal html code tag
text = text.replace(/(<code[^><]*?>)([^]*?)<\/code>/g, function (wholeMatch, tag, c) {
c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
c = showdown.subParser('encodeCode')(c);
return tag + c + '</code>';
});

/*
text = text.replace(/
(^|[^\\]) // Character before opening ` can't be a backslash
Expand All @@ -38,15 +46,15 @@ showdown.subParser('codeSpans', function (text) {
(?!`)
/gm, function(){...});
*/

text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function (wholeMatch, m1, m2, m3) {
var c = m3;
c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
c = showdown.subParser('encodeCode')(c);
return m1 + '<code>' + c + '</code>';
});
text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
function (wholeMatch, m1, m2, m3) {
var c = m3;
c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
c = showdown.subParser('encodeCode')(c);
return m1 + '<code>' + c + '</code>';
}
);

return text;

});
1 change: 1 addition & 0 deletions src/subParsers/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ showdown.subParser('images', function (text, options, globals) {
}

altText = altText.replace(/"/g, '&quot;');
altText = showdown.helper.escapeCharacters(altText, '*_', false);
url = showdown.helper.escapeCharacters(url, '*_', false);
var result = '<img src="' + url + '" alt="' + altText + '"';

Expand Down
4 changes: 2 additions & 2 deletions src/subParsers/italicsAndBold.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ showdown.subParser('italicsAndBold', function (text, options) {
if (options.literalMidWordUnderscores) {
//underscores
// Since we are consuming a \s character, we need to add it
text = text.replace(/(^|\s)__(?=\S)([^]+?)__(?=\s|$)/gm, '$1<strong>$2</strong>');
text = text.replace(/(^|\s)_(?=\S)([^]+?)_(?=\s|$)/gm, '$1<em>$2</em>');
text = text.replace(/(^|\s|>|\b)__(?=\S)([^]+?)__(?=\b|<|\s|$)/gm, '$1<strong>$2</strong>');
text = text.replace(/(^|\s|>|\b)_(?=\S)([^]+?)_(?=\b|<|\s|$)/gm, '$1<em>$2</em>');
//asterisks
text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '<strong>$1</strong>');
text = text.replace(/\*(?=\S)([^]+?)\*/g, '<em>$1</em>');
Expand Down
4 changes: 2 additions & 2 deletions test/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
testCase.actual = beautify(testCase.actual, beauOptions);

// Normalize line returns
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, os.EOL);
testCase.actual = testCase.actual.replace(/(\r\n)|\n|\r/g, os.EOL);
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, '\n');
testCase.actual = testCase.actual.replace(/(\r\n)|\n|\r/g, '\n');

return testCase;
}
Expand Down
1 change: 1 addition & 0 deletions test/features/autolink_and_disallow_underscores.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p><a href="http://en.wikipedia.org/wiki/Tourism_in_Germany">http://en.wikipedia.org/wiki/Tourism_in_Germany</a></p>
1 change: 1 addition & 0 deletions test/features/autolink_and_disallow_underscores.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://en.wikipedia.org/wiki/Tourism_in_Germany
40 changes: 40 additions & 0 deletions test/ghost/markdown-magic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<h3 id="automaticlinks">Automatic Links</h3>

<pre><code>https://ghost.org
</code></pre>

<p><a href="https://ghost.org">https://ghost.org</a></p>

<h3 id="markdownfootnotes">Markdown Footnotes</h3>

<pre><code>The quick brown fox[^1] jumped over the lazy dog[^2].

[^1]: Foxes are red
[^2]: Dogs are usually not red
</code></pre>

<p>The quick brown fox[^1] jumped over the lazy dog[^2].</p>

<h3 id="syntaxhighlighting">Syntax Highlighting</h3>

<pre><code>```language-javascript
[...]
```
</code></pre>

<p>Combined with <a href="http://prismjs.com/">Prism.js</a> in the Ghost theme:</p>

<pre><code class="language-javascript language-language-javascript">// # Notifications API
// RESTful API for creating notifications
var Promise = require('bluebird'),
_ = require('lodash'),
canThis = require('../permissions').canThis,
errors = require('../errors'),
utils = require('./utils'),

// Holds the persistent notifications
notificationsStore = [],
// Holds the last used id
notificationCounter = 0,
notifications;
</code></pre>
43 changes: 43 additions & 0 deletions test/ghost/markdown-magic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
### Automatic Links

```
https://ghost.org
```

https://ghost.org

### Markdown Footnotes

```
The quick brown fox[^1] jumped over the lazy dog[^2].
[^1]: Foxes are red
[^2]: Dogs are usually not red
```

The quick brown fox[^1] jumped over the lazy dog[^2].


### Syntax Highlighting

```language-javascript
[...]
```

Combined with [Prism.js](http://prismjs.com/) in the Ghost theme:

```language-javascript
// # Notifications API
// RESTful API for creating notifications
var Promise = require('bluebird'),
_ = require('lodash'),
canThis = require('../permissions').canThis,
errors = require('../errors'),
utils = require('./utils'),
// Holds the persistent notifications
notificationsStore = [],
// Holds the last used id
notificationCounter = 0,
notifications;
```
78 changes: 78 additions & 0 deletions test/ghost/underscore.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<p>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</p>

<p><em>baz_bar_foo</em></p>

<p><strong>baz_bar_foo</strong></p>

<p><strong><em>baz_bar_foo</em></strong></p>

<p>baz bar foo <em>baz_bar_foo foo bar baz</em> and foo</p>

<p>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</p>

<p><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></p>

<pre><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
</code></pre>

<pre><code class="html language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
</code></pre>

<pre>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</pre>

<pre><code class="language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></pre>

<pre class="lang-html"><code class="language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></pre>

<script>
var strike = "foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo";
var foo_bar_baz_bar_foo = "foo_bar_";
</script>

<p><a href="http://myurl.com/foo_bar_baz_bar_foo">foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</a></p>

<p><a href="http://myurl.com/foo_bar_baz_bar_foo" title="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo">foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</a></p>

<p><img src="http://myurl.com/foo_bar_baz_bar_foo" alt="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo"></p>

<h2 id="foo_bar_bazfoo_bar_baz_bar_foo_foo_barbaz_bar_baz_foo">foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</h2>

<h3 id="foo_bar_bazfoo_bar_baz_bar_foo_foo_barbaz_bar_baz_foo-1">foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</h3>

<ol>
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
</ol>

<blockquote>
<p>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</p>
</blockquote>

<ul>
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
</ul>

<hr />

<p><a href="http://en.wikipedia.org/wiki/Tourism_in_Germany">http://en.wikipedia.org/wiki/Tourism_in_Germany</a></p>

<p><a href="http://en.wikipedia.org/wiki/Tourism_in_Germany">an example</a></p>

<p>Another <a href="http://en.wikipedia.org/wiki/Tourism_in_Germany">example</a> of a link</p>

<p><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></p>

<!-- These two cases still have bad <ems> because showdown handles them incorrectly -->

<p><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></p>

<p><img src="http://myurl.com/foo_bar_baz_bar_foo" alt="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo"/></p>

<p><a href="http://myurl.com/foo_bar_baz_bar_foo">http://myurl.com/foo_bar_baz_bar_foo</a></p>

<p><a href="http://myurl.com/foo_bar_baz_bar_foo">http://myurl.com/foo_bar_baz_bar_foo</a></p>

<p><em>italics</em>.</p>

<p><em>italics</em> .</p>
76 changes: 76 additions & 0 deletions test/ghost/underscore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo

_baz_bar_foo_

__baz_bar_foo__

___baz_bar_foo___

baz bar foo _baz_bar_foo foo bar baz_ and foo

foo\_bar\_baz foo\_bar\_baz\_bar\_foo \_foo\_bar baz\_bar\_ baz\_foo

`foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo`


foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo


```html
foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
```

<pre>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</pre>

<pre><code class="language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></pre>

<pre class="lang-html"><code class="language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></pre>

<script>
var strike = "foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo";
var foo_bar_baz_bar_foo = "foo_bar_";
</script>

[foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo](http://myurl.com/foo_bar_baz_bar_foo)

<a href="http://myurl.com/foo_bar_baz_bar_foo" title="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</a>

<img src="http://myurl.com/foo_bar_baz_bar_foo" alt="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo">

foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
-----

### foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo

1. foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
2. foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo

> foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
* foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
* foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo

-------

http://en.wikipedia.org/wiki/Tourism_in_Germany

[an example] [wiki]

Another [example][wiki] of a link

[wiki]: http://en.wikipedia.org/wiki/Tourism_in_Germany

<p><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></p>

<!-- These two cases still have bad <ems> because showdown handles them incorrectly -->
<code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code>

![foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo](http://myurl.com/foo_bar_baz_bar_foo)

http://myurl.com/foo_bar_baz_bar_foo

<http://myurl.com/foo_bar_baz_bar_foo>

_italics_.

_italics_ .
2 changes: 2 additions & 0 deletions test/node/testsuite.features.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ describe('makeHtml() features testsuite', function () {
converter = new showdown.Converter({ghCodeBlocks: false});
} else if (testsuite[i].name === '#164.4.tasklists') {
converter = new showdown.Converter({tasklists: true});
} else if (testsuite[i].name === 'autolink_and_disallow_underscores') {
converter = new showdown.Converter({literalMidWordUnderscores: true, simplifiedAutoLink: true});
} else {
converter = new showdown.Converter();
}
Expand Down
Loading

0 comments on commit eeccee7

Please sign in to comment.