Skip to content

Commit 17c9e91

Browse files
committed
Update dingus to commonmark.js 0.29.1.
1 parent 86cb592 commit 17c9e91

File tree

2 files changed

+41
-164
lines changed

2 files changed

+41
-164
lines changed

dingus/commonmark.js

Lines changed: 41 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var reHtmlBlockOpen = [
2424
/^<[?]/,
2525
/^<![A-Z]/,
2626
/^<!\[CDATA\[/,
27-
/^<[/]?(?: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,
27+
/^<[/]?(?: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,
2828
new RegExp('^(?:' + OPENTAG + '|' + CLOSETAG + ')\\s*$', 'i')
2929
];
3030

@@ -326,6 +326,7 @@ var blocks = {
326326
ln.slice(parser.nextNonspace).match(reClosingCodeFence));
327327
if (match && match[0].length >= container._fenceLength) {
328328
// closing fence - we're at end of line, so we can return
329+
parser.lastLineLength = match[0].length;
329330
parser.finalize(container, parser.lineNumber);
330331
return 2;
331332
} else {
@@ -674,7 +675,6 @@ var incorporateLine = function(ln) {
674675
all_matched = false;
675676
break;
676677
case 2: // we've hit end of line for fenced code close and can return
677-
this.lastLineLength = ln.length;
678678
return;
679679
default:
680680
throw 'continue returned illegal value, must be 0, 1, or 2';
@@ -770,6 +770,7 @@ var incorporateLine = function(ln) {
770770
container._htmlBlockType >= 1 &&
771771
container._htmlBlockType <= 5 &&
772772
reHtmlBlockClose[container._htmlBlockType].test(this.currentLine.slice(this.offset))) {
773+
this.lastLineLength = ln.length;
773774
this.finalize(container, this.lineNumber);
774775
}
775776

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

898899
var encode = require('mdurl/encode');
899-
var decode = require('mdurl/decode');
900900

901901
var C_BACKSLASH = 92;
902902

@@ -951,7 +951,7 @@ var unescapeString = function(s) {
951951

952952
var normalizeURI = function(uri) {
953953
try {
954-
return encode(decode(uri));
954+
return encode(uri);
955955
}
956956
catch(err) {
957957
return uri;
@@ -991,7 +991,7 @@ module.exports = { unescapeString: unescapeString,
991991
ESCAPABLE: ESCAPABLE
992992
};
993993

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

997997
// derived from https://github.com/mathiasbynens/String.fromCodePoint
@@ -1068,10 +1068,11 @@ if (String.fromCodePoint) {
10681068

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

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

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

1113-
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]/);
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]/);
11141115

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

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

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

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

13801379
// Add entry to stack for this opener
1381-
this.delimiters = { cc: cc,
1382-
numdelims: numdelims,
1383-
origdelims: numdelims,
1384-
node: node,
1385-
previous: this.delimiters,
1386-
next: null,
1387-
can_open: res.can_open,
1388-
can_close: res.can_close };
1389-
if (this.delimiters.previous !== null) {
1380+
if ((res.can_open || res.can_close) &&
1381+
(this.options.smart || cc !== C_SINGLEQUOTE || cc !== C_DOUBLEQUOTE)){
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) {
13901391
this.delimiters.previous.next = this.delimiters;
1392+
}
13911393
}
13921394

13931395
return true;
@@ -1420,14 +1422,15 @@ var processEmphasis = function(stack_bottom) {
14201422
var use_delims;
14211423
var tmp, next;
14221424
var opener_found;
1423-
var openers_bottom = [];
1425+
var openers_bottom = [[],[],[]];
14241426
var odd_match = false;
14251427

1426-
openers_bottom[C_UNDERSCORE] = stack_bottom;
1427-
openers_bottom[C_ASTERISK] = stack_bottom;
1428-
openers_bottom[C_SINGLEQUOTE] = stack_bottom;
1429-
openers_bottom[C_DOUBLEQUOTE] = stack_bottom;
1430-
1428+
for (var i=0; i < 3; i++) {
1429+
openers_bottom[i][C_UNDERSCORE] = stack_bottom;
1430+
openers_bottom[i][C_ASTERISK] = stack_bottom;
1431+
openers_bottom[i][C_SINGLEQUOTE] = stack_bottom;
1432+
openers_bottom[i][C_DOUBLEQUOTE] = stack_bottom;
1433+
}
14311434
// find first closer above stack_bottom:
14321435
closer = this.delimiters;
14331436
while (closer !== null && closer.previous !== stack_bottom) {
@@ -1443,7 +1446,7 @@ var processEmphasis = function(stack_bottom) {
14431446
opener = closer.previous;
14441447
opener_found = false;
14451448
while (opener !== null && opener !== stack_bottom &&
1446-
opener !== openers_bottom[closercc]) {
1449+
opener !== openers_bottom[closer.origdelims % 3][closercc]) {
14471450
odd_match = (closer.can_open || opener.can_close) &&
14481451
closer.origdelims % 3 !== 0 &&
14491452
(opener.origdelims + closer.origdelims) % 3 === 0;
@@ -1522,13 +1525,9 @@ var processEmphasis = function(stack_bottom) {
15221525
closer = closer.next;
15231526

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

20382040
module.exports = InlineParser;
20392041

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

20432045
function isContainer(node) {
@@ -2420,10 +2422,10 @@ function link(node, entering) {
24202422
var attrs = this.attrs(node);
24212423
if (entering) {
24222424
if (!(this.options.safe && potentiallyUnsafe(node.destination))) {
2423-
attrs.push(['href', this.esc(node.destination, false)]);
2425+
attrs.push(['href', this.esc(node.destination)]);
24242426
}
24252427
if (node.title) {
2426-
attrs.push(['title', this.esc(node.title, false)]);
2428+
attrs.push(['title', this.esc(node.title)]);
24272429
}
24282430
this.tag('a', attrs);
24292431
} else {
@@ -2437,7 +2439,7 @@ function image(node, entering) {
24372439
if (this.options.safe && potentiallyUnsafe(node.destination)) {
24382440
this.lit('<img src="" alt="');
24392441
} else {
2440-
this.lit('<img src="' + this.esc(node.destination, false) +
2442+
this.lit('<img src="' + this.esc(node.destination) +
24412443
'" alt="');
24422444
}
24432445
}
@@ -2446,7 +2448,7 @@ function image(node, entering) {
24462448
this.disableTags -= 1;
24472449
if (this.disableTags === 0) {
24482450
if (node.title) {
2449-
this.lit('" title="' + this.esc(node.title, false));
2451+
this.lit('" title="' + this.esc(node.title));
24502452
}
24512453
this.lit('" />');
24522454
}
@@ -2501,7 +2503,7 @@ function code_block(node) {
25012503
var info_words = node.info ? node.info.split(/\s+/) : []
25022504
, attrs = this.attrs(node);
25032505
if (info_words.length > 0 && info_words[0].length > 0) {
2504-
attrs.push(['class', 'language-' + this.esc(info_words[0], false)]);
2506+
attrs.push(['class', 'language-' + this.esc(info_words[0])]);
25052507
}
25062508
this.cr();
25072509
this.tag('pre');
@@ -2600,7 +2602,7 @@ function custom_block(node, entering) {
26002602
/* Helper methods */
26012603

26022604
function out(s) {
2603-
this.lit(this.esc(s, false));
2605+
this.lit(this.esc(s));
26042606
}
26052607

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

31353137

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

32623140

@@ -3352,7 +3230,7 @@ encode.componentChars = "-_.!~*'()";
33523230

33533231
module.exports = encode;
33543232

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

dingus/dingus.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ var syncScroll = function() {
4646
var elt = preview.find("*[data-sourcepos^='" + lineNumber + ":']").last();
4747
if (elt.length > 0) {
4848
if (elt.offset()) {
49-
console.log("Moving scrollTop to ", elt.offset().top - 100);
5049
preview.animate({
5150
scrollTop: elt.offset().top - 100
5251
}, 50);

0 commit comments

Comments
 (0)