diff --git a/README.md b/README.md index 44ba6b4..0ef4c19 100644 --- a/README.md +++ b/README.md @@ -353,6 +353,8 @@ var defaultOptions = showdown.getDefaultOptions(); * **underline**: (boolean) [default false] ***EXPERIMENTAL FEATURE*** Enable support for underline. Syntax is **double** or **triple** **underscores** ex: `__underlined word__`. With this option enabled, underscores are no longer parses into `` and ``. + * **ellipsis**: (boolean) [default true] Replaces three dots with the ellipsis unicode character. + * **completeHTMLDocument**: (boolean) [default false] Outputs a complete html document, including ``, `` and `` tags' instead of an HTML fragment. (since v.1.8.5) diff --git a/dist/showdown.js b/dist/showdown.js index 36c74cd..aa9299b 100644 Binary files a/dist/showdown.js and b/dist/showdown.js differ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 00aa3de..8395f88 100644 Binary files a/dist/showdown.js.map and b/dist/showdown.js.map differ diff --git a/dist/showdown.min.js b/dist/showdown.min.js index a298817..2051edf 100644 Binary files a/dist/showdown.min.js and b/dist/showdown.min.js differ diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index 4889b77..173bc46 100644 Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ diff --git a/src/options.js b/src/options.js index 789e6a7..3504fe6 100644 --- a/src/options.js +++ b/src/options.js @@ -146,6 +146,11 @@ function getDefaultOpts (simple) { description: 'Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `` and ``', type: 'boolean' }, + ellipsis: { + defaultValue: true, + description: 'Replaces three dots with the ellipsis unicode character', + type: 'boolean' + }, completeHTMLDocument: { defaultValue: false, description: 'Outputs a complete html document, including ``, `` and `` tags', diff --git a/src/subParsers/makehtml/ellipsis.js b/src/subParsers/makehtml/ellipsis.js index 68856a6..757fca0 100644 --- a/src/subParsers/makehtml/ellipsis.js +++ b/src/subParsers/makehtml/ellipsis.js @@ -1,6 +1,10 @@ showdown.subParser('makehtml.ellipsis', function (text, options, globals) { 'use strict'; + if (!options.ellipsis) { + return text; + } + text = globals.converter._dispatch('makehtml.ellipsis.before', text, options, globals).getText(); text = text.replace(/\.\.\./g, '…'); diff --git a/test/functional/makehtml/cases/features/ellipsis/ellipsis.html b/test/functional/makehtml/cases/features/ellipsis/ellipsis.html new file mode 100644 index 0000000..8edcf27 --- /dev/null +++ b/test/functional/makehtml/cases/features/ellipsis/ellipsis.html @@ -0,0 +1,20 @@ +

ellipsis in text...

+

+
    +
  1. foo...
  2. +
  3. bar
  4. +
+
+

ellipsis in blockquote...

+
+
ellipsis in code...
+
+
ellipsis in code...
+
+

ellipsis in header...

+

1...

+
    +
  1. ..
  2. +
+

1…

+

Link

\ No newline at end of file diff --git a/test/functional/makehtml/cases/features/ellipsis/ellipsis.md b/test/functional/makehtml/cases/features/ellipsis/ellipsis.md new file mode 100644 index 0000000..81023be --- /dev/null +++ b/test/functional/makehtml/cases/features/ellipsis/ellipsis.md @@ -0,0 +1,24 @@ +ellipsis in text... + +… + +1. foo... +2. bar + +> ellipsis in blockquote... + +``` +ellipsis in code... +``` + + ellipsis in code... + +# ellipsis in header... + +1... + +1. .. + +1… + +[Link](https://gitlab.com/gitlab-org/gitlab-ce/compare/v11.5.4...v11.5.5 "title") \ No newline at end of file diff --git a/test/functional/makehtml/cases/standard/ellipsis.html b/test/functional/makehtml/cases/standard/ellipsis.html index fd77939..5830164 100644 --- a/test/functional/makehtml/cases/standard/ellipsis.html +++ b/test/functional/makehtml/cases/standard/ellipsis.html @@ -17,3 +17,4 @@
  • ..
  • 1…

    +

    Link

    \ No newline at end of file diff --git a/test/functional/makehtml/cases/standard/ellipsis.md b/test/functional/makehtml/cases/standard/ellipsis.md index e790fb5..5b6aa98 100644 --- a/test/functional/makehtml/cases/standard/ellipsis.md +++ b/test/functional/makehtml/cases/standard/ellipsis.md @@ -19,4 +19,6 @@ ellipsis in code... 1. .. -1... \ No newline at end of file +1... + +[Link](https://gitlab.com/gitlab-org/gitlab-ce/compare/v11.5.4...v11.5.5 "title") \ No newline at end of file diff --git a/test/functional/makehtml/testsuite.features.js b/test/functional/makehtml/testsuite.features.js index b1498bd..40f1252 100644 --- a/test/functional/makehtml/testsuite.features.js +++ b/test/functional/makehtml/testsuite.features.js @@ -13,6 +13,7 @@ var bootstrap = require('./makehtml.bootstrap.js'), rawPrefixHeaderIdSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/rawPrefixHeaderId/'), emojisSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/emojis/'), underlineSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/underline/'), + ellipsisSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/ellipsis/'), literalMidWordUnderscoresSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/literalMidWordUnderscores/'), //literalMidWordAsterisksSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/literalMidWordAsterisks/'), completeHTMLOutputSuite = bootstrap.getTestSuite('test/functional/makehtml/cases/features/completeHTMLOutput/'), @@ -215,6 +216,16 @@ describe('makeHtml() features testsuite', function () { } }); + /** test ellipsis option **/ + describe('ellipsis option', function () { + var converter, + suite = ellipsisSuite; + for (var i = 0; i < suite.length; ++i) { + converter = new showdown.Converter({ellipsis: false}); + it(suite[i].name.replace(/-/g, ' '), assertion(suite[i], converter)); + } + }); + /** test literalMidWordUnderscores option **/ describe('literalMidWordUnderscores option', function () { var converter,