Merge branch 'master' into greenkeeper/sinon-3.0.0

This commit is contained in:
Estevão Soares dos Santos 2017-08-05 01:53:40 +01:00 committed by GitHub
commit aaf6d032f3
20 changed files with 126 additions and 14 deletions

View File

@ -1,3 +1,20 @@
<a name="1.7.2"></a>
## [1.7.2](https://github.com/showdownjs/showdown/compare/1.7.1...1.7.2) (2017-08-05)
### Bug Fixes
* **githubMentions:** githubMentions now works with openLinksInNewWindow options ([1194d88](https://github.com/showdownjs/showdown/commit/1194d88)), closes [#403](https://github.com/showdownjs/showdown/issues/403)
* **lists:** fix multi paragraph lists with sublists ([a2259c0](https://github.com/showdownjs/showdown/commit/a2259c0)), closes [#397](https://github.com/showdownjs/showdown/issues/397)
* **tablesHeaderId:** fix missmatch of option name ([51e4693](https://github.com/showdownjs/showdown/commit/51e4693)), closes [#412](https://github.com/showdownjs/showdown/issues/412)
### Features
* **backslashEscapesHTMLTags:** backslash escapes HTML tags ([5a5aff6](https://github.com/showdownjs/showdown/commit/5a5aff6)), closes [#374](https://github.com/showdownjs/showdown/issues/374)
<a name="1.7.1"></a> <a name="1.7.1"></a>
## [1.7.1](https://github.com/showdownjs/showdown/compare/1.7.0...1.7.1) (2017-06-02) ## [1.7.1](https://github.com/showdownjs/showdown/compare/1.7.0...1.7.1) (2017-06-02)

View File

@ -198,7 +198,7 @@ var defaultOptions = showdown.getDefaultOptions();
* **noHeaderId**: (boolean) [default false] Disable the automatic generation of header ids. Setting to true overrides **prefixHeaderId** * **noHeaderId**: (boolean) [default false] Disable the automatic generation of header ids. Setting to true overrides **prefixHeaderId**
* **customizedHeaderId**: (boolean) [default false] Use text in curly braces as header id. * **customizedHeaderId**: (boolean) [default false] Use text in curly braces as header id. (since v1.7.0)
Example: Example:
``` ```
## Sample header {real-id} will use real-id as id ## Sample header {real-id} will use real-id as id
@ -328,7 +328,9 @@ var defaultOptions = showdown.getDefaultOptions();
NOTE: Prior to version 1.6.1, emails would always be obfuscated through dec and hex encoding. NOTE: Prior to version 1.6.1, emails would always be obfuscated through dec and hex encoding.
* **openLinksInNewWindow**: (boolean) [default false] Open all links in new windows (by adding the attribute `target="_blank"` to `<a>` tags) * **openLinksInNewWindow**: (boolean) [default false] Open all links in new windows (by adding the attribute `target="_blank"` to `<a>` tags) (since v1.7.0)
* **backslashEscapesHTMLTags**: (boolean) [default false] Support for HTML Tag escaping. ex: `\<div>foo\</div>` (since v1.7.2)
**NOTE**: Please note that until version 1.6.0, all of these options are ***DISABLED*** by default in the cli tool. **NOTE**: Please note that until version 1.6.0, all of these options are ***DISABLED*** by default in the cli tool.

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
{ {
"name": "showdown", "name": "showdown",
"version": "1.7.1", "version": "1.7.2",
"description": "A Markdown to HTML converter written in Javascript", "description": "A Markdown to HTML converter written in Javascript",
"author": "Estevão Santos", "author": "Estevão Santos",
"homepage": "http://showdownjs.github.io/showdown/", "homepage": "http://showdownjs.github.io/showdown/",
@ -53,7 +53,7 @@
"load-grunt-tasks": "^3.2.0", "load-grunt-tasks": "^3.2.0",
"performance-now": "^2.0.0", "performance-now": "^2.0.0",
"quiet-grunt": "^0.2.3", "quiet-grunt": "^0.2.3",
"semver": "^5.0.0", "semver": "^5.4.1",
"semver-sort": "0.0.4", "semver-sort": "0.0.4",
"sinon": "^3.0.0", "sinon": "^3.0.0",
"source-map-support": "^0.4.15" "source-map-support": "^0.4.15"

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,47 @@
# Performance Tests for showdown # Performance Tests for showdown
## [version 1.7.2](https://github.com/showdownjs/showdown/tree/1.7.2)
### Test Suite: Basic (50 cycles)
| test | avgTime | max | min |
|:-----|--------:|----:|----:|
|Simple "Hello World"|0.292|5.780|0.087|
|performance.testfile.md|30.396|53.860|26.054|
### Test Suite: subParsers (20 cycles)
| test | avgTime | max | min |
|:-----|--------:|----:|----:|
|hashHTMLBlocks|4.303|7.798|2.377|
|anchors|0.347|0.647|0.287|
|autoLinks|0.088|0.165|0.063|
|blockQuotes|2.101|5.121|1.738|
|codeBlocks|0.239|0.878|0.184|
|codeSpans|0.252|0.628|0.160|
|detab|0.094|0.129|0.088|
|encodeAmpsAndAngles|0.131|0.733|0.093|
|encodeBackslashEscapes|0.080|0.116|0.070|
|encodeCode|0.939|1.480|0.857|
|escapeSpecialCharsWithinTagAttributes|0.285|0.473|0.243|
|githubCodeBlocks|0.214|1.047|0.140|
|hashBlock|0.068|0.553|0.036|
|hashElement|0.002|0.030|0.000|
|hashHTMLSpans|4.323|6.162|4.004|
|hashPreCodeTags|0.147|0.558|0.109|
|headers|1.176|4.491|0.884|
|horizontalRule|0.216|0.264|0.193|
|images|0.156|0.559|0.118|
|italicsAndBold|0.322|1.013|0.237|
|lists|2.753|5.613|2.328|
|outdent|0.163|0.232|0.140|
|paragraphs|5.109|6.168|4.741|
|spanGamut|4.423|6.149|4.001|
|strikethrough|0.003|0.051|0.000|
|stripLinkDefinitions|0.160|0.226|0.142|
|tables|0.002|0.043|0.000|
|unescapeSpecialChars|0.011|0.046|0.007|
## [version 1.7.1](https://github.com/showdownjs/showdown/tree/1.7.1) ## [version 1.7.1](https://github.com/showdownjs/showdown/tree/1.7.1)
### Test Suite: Basic (50 cycles) ### Test Suite: Basic (50 cycles)

View File

@ -125,6 +125,11 @@ function getDefaultOpts (simple) {
defaultValue: false, defaultValue: false,
description: 'Open all links in new windows', description: 'Open all links in new windows',
type: 'boolean' type: 'boolean'
},
backslashEscapesHTMLTags: {
defaultValue: false,
description: 'Support for HTML Tag escaping. ex: \<div>foo\</div>',
type: 'boolean'
} }
}; };
if (simple === false) { if (simple === false) {

View File

@ -82,8 +82,12 @@ showdown.subParser('anchors', function (text, options, globals) {
if (!showdown.helper.isString(options.ghMentionsLink)) { if (!showdown.helper.isString(options.ghMentionsLink)) {
throw new Error('ghMentionsLink option must be a string'); throw new Error('ghMentionsLink option must be a string');
} }
var lnk = options.ghMentionsLink.replace(/\{u}/g, username); var lnk = options.ghMentionsLink.replace(/\{u}/g, username),
return st + '<a href="' + lnk + '">' + mentions + '</a>'; target = '';
if (options.openLinksInNewWindow) {
target = ' target="¨E95Eblank"';
}
return st + '<a href="' + lnk + '"' + target + '>' + mentions + '</a>';
}); });
} }

View File

@ -48,14 +48,26 @@ showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n'; return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
}; };
if (options.backslashEscapesHTMLTags) {
// encode backslash escaped HTML tags
text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) {
return '&lt;' + inside + '&gt;';
});
}
// hash HTML Blocks
for (var i = 0; i < blockTags.length; ++i) { for (var i = 0; i < blockTags.length; ++i) {
var opTagPos, var opTagPos,
rgx1 = new RegExp('^ {0,3}<' + blockTags[i] + '\\b[^>]*>', 'im'), rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'),
patLeft = '<' + blockTags[i] + '\\b[^>]*>', patLeft = '<' + blockTags[i] + '\\b[^>]*>',
patRight = '</' + blockTags[i] + '>'; patRight = '</' + blockTags[i] + '>';
// 1. Look for the first position of the first opening HTML tag in the text // 1. Look for the first position of the first opening HTML tag in the text
while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) { while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) {
// if the HTML tag is \ escaped, we need to escape it and break
//2. Split the text in that position //2. Split the text in that position
var subTexts = showdown.helper.splitAtIndex(text, opTagPos), var subTexts = showdown.helper.splitAtIndex(text, opTagPos),
//3. Match recursively //3. Match recursively

View File

@ -93,16 +93,14 @@ showdown.subParser('lists', function (text, options, globals) {
item = showdown.subParser('lists')(item, options, globals); item = showdown.subParser('lists')(item, options, globals);
item = item.replace(/\n$/, ''); // chomp(item) item = item.replace(/\n$/, ''); // chomp(item)
item = showdown.subParser('hashHTMLBlocks')(item, options, globals); item = showdown.subParser('hashHTMLBlocks')(item, options, globals);
// Colapse double linebreaks // Colapse double linebreaks
item = item.replace(/\n\n+/g, '\n\n'); item = item.replace(/\n\n+/g, '\n\n');
// replace double linebreaks with a placeholder
item = item.replace(/\n\n/g, '¨B');
if (isParagraphed) { if (isParagraphed) {
item = showdown.subParser('paragraphs')(item, options, globals); item = showdown.subParser('paragraphs')(item, options, globals);
} else { } else {
item = showdown.subParser('spanGamut')(item, options, globals); item = showdown.subParser('spanGamut')(item, options, globals);
} }
item = item.replace(/¨B/g, '\n\n');
} }
// now we need to remove the marker (¨A) // now we need to remove the marker (¨A)

View File

@ -32,7 +32,10 @@ showdown.subParser('spanGamut', function (text, options, globals) {
// Do hard breaks // Do hard breaks
if (options.simpleLineBreaks) { if (options.simpleLineBreaks) {
// GFM style hard breaks // GFM style hard breaks
text = text.replace(/\n/g, '<br />\n'); // only add line breaks if the text does not contain a block (special case for lists)
if (!/\n\n¨K/.test(text)) {
text = text.replace(/\n+/g, '<br />\n');
}
} else { } else {
// Vanilla hard breaks // Vanilla hard breaks
text = text.replace(/ +\n/g, '<br />\n'); text = text.replace(/ +\n/g, '<br />\n');

View File

@ -22,7 +22,8 @@ showdown.subParser('tables', function (text, options, globals) {
function parseHeaders (header, style) { function parseHeaders (header, style) {
var id = ''; var id = '';
header = header.trim(); header = header.trim();
if (options.tableHeaderId) { // support both tablesHeaderId and tableHeaderId due to error in documention so we don't break backwards compatibility
if (options.tablesHeaderId || options.tableHeaderId) {
id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"'; id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
} }
header = showdown.subParser('spanGamut')(header, options, globals); header = showdown.subParser('spanGamut')(header, options, globals);

View File

@ -0,0 +1 @@
<p>&lt;div&gt;foo&lt;/div&gt;</p>

View File

@ -0,0 +1 @@
\<div>foo\</div>

View File

@ -0,0 +1,14 @@
<ul>
<li><p><strong>Customer</strong> Opens the Customer List. Refer to the document “Customer Management”.</p>
<ul>
<li>Customer List</li>
<li>New Customer</li>
<li>Customer Prices</li>
<li>Appointments</li></ul></li>
<li><p><strong>Designer</strong> - Opens the Designer List. Refer to the document “Designer Commissions”.</p>
<ul>
<li>Designer List</li>
<li>New Designer</li>
<li>Designer Payment List</li>
<li>New Designer Payment</li></ul></li>
</ul>

View File

@ -0,0 +1,11 @@
- **Customer** Opens the Customer List. Refer to the document “Customer Management”.
- Customer List
- New Customer
- Customer Prices
- Appointments
- **Designer** - Opens the Designer List. Refer to the document “Designer Commissions”.
- Designer List
- New Designer
- Designer Payment List
- New Designer Payment

View File

@ -80,6 +80,8 @@ describe('makeHtml() features testsuite', function () {
converter = new showdown.Converter({customizedHeaderId: true}); converter = new showdown.Converter({customizedHeaderId: true});
} else if (testsuite[i].name === '#378.simplifiedAutoLinks-with-excludeTrailingPunctuationFromURLs') { } else if (testsuite[i].name === '#378.simplifiedAutoLinks-with-excludeTrailingPunctuationFromURLs') {
converter = new showdown.Converter({simplifiedAutoLink: true, excludeTrailingPunctuationFromURLs: true}); converter = new showdown.Converter({simplifiedAutoLink: true, excludeTrailingPunctuationFromURLs: true});
} else if (testsuite[i].name === '#374.escape-html-tags') {
converter = new showdown.Converter({backslashEscapesHTMLTags: true});
} else if (testsuite[i].name === '#379.openLinksInNewWindow-breaks-em-markdup') { } else if (testsuite[i].name === '#379.openLinksInNewWindow-breaks-em-markdup') {
converter = new showdown.Converter({openLinksInNewWindow: true}); converter = new showdown.Converter({openLinksInNewWindow: true});
} else { } else {
@ -95,7 +97,7 @@ describe('makeHtml() features testsuite', function () {
suite = tableSuite; suite = tableSuite;
for (var i = 0; i < suite.length; ++i) { for (var i = 0; i < suite.length; ++i) {
if (suite[i].name === 'basic-with-header-ids') { if (suite[i].name === 'basic-with-header-ids') {
converter = new showdown.Converter({tables: true, tableHeaderId: true}); converter = new showdown.Converter({tables: true, tablesHeaderId: true});
} else if (suite[i].name === '#179.parse-md-in-table-ths') { } else if (suite[i].name === '#179.parse-md-in-table-ths') {
converter = new showdown.Converter({tables: true, strikethrough: true}); converter = new showdown.Converter({tables: true, strikethrough: true});
} else { } else {