From 5d494c82027fbae127104ca581d350fdb857fdb7 Mon Sep 17 00:00:00 2001 From: Vladimir Vuksanovic Date: Fri, 4 Oct 2019 16:45:27 +0200 Subject: [PATCH] feature(ellipsis): Add option to disable ellipsis Add ability to disable ellipsis parser. This is needed for some use cases. See #634 Defaults to true to keep backwards compatibility. --- README.md | 2 ++ dist/showdown.js | Bin 173544 -> 173869 bytes dist/showdown.js.map | Bin 488985 -> 490089 bytes dist/showdown.min.js | Bin 81125 -> 81379 bytes dist/showdown.min.js.map | Bin 91924 -> 92115 bytes src/options.js | 5 ++++ src/subParsers/makehtml/ellipsis.js | 4 +++ .../cases/features/ellipsis/ellipsis.html | 20 +++++++++++++++ .../cases/features/ellipsis/ellipsis.md | 24 ++++++++++++++++++ .../makehtml/cases/standard/ellipsis.html | 1 + .../makehtml/cases/standard/ellipsis.md | 4 ++- .../functional/makehtml/testsuite.features.js | 11 ++++++++ 12 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 test/functional/makehtml/cases/features/ellipsis/ellipsis.html create mode 100644 test/functional/makehtml/cases/features/ellipsis/ellipsis.md diff --git a/README.md b/README.md index 4c6008a..bf5faa5 100644 --- a/README.md +++ b/README.md @@ -348,6 +348,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 36c74cd802fbe1595b2e6bacaae1c6faa19313ce..aa9299bbbc31354d6c3530fd33d8b61875ddf8d4 100644 GIT binary patch delta 982 zcmX|8OGs2<6y_WqXS@?WF{QMAH1q8pANd$_@X>=&F)`5u&Bu6k?x=I8xp$a_*u!X% z5F}Rrt_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a`%sdQ_4H7(`8&8ri%sIum4n zHpp?+Fo|}a7%5%XlBN><+fYklrl}jXvfSFl^#T+C delta 265 zcmV+k0rvjs^c|V(9k9#>v-Sq;A+yUV1_uK%Ohl7VM;ezvR00&2pt}MTmwHQ0W5-x5?fERWg^l5d`c4c1V{YSOON8fcygrx5yF% zZLo*W!vwd_!vz&Fmk`zkEtlN&1qqi=^#$dZ2has3mzvfFafitE1-Hod2Cfa49vue? Px8?)~I2^ZxAqVAHt=VNf diff --git a/dist/showdown.min.js b/dist/showdown.min.js index a298817d3e1de74330369cdeb6c6f228cf8c9c4a..2051edf436327a39caaa59f5ec1694fa77c9ba1a 100644 GIT binary patch delta 193 zcmaF*ljZSmmI-oP1}3_O2D(NDhL#&O+WFX1b8<2ZiZdsl;#M#ZN-fAqOinFUD9I>F zO;t$AFDX_i&n(FR@>3O{3X2s=^D>k3Q&JU@GZKpulS@*IHqYhTFonBF52nI?^1+2_ zlP@ghoLs%Qbn@wSGMhP4vx%f> TYPUKM0ay;V${hh1AOZ~v;j$Jz diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index 4889b775f5371ab74cbd48586ea35380bbf4a643..173bc46e977d012ae852a84213fc67966cf301ea 100644 GIT binary patch delta 1637 zcmY*ZZA@EL7|y8_+B#a0Z6Pqnn7EnrBrVVaHPP*y)7#P&))wdoW?*P-=q<2PN}YCC@w=~$pMGL6rDtd5`GQ;J9Tu4&H~zVxWGiZAj89u z)T{rOa1`!cVmLsglj2JP%lw;oJ6mB`A}mJWOVUn;)9@ogScZAUUVvdgAt4<`(q(-W zgghzYhdd!TDsV@_WzBd6E)5^%pfb-VIt>{wKbN@O7Q{}$M?^{`mf9xK&tD#IYn1ge zLxSzlEPsFe^CQa?M+g~R+|F2{MK6%)_Z|m{n1rVYBRU6BJc*XJkt@_GXsN3&TtYU7 z2=Zq{nLd(Z+> zQ_rqyCWYHkbA6NyCzpLZa{a6=PQv|CNsy3f!XqiqnjpOGhP82tf_yBYo9tBGHy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w%vDf4& z*u@gEekJ3~mEWv3;4)5vV>yj~{Yj(o#>zTUoIOJJsF&Z|z{a`N8&=yXirXnsV=m*x z>k(xa@XpN*6v!VJmS$;tN4fEsXxRQqw{$uJo0)QBi>C6x@_*4OO8WDGF5}R*R#ZLh zk&TjpPCB;PQ11jd7~=5@{})tAJH?kboA~Qn4*tsK`*kxifn=z_bgldnlc5x zxM^FNL}d*q7=VsFyGfWT949J)QfN!0T8A|^;rjM)O#&R;cwkre%MW=zL~P&va#oR;r?L- z0!f&hl(BgK3yZQqp|mX4rO!TqPU_bYx@}*O<)|F)F)v%tdsVwQ6L8ze<^xtRld*z6 zWJAB$ro{xaIa)A#t5L6gr}%08g9g;PyE4}s&~2-|o8mMj+HqOstp0g3TD8Ng0o71r zB@JBm>oX2?(ERiedc<-7dIX$?SFg>ZZ?&M`Yv#ltSJ=&)w+^Gvs;WUHq?0L{HP0PI zkt*Aq@FzGnAApYa>75uoR&kgKhfm*enP)NjaUWl~aX^1Egc{9DE`;|xxdo0%l&1^YuC;$dN90v8gTo^t7{5%joO-;3Tw<*2$h nYC`l^tC(XLowRs7*d$HqSL5hnH9Su_N_>I7oOw2ZdTRdxDW%-8 diff --git a/src/options.js b/src/options.js index afefab0..db19fff 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 4affe1c..7510194 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/'), @@ -213,6 +214,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,