Răsfoiți Sursa

feat(ellipsis): add auto-ellipsis support

Three dots `...` are now converted automatically into an ellipsis
Estevao Soares dos Santos 7 ani în urmă
părinte
comite
25f1978666

+ 13 - 0
dist/showdown.js

@@ -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);

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/showdown.js.map


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/showdown.min.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
dist/showdown.min.js.map


+ 11 - 0
src/subParsers/ellipsis.js

@@ -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 - 0
src/subParsers/spanGamut.js

@@ -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 - 0
test/cases/ellipsis.html

@@ -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 - 0
test/cases/ellipsis.md

@@ -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...

+ 1 - 1
test/features/disableForced4SpacesIndentedSublists.html

@@ -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 - 1
test/features/disableForced4SpacesIndentedSublists.md

@@ -1,7 +1,7 @@
 * foo
   * bar
 
-...
+---
 
 * baz
   1. bazinga

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff