Skip to content

Commit

Permalink
feat(ellipsis): add auto-ellipsis support
Browse files Browse the repository at this point in the history
Three dots `...` are now converted automatically into an ellipsis
  • Loading branch information
tivie committed Oct 24, 2017
1 parent 084b819 commit 25f1978
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 5 deletions.
13 changes: 13 additions & 0 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.

11 changes: 11 additions & 0 deletions src/subParsers/ellipsis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
showdown.subParser('ellipsis', function (text, options, globals) {
'use strict';

text = globals.converter._dispatch('ellipsis.before', text, options, globals);

text = text.replace(/\.\.\./g, '…');

text = globals.converter._dispatch('ellipsis.after', text, options, globals);

return text;
});
1 change: 1 addition & 0 deletions src/subParsers/spanGamut.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ showdown.subParser('spanGamut', function (text, options, globals) {
text = showdown.subParser('underline')(text, options, globals);
text = showdown.subParser('italicsAndBold')(text, options, globals);
text = showdown.subParser('strikethrough')(text, options, globals);
text = showdown.subParser('ellipsis')(text, options, globals);

// we need to hash HTML tags inside spans
text = showdown.subParser('hashHTMLSpans')(text, options, globals);
Expand Down
19 changes: 19 additions & 0 deletions test/cases/ellipsis.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<p>ellipsis in text…</p>
<p></p>
<ol>
<li>foo…</li>
<li>bar</li>
</ol>
<blockquote>
<p>ellipsis in blockquote…</p>
</blockquote>
<pre><code>ellipsis in code...
</code></pre>
<pre><code>ellipsis in code...
</code></pre>
<h1 id="ellipsisinheader">ellipsis in header…</h1>
<p>1…</p>
<ol>
<li>..</li>
</ol>
<p>1…</p>
22 changes: 22 additions & 0 deletions test/cases/ellipsis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ellipsis in text...

...

1. foo...
2. bar

> ellipsis in blockquote...
```
ellipsis in code...
```

ellipsis in code...

# ellipsis in header...

1...

1. ..

1...
2 changes: 1 addition & 1 deletion test/features/disableForced4SpacesIndentedSublists.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<li>foo<ul>
<li>bar</li></ul></li>
</ul>
<p>...</p>
<hr />
<ul>
<li>baz<ol>
<li>bazinga</li></ol></li>
Expand Down
2 changes: 1 addition & 1 deletion test/features/disableForced4SpacesIndentedSublists.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
* foo
* bar

...
---

* baz
1. bazinga

0 comments on commit 25f1978

Please sign in to comment.