Merge pull request #731 from VladimirV99/ellipsis

feature(ellipsis): Add option to disable ellipsis
This commit is contained in:
Devyn S 2021-11-12 09:58:50 -07:00 committed by GitHub
commit 6efd75cb83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 158 additions and 69 deletions

View File

@ -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 `<em>` and `<strong>`.
* **ellipsis**: (boolean) [default true] Replaces three dots with the ellipsis unicode character.
* **completeHTMLDocument**: (boolean) [default false] Outputs a complete html document,
including `<html>`, `<head>` and `<body>` tags' instead of an HTML fragment. (since v.1.8.5)

146
dist/showdown.js vendored
View File

@ -1,5 +1,5 @@
;/*! showdown v 2.0.0-alpha1 - 24-10-2018 */
(function(){
;/*! showdown v 2.0.0-alpha1 - 04-10-2019 */
(function(){
/**
* Created by Tivie on 13-07-2015.
*/
@ -148,6 +148,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 `<em>` and `<strong>`',
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 `<html>`, `<head>` and `<body>` tags',
@ -187,7 +192,7 @@ function allOptionsOn () {
}
return ret;
}
/**
* Created by Tivie on 06-01-2015.
*/
@ -567,7 +572,7 @@ showdown.validateExtension = function (ext) {
}
return true;
};
/**
* showdownjs helper functions
*/
@ -2255,7 +2260,7 @@ showdown.helper.emojis = {
'octocat': '<img width="20" height="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">',
'showdown': '<img width="20" height="20" align="absmiddle" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAS1BMVEX///8jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS0jJS3b1q3b1q3b1q3b1q3b1q3b1q3b1q3b1q0565CIAAAAGXRSTlMAQHCAYCCw/+DQwPCQUBAwoHCAEP+wwFBgS2fvBgAAAUZJREFUeAHs1cGy7BAUheFFsEDw/k97VTq3T6ge2EmdM+pvrP6Iwd74XV9Kb52xuMU4/uc1YNgZLFOeV8FGdhGrNk5SEgUyPxAEdj4LlMRDyhVAMVEa2M7TBSeVZAFPdqHgzSZJwPKgcLFLAooHDJo4EDCw4gAtBoJA5UFj4Ng5LOGLwVXZuoIlji/jeQHFk7+baHxrCjeUwB9+s88KndvlhcyBN5BSkYNQIVVb4pV+Npm7hhuKDs/uMP5KxT3WzSNNLIuuoDpMmuAVMruMSeDyQBi24DTr43LAY7ILA1QYaWkgfHzFthYYzg67SQsCbB8GhJUEGCtO9n0rSaCLxgJQjS/JSgMTg2eBDEHAJ+H350AsjYNYscrErgI2e/l+mdR967TCX/v6N0EhPECYCP0i+IAoYQOE8BogNhQMEMdrgAQWHaMAAGi5I5euoY9NAAAAAElFTkSuQmCC">'
};
/**
* These are all the transformations that form block-level
* tags like paragraphs, headers, and list items.
@ -2288,7 +2293,7 @@ showdown.subParser('makehtml.blockGamut', function (text, options, globals) {
return text;
});
showdown.subParser('makehtml.blockQuotes', function (text, options, globals) {
'use strict';
@ -2331,7 +2336,7 @@ showdown.subParser('makehtml.blockQuotes', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.blockQuotes.after', text, options, globals).getText();
return text;
});
/**
* Process Markdown `<pre><code>` blocks.
*/
@ -2370,7 +2375,7 @@ showdown.subParser('makehtml.codeBlocks', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.codeBlocks.after', text, options, globals).getText();
return text;
});
/**
*
* * Backtick quotes are used for <code></code> spans.
@ -2419,7 +2424,7 @@ showdown.subParser('makehtml.codeSpans', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.codeSpans.after', text, options, globals).getText();
return text;
});
/**
* Create a full HTML document from the processed markdown
*/
@ -2482,7 +2487,7 @@ showdown.subParser('makehtml.completeHTMLDocument', function (text, options, glo
text = globals.converter._dispatch('makehtml.completeHTMLDocument.after', text, options, globals).getText();
return text;
});
/**
* Convert all tabs to spaces
*/
@ -2516,10 +2521,14 @@ showdown.subParser('makehtml.detab', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.detab.after', text, options, globals).getText();
return text;
});
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, '…');
@ -2528,10 +2537,11 @@ showdown.subParser('makehtml.ellipsis', function (text, options, globals) {
return text;
});
/**
* These are all the transformations that occur *within* block-level
* tags like paragraphs, headers, and list items.
* Turn emoji codes into emojis
*
* List of supported emojis: https://github.com/showdownjs/showdown/wiki/Emojis
*/
showdown.subParser('makehtml.emoji', function (text, options, globals) {
'use strict';
@ -2555,7 +2565,7 @@ showdown.subParser('makehtml.emoji', function (text, options, globals) {
return text;
});
/**
* Smart processing for ampersands and angle brackets that need to be encoded.
*/
@ -2579,7 +2589,7 @@ showdown.subParser('makehtml.encodeAmpsAndAngles', function (text, options, glob
text = globals.converter._dispatch('makehtml.encodeAmpsAndAngles.after', text, options, globals).getText();
return text;
});
/**
* Returns the string, with after processing the following backslash escape sequences.
*
@ -2601,7 +2611,7 @@ showdown.subParser('makehtml.encodeBackslashEscapes', function (text, options, g
text = globals.converter._dispatch('makehtml.encodeBackslashEscapes.after', text, options, globals).getText();
return text;
});
/**
* Encode/escape certain characters inside Markdown code runs.
* The point is that in code, these characters are literals,
@ -2625,7 +2635,7 @@ showdown.subParser('makehtml.encodeCode', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.encodeCode.after', text, options, globals).getText();
return text;
});
/**
* Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they
* don't conflict with their use in Markdown for code, italics and strong.
@ -2652,7 +2662,7 @@ showdown.subParser('makehtml.escapeSpecialCharsWithinTagAttributes', function (t
text = globals.converter._dispatch('makehtml.escapeSpecialCharsWithinTagAttributes.after', text, options, globals).getText();
return text;
});
/**
* Handle github codeblocks prior to running HashHTML so that
* HTML contained within the codeblock gets escaped properly
@ -2699,7 +2709,7 @@ showdown.subParser('makehtml.githubCodeBlocks', function (text, options, globals
return globals.converter._dispatch('makehtml.githubCodeBlocks.after', text, options, globals).getText();
});
showdown.subParser('makehtml.hashBlock', function (text, options, globals) {
'use strict';
text = globals.converter._dispatch('makehtml.hashBlock.before', text, options, globals).getText();
@ -2708,7 +2718,7 @@ showdown.subParser('makehtml.hashBlock', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.hashBlock.after', text, options, globals).getText();
return text;
});
/**
* Hash and escape <code> elements that should not be parsed as markdown
*/
@ -2727,7 +2737,7 @@ showdown.subParser('makehtml.hashCodeTags', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.hashCodeTags.after', text, options, globals).getText();
return text;
});
showdown.subParser('makehtml.hashElement', function (text, options, globals) {
'use strict';
@ -2747,7 +2757,7 @@ showdown.subParser('makehtml.hashElement', function (text, options, globals) {
return blockText;
};
});
showdown.subParser('makehtml.hashHTMLBlocks', function (text, options, globals) {
'use strict';
text = globals.converter._dispatch('makehtml.hashHTMLBlocks.before', text, options, globals).getText();
@ -2846,7 +2856,7 @@ showdown.subParser('makehtml.hashHTMLBlocks', function (text, options, globals)
text = globals.converter._dispatch('makehtml.hashHTMLBlocks.after', text, options, globals).getText();
return text;
});
/**
* Hash span elements that should not be parsed as markdown
*/
@ -2905,7 +2915,7 @@ showdown.subParser('makehtml.unhashHTMLSpans', function (text, options, globals)
text = globals.converter._dispatch('makehtml.unhashHTMLSpans.after', text, options, globals).getText();
return text;
});
/**
* Hash and escape <pre><code> elements that should not be parsed as markdown
*/
@ -2925,7 +2935,7 @@ showdown.subParser('makehtml.hashPreCodeTags', function (text, options, globals)
text = globals.converter._dispatch('makehtml.hashPreCodeTags.after', text, options, globals).getText();
return text;
});
showdown.subParser('makehtml.headers', function (text, options, globals) {
'use strict';
@ -3052,7 +3062,7 @@ showdown.subParser('makehtml.headers', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.headers.after', text, options, globals).getText();
return text;
});
/**
* Turn Markdown horizontal rule shortcuts into <hr /> tags.
*
@ -3071,7 +3081,7 @@ showdown.subParser('makehtml.horizontalRule', function (text, options, globals)
text = globals.converter._dispatch('makehtml.horizontalRule.after', text, options, globals).getText();
return text;
});
/**
* Turn Markdown image shortcuts into <img> tags.
*/
@ -3176,7 +3186,7 @@ showdown.subParser('makehtml.images', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.images.after', text, options, globals).getText();
return text;
});
showdown.subParser('makehtml.italicsAndBold', function (text, options, globals) {
'use strict';
@ -3243,7 +3253,7 @@ showdown.subParser('makehtml.italicsAndBold', function (text, options, globals)
text = globals.converter._dispatch('makehtml.italicsAndBold.after', text, options, globals).getText();
return text;
});
////
// makehtml/links.js
// Copyright (c) 2018 ShowdownJS
@ -3663,7 +3673,7 @@ showdown.subParser('makehtml.italicsAndBold', function (text, options, globals)
return text;
});
})();
/**
* Form HTML ordered (numbered) and unordered (bulleted) lists.
*/
@ -3880,7 +3890,7 @@ showdown.subParser('makehtml.lists', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.lists.after', text, options, globals).getText();
return text;
});
/**
* Parse metadata at the top of the document
*/
@ -3930,7 +3940,7 @@ showdown.subParser('makehtml.metadata', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.metadata.after', text, options, globals).getText();
return text;
});
/**
* Remove one level of line-leading tabs or spaces
*/
@ -3948,7 +3958,7 @@ showdown.subParser('makehtml.outdent', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.outdent.after', text, options, globals).getText();
return text;
});
/**
*
*/
@ -4019,7 +4029,7 @@ showdown.subParser('makehtml.paragraphs', function (text, options, globals) {
text = text.replace(/\n+$/g, '');
return globals.converter._dispatch('makehtml.paragraphs.after', text, options, globals).getText();
});
/**
* Run extension
*/
@ -4040,7 +4050,7 @@ showdown.subParser('makehtml.runExtension', function (ext, text, options, global
return text;
});
/**
* These are all the transformations that occur *within* block-level
* tags like paragraphs, headers, and list items.
@ -4091,7 +4101,7 @@ showdown.subParser('makehtml.spanGamut', function (text, options, globals) {
text = globals.converter._dispatch('makehtml.spanGamut.after', text, options, globals).getText();
return text;
});
showdown.subParser('makehtml.strikethrough', function (text, options, globals) {
'use strict';
@ -4103,7 +4113,7 @@ showdown.subParser('makehtml.strikethrough', function (text, options, globals) {
return text;
});
/**
* Strips link definitions from text, stores the URLs and titles in
* hash references.
@ -4157,7 +4167,7 @@ showdown.subParser('makehtml.stripLinkDefinitions', function (text, options, glo
return text;
});
showdown.subParser('makehtml.tables', function (text, options, globals) {
'use strict';
@ -4301,7 +4311,7 @@ showdown.subParser('makehtml.tables', function (text, options, globals) {
return text;
});
showdown.subParser('makehtml.underline', function (text, options, globals) {
'use strict';
@ -4334,7 +4344,7 @@ showdown.subParser('makehtml.underline', function (text, options, globals) {
return text;
});
/**
* Swap back in all the special characters we've hidden.
*/
@ -4350,7 +4360,7 @@ showdown.subParser('makehtml.unescapeSpecialChars', function (text, options, glo
text = globals.converter._dispatch('makehtml.unescapeSpecialChars.after', text, options, globals).getText();
return text;
});
showdown.subParser('makeMarkdown.blockquote', function (node, globals) {
'use strict';
@ -4373,7 +4383,13 @@ showdown.subParser('makeMarkdown.blockquote', function (node, globals) {
txt = '> ' + txt.split('\n').join('\n> ');
return txt;
});
showdown.subParser('makeMarkdown.break', function () {
'use strict';
return ' \n';
});
showdown.subParser('makeMarkdown.codeBlock', function (node, globals) {
'use strict';
@ -4381,13 +4397,13 @@ showdown.subParser('makeMarkdown.codeBlock', function (node, globals) {
num = node.getAttribute('precodenum');
return '```' + lang + '\n' + globals.preList[num] + '\n```';
});
showdown.subParser('makeMarkdown.codeSpan', function (node) {
'use strict';
return '`' + node.innerHTML + '`';
});
showdown.subParser('makeMarkdown.emphasis', function (node, globals) {
'use strict';
@ -4403,7 +4419,7 @@ showdown.subParser('makeMarkdown.emphasis', function (node, globals) {
}
return txt;
});
showdown.subParser('makeMarkdown.header', function (node, globals, headerLevel) {
'use strict';
@ -4421,13 +4437,13 @@ showdown.subParser('makeMarkdown.header', function (node, globals, headerLevel)
}
return txt;
});
showdown.subParser('makeMarkdown.hr', function () {
'use strict';
return '---';
});
showdown.subParser('makeMarkdown.image', function (node) {
'use strict';
@ -4446,7 +4462,7 @@ showdown.subParser('makeMarkdown.image', function (node) {
}
return txt;
});
showdown.subParser('makeMarkdown.links', function (node, globals) {
'use strict';
@ -4467,7 +4483,7 @@ showdown.subParser('makeMarkdown.links', function (node, globals) {
}
return txt;
});
showdown.subParser('makeMarkdown.list', function (node, globals, type) {
'use strict';
@ -4499,7 +4515,7 @@ showdown.subParser('makeMarkdown.list', function (node, globals, type) {
return txt.trim();
});
showdown.subParser('makeMarkdown.listItem', function (node, globals) {
'use strict';
@ -4525,7 +4541,7 @@ showdown.subParser('makeMarkdown.listItem', function (node, globals) {
return listItemTxt;
});
showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) {
@ -4637,6 +4653,10 @@ showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) {
txt = showdown.subParser('makeMarkdown.image')(node, globals);
break;
case 'br':
txt = showdown.subParser('makeMarkdown.break')(node, globals);
break;
default:
txt = node.outerHTML + '\n\n';
}
@ -4646,7 +4666,7 @@ showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) {
return txt;
});
showdown.subParser('makeMarkdown.paragraph', function (node, globals) {
'use strict';
@ -4664,14 +4684,14 @@ showdown.subParser('makeMarkdown.paragraph', function (node, globals) {
return txt;
});
showdown.subParser('makeMarkdown.pre', function (node, globals) {
'use strict';
var num = node.getAttribute('prenum');
return '<pre>' + globals.preList[num] + '</pre>';
});
showdown.subParser('makeMarkdown.strikethrough', function (node, globals) {
'use strict';
@ -4687,7 +4707,7 @@ showdown.subParser('makeMarkdown.strikethrough', function (node, globals) {
}
return txt;
});
showdown.subParser('makeMarkdown.strong', function (node, globals) {
'use strict';
@ -4703,7 +4723,7 @@ showdown.subParser('makeMarkdown.strong', function (node, globals) {
}
return txt;
});
showdown.subParser('makeMarkdown.table', function (node, globals) {
'use strict';
@ -4774,7 +4794,7 @@ showdown.subParser('makeMarkdown.table', function (node, globals) {
return txt.trim();
});
showdown.subParser('makeMarkdown.tableCell', function (node, globals) {
'use strict';
@ -4790,7 +4810,7 @@ showdown.subParser('makeMarkdown.tableCell', function (node, globals) {
}
return txt.trim();
});
showdown.subParser('makeMarkdown.txt', function (node) {
'use strict';
@ -4834,7 +4854,7 @@ showdown.subParser('makeMarkdown.txt', function (node) {
return txt;
});
/**
* Created by Estevao on 31-05-2015.
*/
@ -5437,7 +5457,7 @@ showdown.Converter = function (converterOptions) {
metadata.raw = raw;
};
};
var root = this;
// AMD Loader
@ -5455,6 +5475,6 @@ if (typeof define === 'function' && define.amd) {
} else {
root.showdown = showdown;
}
}).call(this);
}).call(this);
//# sourceMappingURL=showdown.js.map
//# sourceMappingURL=showdown.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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 `<em>` and `<strong>`',
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 `<html>`, `<head>` and `<body>` tags',

View File

@ -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, '…');

View File

@ -0,0 +1,20 @@
<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>
<p><a href="https://gitlab.com/gitlab-org/gitlab-ce/compare/v11.5.4...v11.5.5" title="title">Link</a></p>

View File

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

View File

@ -17,3 +17,4 @@
<li>..</li>
</ol>
<p>1…</p>
<p><a href="https://gitlab.com/gitlab-org/gitlab-ce/compare/v11.5.4...v11.5.5" title="title">Link</a></p>

View File

@ -19,4 +19,6 @@ ellipsis in code...
1. ..
1...
1...
[Link](https://gitlab.com/gitlab-org/gitlab-ce/compare/v11.5.4...v11.5.5 "title")

View File

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