mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
feat(ellipsis): add auto-ellipsis support
Three dots `...` are now converted automatically into an ellipsis
This commit is contained in:
parent
084b819b14
commit
25f1978666
13
dist/showdown.js
vendored
13
dist/showdown.js
vendored
@ -2918,6 +2918,18 @@ showdown.subParser('detab', function (text, options, globals) {
|
||||
return text;
|
||||
});
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
/**
|
||||
* These are all the transformations that occur *within* block-level
|
||||
* tags like paragraphs, headers, and list items.
|
||||
@ -3979,6 +3991,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);
|
||||
|
2
dist/showdown.js.map
vendored
2
dist/showdown.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/showdown.min.js
vendored
2
dist/showdown.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/showdown.min.js.map
vendored
2
dist/showdown.min.js.map
vendored
File diff suppressed because one or more lines are too long
11
src/subParsers/ellipsis.js
Normal file
11
src/subParsers/ellipsis.js
Normal file
@ -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;
|
||||
});
|
@ -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);
|
||||
|
19
test/cases/ellipsis.html
Normal file
19
test/cases/ellipsis.html
Normal file
@ -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
test/cases/ellipsis.md
Normal file
22
test/cases/ellipsis.md
Normal file
@ -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,7 +2,7 @@
|
||||
<li>foo<ul>
|
||||
<li>bar</li></ul></li>
|
||||
</ul>
|
||||
<p>...</p>
|
||||
<hr />
|
||||
<ul>
|
||||
<li>baz<ol>
|
||||
<li>bazinga</li></ol></li>
|
||||
|
@ -1,7 +1,7 @@
|
||||
* foo
|
||||
* bar
|
||||
|
||||
...
|
||||
---
|
||||
|
||||
* baz
|
||||
1. bazinga
|
||||
|
Loading…
x
Reference in New Issue
Block a user