Skip to content

Commit 2feaec3

Browse files
committed
New dist.
1 parent b916820 commit 2feaec3

File tree

2 files changed

+42
-164
lines changed

2 files changed

+42
-164
lines changed

dist/commonmark.js

Lines changed: 41 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var reHtmlBlockOpen = [
2525
/^<[?]/,
2626
/^<![A-Z]/,
2727
/^<!\[CDATA\[/,
28-
/^<[/]?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[123456]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|title|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|[/]?[>]|$)/i,
28+
/^<[/]?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[123456]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|[/]?[>]|$)/i,
2929
new RegExp('^(?:' + OPENTAG + '|' + CLOSETAG + ')\\s*$', 'i')
3030
];
3131

@@ -327,6 +327,7 @@ var blocks = {
327327
ln.slice(parser.nextNonspace).match(reClosingCodeFence));
328328
if (match && match[0].length >= container._fenceLength) {
329329
// closing fence - we're at end of line, so we can return
330+
parser.lastLineLength = match[0].length;
330331
parser.finalize(container, parser.lineNumber);
331332
return 2;
332333
} else {
@@ -675,7 +676,6 @@ var incorporateLine = function(ln) {
675676
all_matched = false;
676677
break;
677678
case 2: // we've hit end of line for fenced code close and can return
678-
this.lastLineLength = ln.length;
679679
return;
680680
default:
681681
throw 'continue returned illegal value, must be 0, 1, or 2';
@@ -771,6 +771,7 @@ var incorporateLine = function(ln) {
771771
container._htmlBlockType >= 1 &&
772772
container._htmlBlockType <= 5 &&
773773
reHtmlBlockClose[container._htmlBlockType].test(this.currentLine.slice(this.offset))) {
774+
this.lastLineLength = ln.length;
774775
this.finalize(container, this.lineNumber);
775776
}
776777

@@ -897,7 +898,6 @@ module.exports = Parser;
897898
"use strict";
898899

899900
var encode = require('mdurl/encode');
900-
var decode = require('mdurl/decode');
901901

902902
var C_BACKSLASH = 92;
903903

@@ -952,7 +952,7 @@ var unescapeString = function(s) {
952952

953953
var normalizeURI = function(uri) {
954954
try {
955-
return encode(decode(uri));
955+
return encode(uri);
956956
}
957957
catch(err) {
958958
return uri;
@@ -992,7 +992,7 @@ module.exports = { unescapeString: unescapeString,
992992
ESCAPABLE: ESCAPABLE
993993
};
994994

995-
},{"entities":11,"mdurl/decode":19,"mdurl/encode":20}],3:[function(require,module,exports){
995+
},{"entities":11,"mdurl/encode":19}],3:[function(require,module,exports){
996996
"use strict";
997997

998998
// derived from https://github.com/mathiasbynens/String.fromCodePoint
@@ -1069,10 +1069,11 @@ if (String.fromCodePoint) {
10691069

10701070
module.exports.Node = require('./node');
10711071
module.exports.Parser = require('./blocks');
1072+
module.exports.Renderer = require('./render/renderer');
10721073
module.exports.HtmlRenderer = require('./render/html');
10731074
module.exports.XmlRenderer = require('./render/xml');
10741075

1075-
},{"./blocks":1,"./node":6,"./render/html":8,"./render/xml":10}],5:[function(require,module,exports){
1076+
},{"./blocks":1,"./node":6,"./render/html":8,"./render/renderer":9,"./render/xml":10}],5:[function(require,module,exports){
10761077
"use strict";
10771078

10781079
var Node = require('./node');
@@ -1111,7 +1112,7 @@ var ESCAPED_CHAR = '\\\\' + ESCAPABLE;
11111112
var ENTITY = common.ENTITY;
11121113
var reHtmlTag = common.reHtmlTag;
11131114

1114-
var rePunctuation = new RegExp(/[!"#$%&'()*+,\-./:;<=>?@\[\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/);
1115+
var rePunctuation = new RegExp(/[!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/);
11151116

11161117
var reLinkTitle = new RegExp(
11171118
'^(?:"(' + ESCAPED_CHAR + '|[^"\\x00])*"' +
@@ -1142,8 +1143,6 @@ var reSpnl = /^ *(?:\n *)?/;
11421143

11431144
var reWhitespaceChar = /^[ \t\n\x0b\x0c\x0d]/;
11441145

1145-
var reWhitespace = /[ \t\n\x0b\x0c\x0d]+/g;
1146-
11471146
var reUnicodeWhitespaceChar = /^\s/;
11481147

11491148
var reFinalSpace = / *$/;
@@ -1379,16 +1378,19 @@ var handleDelim = function(cc, block) {
13791378
block.appendChild(node);
13801379

13811380
// Add entry to stack for this opener
1382-
this.delimiters = { cc: cc,
1383-
numdelims: numdelims,
1384-
origdelims: numdelims,
1385-
node: node,
1386-
previous: this.delimiters,
1387-
next: null,
1388-
can_open: res.can_open,
1389-
can_close: res.can_close };
1390-
if (this.delimiters.previous !== null) {
1381+
if ((res.can_open || res.can_close) &&
1382+
(this.options.smart || cc !== C_SINGLEQUOTE || cc !== C_DOUBLEQUOTE)){
1383+
this.delimiters = { cc: cc,
1384+
numdelims: numdelims,
1385+
origdelims: numdelims,
1386+
node: node,
1387+
previous: this.delimiters,
1388+
next: null,
1389+
can_open: res.can_open,
1390+
can_close: res.can_close };
1391+
if (this.delimiters.previous !== null) {
13911392
this.delimiters.previous.next = this.delimiters;
1393+
}
13921394
}
13931395

13941396
return true;
@@ -1421,14 +1423,15 @@ var processEmphasis = function(stack_bottom) {
14211423
var use_delims;
14221424
var tmp, next;
14231425
var opener_found;
1424-
var openers_bottom = [];
1426+
var openers_bottom = [[],[],[]];
14251427
var odd_match = false;
14261428

1427-
openers_bottom[C_UNDERSCORE] = stack_bottom;
1428-
openers_bottom[C_ASTERISK] = stack_bottom;
1429-
openers_bottom[C_SINGLEQUOTE] = stack_bottom;
1430-
openers_bottom[C_DOUBLEQUOTE] = stack_bottom;
1431-
1429+
for (var i=0; i < 3; i++) {
1430+
openers_bottom[i][C_UNDERSCORE] = stack_bottom;
1431+
openers_bottom[i][C_ASTERISK] = stack_bottom;
1432+
openers_bottom[i][C_SINGLEQUOTE] = stack_bottom;
1433+
openers_bottom[i][C_DOUBLEQUOTE] = stack_bottom;
1434+
}
14321435
// find first closer above stack_bottom:
14331436
closer = this.delimiters;
14341437
while (closer !== null && closer.previous !== stack_bottom) {
@@ -1444,7 +1447,7 @@ var processEmphasis = function(stack_bottom) {
14441447
opener = closer.previous;
14451448
opener_found = false;
14461449
while (opener !== null && opener !== stack_bottom &&
1447-
opener !== openers_bottom[closercc]) {
1450+
opener !== openers_bottom[closer.origdelims % 3][closercc]) {
14481451
odd_match = (closer.can_open || opener.can_close) &&
14491452
closer.origdelims % 3 !== 0 &&
14501453
(opener.origdelims + closer.origdelims) % 3 === 0;
@@ -1523,13 +1526,9 @@ var processEmphasis = function(stack_bottom) {
15231526
closer = closer.next;
15241527

15251528
}
1526-
if (!opener_found && !odd_match) {
1529+
if (!opener_found) {
15271530
// Set lower bound for future searches for openers:
1528-
// We don't do this with odd_match because a **
1529-
// that doesn't match an earlier * might turn into
1530-
// an opener, and the * might be matched by something
1531-
// else.
1532-
openers_bottom[closercc] = old_closer.previous;
1531+
openers_bottom[old_closer.origdelims % 3][closercc] = old_closer.previous;
15331532
if (!old_closer.can_open) {
15341533
// We can remove a closer that can't be an opener,
15351534
// once we've seen there's no matching opener:
@@ -1596,6 +1595,9 @@ var parseLinkDestination = function() {
15961595
if (this.pos === savepos && c !== C_CLOSE_PAREN) {
15971596
return null;
15981597
}
1598+
if (openparens !== 0) {
1599+
return null;
1600+
}
15991601
res = this.subject.substr(savepos, this.pos - savepos);
16001602
return normalizeURI(unescapeString(res));
16011603
} else { // chop off surrounding <..>:
@@ -2038,7 +2040,7 @@ function InlineParser(options){
20382040

20392041
module.exports = InlineParser;
20402042

2041-
},{"./common":2,"./from-code-point.js":3,"./node":6,"./normalize-reference":7,"entities":11,"string.prototype.repeat":21}],6:[function(require,module,exports){
2043+
},{"./common":2,"./from-code-point.js":3,"./node":6,"./normalize-reference":7,"entities":11,"string.prototype.repeat":20}],6:[function(require,module,exports){
20422044
"use strict";
20432045

20442046
function isContainer(node) {
@@ -2421,10 +2423,10 @@ function link(node, entering) {
24212423
var attrs = this.attrs(node);
24222424
if (entering) {
24232425
if (!(this.options.safe && potentiallyUnsafe(node.destination))) {
2424-
attrs.push(['href', this.esc(node.destination, false)]);
2426+
attrs.push(['href', this.esc(node.destination)]);
24252427
}
24262428
if (node.title) {
2427-
attrs.push(['title', this.esc(node.title, false)]);
2429+
attrs.push(['title', this.esc(node.title)]);
24282430
}
24292431
this.tag('a', attrs);
24302432
} else {
@@ -2438,7 +2440,7 @@ function image(node, entering) {
24382440
if (this.options.safe && potentiallyUnsafe(node.destination)) {
24392441
this.lit('<img src="" alt="');
24402442
} else {
2441-
this.lit('<img src="' + this.esc(node.destination, false) +
2443+
this.lit('<img src="' + this.esc(node.destination) +
24422444
'" alt="');
24432445
}
24442446
}
@@ -2447,7 +2449,7 @@ function image(node, entering) {
24472449
this.disableTags -= 1;
24482450
if (this.disableTags === 0) {
24492451
if (node.title) {
2450-
this.lit('" title="' + this.esc(node.title, false));
2452+
this.lit('" title="' + this.esc(node.title));
24512453
}
24522454
this.lit('" />');
24532455
}
@@ -2502,7 +2504,7 @@ function code_block(node) {
25022504
var info_words = node.info ? node.info.split(/\s+/) : []
25032505
, attrs = this.attrs(node);
25042506
if (info_words.length > 0 && info_words[0].length > 0) {
2505-
attrs.push(['class', 'language-' + this.esc(info_words[0], false)]);
2507+
attrs.push(['class', 'language-' + this.esc(info_words[0])]);
25062508
}
25072509
this.cr();
25082510
this.tag('pre');
@@ -2601,7 +2603,7 @@ function custom_block(node, entering) {
26012603
/* Helper methods */
26022604

26032605
function out(s) {
2604-
this.lit(this.esc(s, false));
2606+
this.lit(this.esc(s));
26052607
}
26062608

26072609
function attrs (node) {
@@ -3134,130 +3136,6 @@ module.exports={"amp":"&","apos":"'","gt":">","lt":"<","quot":"\""}
31343136
'use strict';
31353137

31363138

3137-
/* eslint-disable no-bitwise */
3138-
3139-
var decodeCache = {};
3140-
3141-
function getDecodeCache(exclude) {
3142-
var i, ch, cache = decodeCache[exclude];
3143-
if (cache) { return cache; }
3144-
3145-
cache = decodeCache[exclude] = [];
3146-
3147-
for (i = 0; i < 128; i++) {
3148-
ch = String.fromCharCode(i);
3149-
cache.push(ch);
3150-
}
3151-
3152-
for (i = 0; i < exclude.length; i++) {
3153-
ch = exclude.charCodeAt(i);
3154-
cache[ch] = '%' + ('0' + ch.toString(16).toUpperCase()).slice(-2);
3155-
}
3156-
3157-
return cache;
3158-
}
3159-
3160-
3161-
// Decode percent-encoded string.
3162-
//
3163-
function decode(string, exclude) {
3164-
var cache;
3165-
3166-
if (typeof exclude !== 'string') {
3167-
exclude = decode.defaultChars;
3168-
}
3169-
3170-
cache = getDecodeCache(exclude);
3171-
3172-
return string.replace(/(%[a-f0-9]{2})+/gi, function(seq) {
3173-
var i, l, b1, b2, b3, b4, chr,
3174-
result = '';
3175-
3176-
for (i = 0, l = seq.length; i < l; i += 3) {
3177-
b1 = parseInt(seq.slice(i + 1, i + 3), 16);
3178-
3179-
if (b1 < 0x80) {
3180-
result += cache[b1];
3181-
continue;
3182-
}
3183-
3184-
if ((b1 & 0xE0) === 0xC0 && (i + 3 < l)) {
3185-
// 110xxxxx 10xxxxxx
3186-
b2 = parseInt(seq.slice(i + 4, i + 6), 16);
3187-
3188-
if ((b2 & 0xC0) === 0x80) {
3189-
chr = ((b1 << 6) & 0x7C0) | (b2 & 0x3F);
3190-
3191-
if (chr < 0x80) {
3192-
result += '\ufffd\ufffd';
3193-
} else {
3194-
result += String.fromCharCode(chr);
3195-
}
3196-
3197-
i += 3;
3198-
continue;
3199-
}
3200-
}
3201-
3202-
if ((b1 & 0xF0) === 0xE0 && (i + 6 < l)) {
3203-
// 1110xxxx 10xxxxxx 10xxxxxx
3204-
b2 = parseInt(seq.slice(i + 4, i + 6), 16);
3205-
b3 = parseInt(seq.slice(i + 7, i + 9), 16);
3206-
3207-
if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
3208-
chr = ((b1 << 12) & 0xF000) | ((b2 << 6) & 0xFC0) | (b3 & 0x3F);
3209-
3210-
if (chr < 0x800 || (chr >= 0xD800 && chr <= 0xDFFF)) {
3211-
result += '\ufffd\ufffd\ufffd';
3212-
} else {
3213-
result += String.fromCharCode(chr);
3214-
}
3215-
3216-
i += 6;
3217-
continue;
3218-
}
3219-
}
3220-
3221-
if ((b1 & 0xF8) === 0xF0 && (i + 9 < l)) {
3222-
// 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
3223-
b2 = parseInt(seq.slice(i + 4, i + 6), 16);
3224-
b3 = parseInt(seq.slice(i + 7, i + 9), 16);
3225-
b4 = parseInt(seq.slice(i + 10, i + 12), 16);
3226-
3227-
if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80 && (b4 & 0xC0) === 0x80) {
3228-
chr = ((b1 << 18) & 0x1C0000) | ((b2 << 12) & 0x3F000) | ((b3 << 6) & 0xFC0) | (b4 & 0x3F);
3229-
3230-
if (chr < 0x10000 || chr > 0x10FFFF) {
3231-
result += '\ufffd\ufffd\ufffd\ufffd';
3232-
} else {
3233-
chr -= 0x10000;
3234-
result += String.fromCharCode(0xD800 + (chr >> 10), 0xDC00 + (chr & 0x3FF));
3235-
}
3236-
3237-
i += 9;
3238-
continue;
3239-
}
3240-
}
3241-
3242-
result += '\ufffd';
3243-
}
3244-
3245-
return result;
3246-
});
3247-
}
3248-
3249-
3250-
decode.defaultChars = ';/?:@&=+$,#';
3251-
decode.componentChars = '';
3252-
3253-
3254-
module.exports = decode;
3255-
3256-
},{}],20:[function(require,module,exports){
3257-
3258-
'use strict';
3259-
3260-
32613139
var encodeCache = {};
32623140

32633141

@@ -3353,7 +3231,7 @@ encode.componentChars = "-_.!~*'()";
33533231

33543232
module.exports = encode;
33553233

3356-
},{}],21:[function(require,module,exports){
3234+
},{}],20:[function(require,module,exports){
33573235
/*! http://mths.be/repeat v0.2.0 by @mathias */
33583236
if (!String.prototype.repeat) {
33593237
(function() {

dist/commonmark.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)