|
@ -1,4 +1,4 @@ |
|
|
/* remarkable 1.0.0 https://github.com//jonschlinkert/remarkable */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Remarkable=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"./":[function(require,module,exports){ |
|
|
/*! remarkable 1.1.0 https://github.com//jonschlinkert/remarkable @license MIT */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Remarkable=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"./":[function(require,module,exports){ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2146,8 +2146,9 @@ module.exports = { |
|
|
|
|
|
|
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
var html_blocks = {}; |
|
|
|
|
|
|
|
|
module.exports = [ |
|
|
[ |
|
|
'article', |
|
|
'article', |
|
|
'aside', |
|
|
'aside', |
|
|
'button', |
|
|
'button', |
|
@ -2198,7 +2199,10 @@ module.exports = [ |
|
|
'thead', |
|
|
'thead', |
|
|
'ul', |
|
|
'ul', |
|
|
'video' |
|
|
'video' |
|
|
]; |
|
|
].forEach(function (name) { html_blocks[name] = true; }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = html_blocks; |
|
|
|
|
|
|
|
|
},{}],3:[function(require,module,exports){ |
|
|
},{}],3:[function(require,module,exports){ |
|
|
// Regexps to match html elements
|
|
|
// Regexps to match html elements
|
|
@ -2691,11 +2695,11 @@ Remarkable.prototype.use = function (plugin, opts) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Main method that does all magic :)
|
|
|
// Parse input string, returns tokens array. Modify `env` with
|
|
|
|
|
|
// definitions data.
|
|
|
//
|
|
|
//
|
|
|
Remarkable.prototype.render = function (src) { |
|
|
Remarkable.prototype.parse = function (src, env) { |
|
|
var tokens, tok, i, l, env = { references: Object.create(null) }; |
|
|
var tokens, tok, i, l; |
|
|
|
|
|
|
|
|
// Parse blocks
|
|
|
// Parse blocks
|
|
|
tokens = this.block.parse(src, this.options, env); |
|
|
tokens = this.block.parse(src, this.options, env); |
|
|
|
|
|
|
|
@ -2707,8 +2711,15 @@ Remarkable.prototype.render = function (src) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Render
|
|
|
return tokens; |
|
|
return this.renderer.render(tokens, this.options, env); |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Main method that does all magic :)
|
|
|
|
|
|
//
|
|
|
|
|
|
Remarkable.prototype.render = function (src) { |
|
|
|
|
|
var env = { references: {} }; |
|
|
|
|
|
|
|
|
|
|
|
return this.renderer.render(this.parse(src, env), this.options, env); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2957,8 +2968,9 @@ ParserBlock.prototype.tokenize = function (state, startLine, endLine) { |
|
|
state.line = line = state.skipEmptyLines(line); |
|
|
state.line = line = state.skipEmptyLines(line); |
|
|
if (line >= endLine) { break; } |
|
|
if (line >= endLine) { break; } |
|
|
|
|
|
|
|
|
|
|
|
// Termination condition for nested calls.
|
|
|
|
|
|
// Nested calls currently used for blockquotes & lists
|
|
|
if (state.tShift[line] < state.blkIndent) { break; } |
|
|
if (state.tShift[line] < state.blkIndent) { break; } |
|
|
if (state.bqMarks[line] < state.bqLevel) { break; } |
|
|
|
|
|
|
|
|
|
|
|
// Try all possible rules.
|
|
|
// Try all possible rules.
|
|
|
// On success, rule should:
|
|
|
// On success, rule should:
|
|
@ -2994,7 +3006,7 @@ ParserBlock.prototype.tokenize = function (state, startLine, endLine) { |
|
|
line++; |
|
|
line++; |
|
|
|
|
|
|
|
|
// two empty lines should stop the parser in list mode
|
|
|
// two empty lines should stop the parser in list mode
|
|
|
if (line < endLine && state.listMode && state.isEmpty(line)) { break; } |
|
|
if (line < endLine && state.parentType === 'list' && state.isEmpty(line)) { break; } |
|
|
state.line = line; |
|
|
state.line = line; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -3240,7 +3252,7 @@ module.exports = function parse_reference(str, parser, options, env) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ensure that the end of the line is empty
|
|
|
// ensure that the end of the line is empty
|
|
|
pos = state.skipSpaces(pos); |
|
|
while (pos < max && state.src.charCodeAt(pos) === 0x20/* space */) { pos++; } |
|
|
if (pos < max && state.src.charCodeAt(pos) !== 0x0A) { return -1; } |
|
|
if (pos < max && state.src.charCodeAt(pos) !== 0x0A) { return -1; } |
|
|
|
|
|
|
|
|
label = normalizeReference(str.slice(1, labelEnd)); |
|
|
label = normalizeReference(str.slice(1, labelEnd)); |
|
@ -3480,6 +3492,17 @@ function Renderer() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Renderer.prototype.renderInline = function (tokens, options) { |
|
|
|
|
|
var result = ''; |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0, len = tokens.length; i < len; i++) { |
|
|
|
|
|
result += rules[tokens[i].type](tokens, i, options); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Renderer.prototype.render = function (tokens, options) { |
|
|
Renderer.prototype.render = function (tokens, options) { |
|
|
var i, len, name, |
|
|
var i, len, name, |
|
|
result = '', |
|
|
result = '', |
|
@ -3524,7 +3547,7 @@ Renderer.prototype.render = function (tokens, options) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (tokens[i].type === 'inline') { |
|
|
if (tokens[i].type === 'inline') { |
|
|
result += this.render(tokens[i].children, options); |
|
|
result += this.renderInline(tokens[i].children, options); |
|
|
} else { |
|
|
} else { |
|
|
result += rules[name](tokens, i, options); |
|
|
result += rules[name](tokens, i, options); |
|
|
} |
|
|
} |
|
@ -3757,7 +3780,7 @@ module.exports = Ruler; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
var nextLine, lastLineEmpty, oldTShift, oldBMarks, oldIndent, oldListMode, |
|
|
var nextLine, lastLineEmpty, oldTShift, oldBMarks, oldIndent, oldParentType, lines, |
|
|
terminatorRules = state.parser._rulesBlockquoteTerm, i, l, terminate, |
|
|
terminatorRules = state.parser._rulesBlockquoteTerm, i, l, terminate, |
|
|
pos = state.bMarks[startLine] + state.tShift[startLine], |
|
|
pos = state.bMarks[startLine] + state.tShift[startLine], |
|
|
max = state.eMarks[startLine]; |
|
|
max = state.eMarks[startLine]; |
|
@ -3776,8 +3799,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
// skip one optional space after '>'
|
|
|
// skip one optional space after '>'
|
|
|
if (state.src.charCodeAt(pos) === 0x20) { pos++; } |
|
|
if (state.src.charCodeAt(pos) === 0x20) { pos++; } |
|
|
|
|
|
|
|
|
state.bqMarks[startLine]++; |
|
|
|
|
|
state.bqLevel++; |
|
|
|
|
|
oldIndent = state.blkIndent; |
|
|
oldIndent = state.blkIndent; |
|
|
state.blkIndent = 0; |
|
|
state.blkIndent = 0; |
|
|
|
|
|
|
|
@ -3819,7 +3840,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (state.src.charCodeAt(pos++) === 0x3E/* > */) { |
|
|
if (state.src.charCodeAt(pos++) === 0x3E/* > */) { |
|
|
state.bqMarks[nextLine]++; |
|
|
|
|
|
// This line is inside the blockquote.
|
|
|
// This line is inside the blockquote.
|
|
|
|
|
|
|
|
|
// skip one optional space after '>'
|
|
|
// skip one optional space after '>'
|
|
@ -3851,14 +3871,28 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
|
|
|
|
|
|
oldBMarks.push(state.bMarks[nextLine]); |
|
|
oldBMarks.push(state.bMarks[nextLine]); |
|
|
oldTShift.push(state.tShift[nextLine]); |
|
|
oldTShift.push(state.tShift[nextLine]); |
|
|
|
|
|
|
|
|
|
|
|
// A negative number means that this is a paragraph continuation;
|
|
|
|
|
|
//
|
|
|
|
|
|
// Any negative number will do the job here, but it's better for it
|
|
|
|
|
|
// to be large enough to make any bugs obvious.
|
|
|
|
|
|
state.tShift[nextLine] = -1337; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
oldListMode = state.listMode; |
|
|
oldParentType = state.parentType; |
|
|
state.listMode = false; |
|
|
state.parentType = 'blockquote'; |
|
|
state.tokens.push({ type: 'blockquote_open', level: state.level++ }); |
|
|
state.tokens.push({ |
|
|
|
|
|
type: 'blockquote_open', |
|
|
|
|
|
lines: lines = [ startLine, 0 ], |
|
|
|
|
|
level: state.level++ |
|
|
|
|
|
}); |
|
|
state.parser.tokenize(state, startLine, nextLine); |
|
|
state.parser.tokenize(state, startLine, nextLine); |
|
|
state.tokens.push({ type: 'blockquote_close', level: --state.level }); |
|
|
state.tokens.push({ |
|
|
state.listMode = oldListMode; |
|
|
type: 'blockquote_close', |
|
|
|
|
|
level: --state.level |
|
|
|
|
|
}); |
|
|
|
|
|
state.parentType = oldParentType; |
|
|
|
|
|
lines[1] = state.lines; |
|
|
|
|
|
|
|
|
// Restore original tShift; this might not be necessary since the parser
|
|
|
// Restore original tShift; this might not be necessary since the parser
|
|
|
// has already been here, but just to make sure we can do that.
|
|
|
// has already been here, but just to make sure we can do that.
|
|
@ -3866,7 +3900,6 @@ module.exports = function blockquote(state, startLine, endLine, silent) { |
|
|
state.bMarks[i + startLine] = oldBMarks[i]; |
|
|
state.bMarks[i + startLine] = oldBMarks[i]; |
|
|
state.tShift[i + startLine] = oldTShift[i]; |
|
|
state.tShift[i + startLine] = oldTShift[i]; |
|
|
} |
|
|
} |
|
|
state.bqLevel--; |
|
|
|
|
|
state.blkIndent = oldIndent; |
|
|
state.blkIndent = oldIndent; |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
@ -3886,7 +3919,6 @@ module.exports = function code(state, startLine, endLine, silent) { |
|
|
last = nextLine = startLine + 1; |
|
|
last = nextLine = startLine + 1; |
|
|
|
|
|
|
|
|
while (nextLine < endLine) { |
|
|
while (nextLine < endLine) { |
|
|
if (state.bqMarks[nextLine] < state.bqLevel) { break; } |
|
|
|
|
|
if (state.isEmpty(nextLine)) { |
|
|
if (state.isEmpty(nextLine)) { |
|
|
nextLine++; |
|
|
nextLine++; |
|
|
continue; |
|
|
continue; |
|
@ -3901,14 +3933,15 @@ module.exports = function code(state, startLine, endLine, silent) { |
|
|
|
|
|
|
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
|
|
|
|
state.line = nextLine; |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'code', |
|
|
type: 'code', |
|
|
content: state.getLines(startLine, last, 4 + state.blkIndent, true), |
|
|
content: state.getLines(startLine, last, 4 + state.blkIndent, true), |
|
|
block: true, |
|
|
block: true, |
|
|
|
|
|
lines: [ startLine, state.line ], |
|
|
level: state.level |
|
|
level: state.level |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
state.line = nextLine; |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -3967,7 +4000,6 @@ module.exports = function fences(state, startLine, endLine, silent) { |
|
|
// test
|
|
|
// test
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
if (pos < max && state.bqMarks[nextLine] < state.bqLevel) { break; } |
|
|
|
|
|
|
|
|
|
|
|
if (state.src.charCodeAt(pos) !== marker) { continue; } |
|
|
if (state.src.charCodeAt(pos) !== marker) { continue; } |
|
|
|
|
|
|
|
@ -3989,14 +4021,15 @@ module.exports = function fences(state, startLine, endLine, silent) { |
|
|
// If a fence has heading spaces, they should be removed from its inner block
|
|
|
// If a fence has heading spaces, they should be removed from its inner block
|
|
|
len = state.tShift[startLine]; |
|
|
len = state.tShift[startLine]; |
|
|
|
|
|
|
|
|
|
|
|
state.line = nextLine + (haveEndMarker ? 1 : 0); |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'fence', |
|
|
type: 'fence', |
|
|
params: params, |
|
|
params: params, |
|
|
content: state.getLines(startLine + 1, nextLine, len, true), |
|
|
content: state.getLines(startLine + 1, nextLine, len, true), |
|
|
|
|
|
lines: [ startLine, state.line ], |
|
|
level: state.level |
|
|
level: state.level |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
state.line = nextLine + (haveEndMarker ? 1 : 0); |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -4048,18 +4081,26 @@ module.exports = function heading(state, startLine, endLine, silent) { |
|
|
|
|
|
|
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'heading_open', hLevel: level, level: state.level }); |
|
|
state.line = startLine + 1; |
|
|
|
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'heading_open', |
|
|
|
|
|
hLevel: level, |
|
|
|
|
|
lines: [ startLine, state.line ], |
|
|
|
|
|
level: state.level |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// only if header is not empty
|
|
|
// only if header is not empty
|
|
|
if (pos < max) { |
|
|
if (pos < max) { |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'inline', |
|
|
type: 'inline', |
|
|
content: state.src.slice(pos, max).trim(), |
|
|
content: state.src.slice(pos, max).trim(), |
|
|
level: state.level + 1 |
|
|
level: state.level + 1, |
|
|
|
|
|
lines: [ startLine, state.line ], |
|
|
|
|
|
children: [] |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
state.tokens.push({ type: 'heading_close', hLevel: level, level: state.level }); |
|
|
state.tokens.push({ type: 'heading_close', hLevel: level, level: state.level }); |
|
|
|
|
|
|
|
|
state.line = startLine + 1; |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -4100,9 +4141,13 @@ module.exports = function hr(state, startLine, endLine, silent) { |
|
|
|
|
|
|
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'hr', level: state.level }); |
|
|
|
|
|
|
|
|
|
|
|
state.line = startLine + 1; |
|
|
state.line = startLine + 1; |
|
|
|
|
|
state.tokens.push({ |
|
|
|
|
|
type: 'hr', |
|
|
|
|
|
lines: [ startLine, state.line ], |
|
|
|
|
|
level: state.level |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -4157,7 +4202,7 @@ module.exports = function htmlblock(state, startLine, endLine, silent) { |
|
|
if (!match) { return false; } |
|
|
if (!match) { return false; } |
|
|
} |
|
|
} |
|
|
// Make sure tag name is valid
|
|
|
// Make sure tag name is valid
|
|
|
if (block_names.indexOf(match[1].toLowerCase()) < 0) { return false; } |
|
|
if (block_names[match[1].toLowerCase()] !== true) { return false; } |
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
@ -4171,13 +4216,14 @@ module.exports = function htmlblock(state, startLine, endLine, silent) { |
|
|
nextLine++; |
|
|
nextLine++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
state.line = nextLine; |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'htmlblock', |
|
|
type: 'htmlblock', |
|
|
level: state.level, |
|
|
level: state.level, |
|
|
|
|
|
lines: [ startLine, state.line ], |
|
|
content: state.getLines(startLine, nextLine, 0, true) |
|
|
content: state.getLines(startLine, nextLine, 0, true) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
state.line = nextLine; |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -4193,14 +4239,16 @@ module.exports = function lheading(state, startLine, endLine, silent) { |
|
|
|
|
|
|
|
|
if (next >= endLine) { return false; } |
|
|
if (next >= endLine) { return false; } |
|
|
if (state.tShift[next] < state.blkIndent) { return false; } |
|
|
if (state.tShift[next] < state.blkIndent) { return false; } |
|
|
if (state.bqMarks[next] < state.bqLevel) { return false; } |
|
|
|
|
|
|
|
|
|
|
|
// Scan next line
|
|
|
// Scan next line
|
|
|
|
|
|
|
|
|
if (state.tShift[next] - state.blkIndent > 3) { return false; } |
|
|
if (state.tShift[next] - state.blkIndent > 3) { return false; } |
|
|
|
|
|
|
|
|
pos = state.bMarks[next] + state.tShift[next]; |
|
|
pos = state.bMarks[next] + state.tShift[next]; |
|
|
max = state.eMarks[next]; |
|
|
max = state.eMarks[next]; |
|
|
|
|
|
|
|
|
|
|
|
if (pos >= max) { return false; } |
|
|
|
|
|
|
|
|
marker = state.src.charCodeAt(pos); |
|
|
marker = state.src.charCodeAt(pos); |
|
|
|
|
|
|
|
|
if (marker !== 0x2D/* - */ && marker !== 0x3D/* = */) { return false; } |
|
|
if (marker !== 0x2D/* - */ && marker !== 0x3D/* = */) { return false; } |
|
@ -4215,15 +4263,19 @@ module.exports = function lheading(state, startLine, endLine, silent) { |
|
|
|
|
|
|
|
|
pos = state.bMarks[startLine] + state.tShift[startLine]; |
|
|
pos = state.bMarks[startLine] + state.tShift[startLine]; |
|
|
|
|
|
|
|
|
|
|
|
state.line = next + 1; |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'heading_open', |
|
|
type: 'heading_open', |
|
|
hLevel: marker === 0x3D/* = */ ? 1 : 2, |
|
|
hLevel: marker === 0x3D/* = */ ? 1 : 2, |
|
|
|
|
|
lines: [ startLine, state.line ], |
|
|
level: state.level |
|
|
level: state.level |
|
|
}); |
|
|
}); |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'inline', |
|
|
type: 'inline', |
|
|
content: state.src.slice(pos, state.eMarks[startLine]).trim(), |
|
|
content: state.src.slice(pos, state.eMarks[startLine]).trim(), |
|
|
level: state.level + 1 |
|
|
level: state.level + 1, |
|
|
|
|
|
lines: [ startLine, state.line - 1 ], |
|
|
|
|
|
children: [] |
|
|
}); |
|
|
}); |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'heading_close', |
|
|
type: 'heading_close', |
|
@ -4231,7 +4283,6 @@ module.exports = function lheading(state, startLine, endLine, silent) { |
|
|
level: state.level |
|
|
level: state.level |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
state.line = next + 1; |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -4313,7 +4364,7 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
oldTShift, |
|
|
oldTShift, |
|
|
oldIndent, |
|
|
oldIndent, |
|
|
oldTight, |
|
|
oldTight, |
|
|
oldListMode, |
|
|
oldParentType, |
|
|
start, |
|
|
start, |
|
|
posAfterMarker, |
|
|
posAfterMarker, |
|
|
max, |
|
|
max, |
|
@ -4324,6 +4375,8 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
contentStart, |
|
|
contentStart, |
|
|
listTokIdx, |
|
|
listTokIdx, |
|
|
prevEmptyEnd, |
|
|
prevEmptyEnd, |
|
|
|
|
|
listLines, |
|
|
|
|
|
itemLines, |
|
|
terminatorRules = state.parser._rulesListTerm, i, l, terminate; |
|
|
terminatorRules = state.parser._rulesListTerm, i, l, terminate; |
|
|
|
|
|
|
|
|
// Detect list type and position after marker
|
|
|
// Detect list type and position after marker
|
|
@ -4354,6 +4407,7 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
type: 'ordered_list_open', |
|
|
type: 'ordered_list_open', |
|
|
order: markerValue, |
|
|
order: markerValue, |
|
|
tight: true, |
|
|
tight: true, |
|
|
|
|
|
lines: listLines = [ startLine, 0 ], |
|
|
level: state.level++ |
|
|
level: state.level++ |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -4361,6 +4415,7 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'bullet_list_open', |
|
|
type: 'bullet_list_open', |
|
|
tight: true, |
|
|
tight: true, |
|
|
|
|
|
lines: listLines = [ startLine, 0 ], |
|
|
level: state.level++ |
|
|
level: state.level++ |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -4396,18 +4451,22 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
indent = (posAfterMarker - state.bMarks[nextLine]) + indentAfterMarker; |
|
|
indent = (posAfterMarker - state.bMarks[nextLine]) + indentAfterMarker; |
|
|
|
|
|
|
|
|
// Run subparser & write tokens
|
|
|
// Run subparser & write tokens
|
|
|
state.tokens.push({ type: 'list_item_open', level: state.level++ }); |
|
|
state.tokens.push({ |
|
|
|
|
|
type: 'list_item_open', |
|
|
|
|
|
lines: itemLines = [ startLine, 0 ], |
|
|
|
|
|
level: state.level++ |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
//nextLine++;
|
|
|
//nextLine++;
|
|
|
|
|
|
|
|
|
oldIndent = state.blkIndent; |
|
|
oldIndent = state.blkIndent; |
|
|
oldTight = state.tight; |
|
|
oldTight = state.tight; |
|
|
oldTShift = state.tShift[startLine]; |
|
|
oldTShift = state.tShift[startLine]; |
|
|
oldListMode = state.listMode; |
|
|
oldParentType = state.parentType; |
|
|
state.tShift[startLine] = contentStart - state.bMarks[startLine]; |
|
|
state.tShift[startLine] = contentStart - state.bMarks[startLine]; |
|
|
state.blkIndent = indent; |
|
|
state.blkIndent = indent; |
|
|
state.tight = true; |
|
|
state.tight = true; |
|
|
state.listMode = true; |
|
|
state.parentType = 'list'; |
|
|
|
|
|
|
|
|
state.parser.tokenize(state, startLine, endLine, true); |
|
|
state.parser.tokenize(state, startLine, endLine, true); |
|
|
|
|
|
|
|
@ -4422,11 +4481,12 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
state.blkIndent = oldIndent; |
|
|
state.blkIndent = oldIndent; |
|
|
state.tShift[startLine] = oldTShift; |
|
|
state.tShift[startLine] = oldTShift; |
|
|
state.tight = oldTight; |
|
|
state.tight = oldTight; |
|
|
state.listMode = oldListMode; |
|
|
state.parentType = oldParentType; |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'list_item_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'list_item_close', level: --state.level }); |
|
|
|
|
|
|
|
|
nextLine = startLine = state.line; |
|
|
nextLine = startLine = state.line; |
|
|
|
|
|
itemLines[1] = nextLine; |
|
|
contentStart = state.bMarks[startLine]; |
|
|
contentStart = state.bMarks[startLine]; |
|
|
|
|
|
|
|
|
if (nextLine >= endLine) { break; } |
|
|
if (nextLine >= endLine) { break; } |
|
@ -4439,7 +4499,6 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
// Try to check if list is terminated or continued.
|
|
|
// Try to check if list is terminated or continued.
|
|
|
//
|
|
|
//
|
|
|
if (state.tShift[nextLine] < state.blkIndent) { break; } |
|
|
if (state.tShift[nextLine] < state.blkIndent) { break; } |
|
|
if (state.bqMarks[nextLine] < state.bqLevel) { break; } |
|
|
|
|
|
|
|
|
|
|
|
// fail if terminating block found
|
|
|
// fail if terminating block found
|
|
|
terminate = false; |
|
|
terminate = false; |
|
@ -4469,6 +4528,7 @@ module.exports = function list(state, startLine, endLine, silent) { |
|
|
} else { |
|
|
} else { |
|
|
state.tokens.push({ type: 'bullet_list_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'bullet_list_close', level: --state.level }); |
|
|
} |
|
|
} |
|
|
|
|
|
listLines[1] = nextLine; |
|
|
|
|
|
|
|
|
state.line = nextLine; |
|
|
state.line = nextLine; |
|
|
return true; |
|
|
return true; |
|
@ -4515,17 +4575,26 @@ module.exports = function paragraph(state, startLine/*, endLine*/) { |
|
|
content = content.slice(pos).trim(); |
|
|
content = content.slice(pos).trim(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
state.line = nextLine; |
|
|
if (content.length) { |
|
|
if (content.length) { |
|
|
state.tokens.push({ type: 'paragraph_open', level: state.level }); |
|
|
state.tokens.push({ |
|
|
|
|
|
type: 'paragraph_open', |
|
|
|
|
|
lines: [ startLine, state.line ], |
|
|
|
|
|
level: state.level |
|
|
|
|
|
}); |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'inline', |
|
|
type: 'inline', |
|
|
content: content, |
|
|
content: content, |
|
|
level: state.level + 1 |
|
|
level: state.level + 1, |
|
|
|
|
|
lines: [ startLine, state.line ], |
|
|
|
|
|
children: [] |
|
|
|
|
|
}); |
|
|
|
|
|
state.tokens.push({ |
|
|
|
|
|
type: 'paragraph_close', |
|
|
|
|
|
level: state.level |
|
|
}); |
|
|
}); |
|
|
state.tokens.push({ type: 'paragraph_close', level: state.level }); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
state.line = nextLine; |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -4535,7 +4604,7 @@ module.exports = function paragraph(state, startLine/*, endLine*/) { |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function State(src, parser, tokens, options, env) { |
|
|
function StateBlock(src, parser, tokens, options, env) { |
|
|
var ch, s, start, pos, len, indent, indent_found; |
|
|
var ch, s, start, pos, len, indent, indent_found; |
|
|
|
|
|
|
|
|
// Prepare string to parse:
|
|
|
// Prepare string to parse:
|
|
@ -4561,15 +4630,14 @@ function State(src, parser, tokens, options, env) { |
|
|
this.bMarks = []; // line begin offsets for fast jumps
|
|
|
this.bMarks = []; // line begin offsets for fast jumps
|
|
|
this.eMarks = []; // line end offsets for fast jumps
|
|
|
this.eMarks = []; // line end offsets for fast jumps
|
|
|
this.tShift = []; // indent for each line
|
|
|
this.tShift = []; // indent for each line
|
|
|
this.bqMarks = []; // lines shifts in blockquotes (calculated on bq enter)
|
|
|
|
|
|
|
|
|
|
|
|
// block parser variables
|
|
|
// block parser variables
|
|
|
this.blkIndent = 0; |
|
|
this.blkIndent = 0; // required block content indent
|
|
|
|
|
|
// (for example, if we are in list)
|
|
|
this.line = 0; // line index in src
|
|
|
this.line = 0; // line index in src
|
|
|
this.lineMax = 0; // lines count
|
|
|
this.lineMax = 0; // lines count
|
|
|
this.tight = false; // loose/tight mode for lists
|
|
|
this.tight = false; // loose/tight mode for lists
|
|
|
this.listMode = false; // if true, block parser stops on two newlines
|
|
|
this.parentType = 'root'; // if `list`, block parser stops on two newlines
|
|
|
this.bqLevel = 0; // blockquote nesting level
|
|
|
|
|
|
|
|
|
|
|
|
this.level = 0; |
|
|
this.level = 0; |
|
|
|
|
|
|
|
@ -4595,20 +4663,15 @@ function State(src, parser, tokens, options, env) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (ch === 0x0A || ch === 0x0D) { |
|
|
if (ch === 0x0A) { |
|
|
this.bMarks.push(start); |
|
|
this.bMarks.push(start); |
|
|
this.eMarks.push(pos); |
|
|
this.eMarks.push(pos); |
|
|
indent_found = false; |
|
|
indent_found = false; |
|
|
indent = 0; |
|
|
indent = 0; |
|
|
start = pos + 1; |
|
|
start = pos + 1; |
|
|
|
|
|
|
|
|
if (ch === 0x0D && pos + 1 < len && s.charCodeAt(pos + 1) === 0x0A) { |
|
|
|
|
|
pos++; |
|
|
|
|
|
start++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (ch !== 0x0D || ch !== 0x0A) { |
|
|
if (ch !== 0x0A) { |
|
|
this.bMarks.push(start); |
|
|
this.bMarks.push(start); |
|
|
this.eMarks.push(len); |
|
|
this.eMarks.push(len); |
|
|
if (!indent_found) { this.tShift.push(indent); } |
|
|
if (!indent_found) { this.tShift.push(indent); } |
|
@ -4620,17 +4683,13 @@ function State(src, parser, tokens, options, env) { |
|
|
this.tShift.push(0); |
|
|
this.tShift.push(0); |
|
|
|
|
|
|
|
|
this.lineMax = this.bMarks.length - 1; // don't count last fake line
|
|
|
this.lineMax = this.bMarks.length - 1; // don't count last fake line
|
|
|
|
|
|
|
|
|
for (start = this.bMarks.length; start > 0; start--) { |
|
|
|
|
|
this.bqMarks.push(0); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
State.prototype.isEmpty = function isEmpty(line) { |
|
|
StateBlock.prototype.isEmpty = function isEmpty(line) { |
|
|
return this.bMarks[line] + this.tShift[line] >= this.eMarks[line]; |
|
|
return this.bMarks[line] + this.tShift[line] >= this.eMarks[line]; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
State.prototype.skipEmptyLines = function skipEmptyLines(from) { |
|
|
StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) { |
|
|
for (var max = this.lineMax; from < max; from++) { |
|
|
for (var max = this.lineMax; from < max; from++) { |
|
|
if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) { |
|
|
if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) { |
|
|
break; |
|
|
break; |
|
@ -4640,7 +4699,7 @@ State.prototype.skipEmptyLines = function skipEmptyLines(from) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// Skip spaces from given position.
|
|
|
// Skip spaces from given position.
|
|
|
State.prototype.skipSpaces = function skipSpaces(pos) { |
|
|
StateBlock.prototype.skipSpaces = function skipSpaces(pos) { |
|
|
for (var max = this.src.length; pos < max; pos++) { |
|
|
for (var max = this.src.length; pos < max; pos++) { |
|
|
if (this.src.charCodeAt(pos) !== 0x20/* space */) { break; } |
|
|
if (this.src.charCodeAt(pos) !== 0x20/* space */) { break; } |
|
|
} |
|
|
} |
|
@ -4648,7 +4707,7 @@ State.prototype.skipSpaces = function skipSpaces(pos) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// Skip char codes from given position
|
|
|
// Skip char codes from given position
|
|
|
State.prototype.skipChars = function skipChars(pos, code) { |
|
|
StateBlock.prototype.skipChars = function skipChars(pos, code) { |
|
|
for (var max = this.src.length; pos < max; pos++) { |
|
|
for (var max = this.src.length; pos < max; pos++) { |
|
|
if (this.src.charCodeAt(pos) !== code) { break; } |
|
|
if (this.src.charCodeAt(pos) !== code) { break; } |
|
|
} |
|
|
} |
|
@ -4656,7 +4715,7 @@ State.prototype.skipChars = function skipChars(pos, code) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// Skip char codes reverse from given position - 1
|
|
|
// Skip char codes reverse from given position - 1
|
|
|
State.prototype.skipCharsBack = function skipCharsBack(pos, code, min) { |
|
|
StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) { |
|
|
if (pos <= min) { return pos; } |
|
|
if (pos <= min) { return pos; } |
|
|
|
|
|
|
|
|
while (pos > min) { |
|
|
while (pos > min) { |
|
@ -4666,8 +4725,8 @@ State.prototype.skipCharsBack = function skipCharsBack(pos, code, min) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// cut lines range from source.
|
|
|
// cut lines range from source.
|
|
|
State.prototype.getLines = function getLines(begin, end, indent, keepLastLF) { |
|
|
StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) { |
|
|
var i, first, last, queue, |
|
|
var i, first, last, queue, shift, |
|
|
line = begin; |
|
|
line = begin; |
|
|
|
|
|
|
|
|
if (begin >= end) { |
|
|
if (begin >= end) { |
|
@ -4684,7 +4743,11 @@ State.prototype.getLines = function getLines(begin, end, indent, keepLastLF) { |
|
|
queue = new Array(end - begin); |
|
|
queue = new Array(end - begin); |
|
|
|
|
|
|
|
|
for (i = 0; line < end; line++, i++) { |
|
|
for (i = 0; line < end; line++, i++) { |
|
|
first = this.bMarks[line] + Math.min(this.tShift[line], indent); |
|
|
shift = this.tShift[line]; |
|
|
|
|
|
if (shift > indent) { shift = indent; } |
|
|
|
|
|
if (shift < 0) { shift = 0; } |
|
|
|
|
|
|
|
|
|
|
|
first = this.bMarks[line] + shift; |
|
|
|
|
|
|
|
|
if (line + 1 < end || keepLastLF) { |
|
|
if (line + 1 < end || keepLastLF) { |
|
|
// No need for bounds check because we have fake entry on tail.
|
|
|
// No need for bounds check because we have fake entry on tail.
|
|
@ -4700,8 +4763,8 @@ State.prototype.getLines = function getLines(begin, end, indent, keepLastLF) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// Create shadow clone of curent state with new input data
|
|
|
// Create shadow clone of curent state with new input data
|
|
|
State.prototype.clone = function clone(src) { |
|
|
StateBlock.prototype.clone = function clone(src) { |
|
|
return new State( |
|
|
return new StateBlock( |
|
|
src, |
|
|
src, |
|
|
this.parser, |
|
|
this.parser, |
|
|
this.tokens, |
|
|
this.tokens, |
|
@ -4709,7 +4772,7 @@ State.prototype.clone = function clone(src) { |
|
|
); |
|
|
); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
module.exports = State; |
|
|
module.exports = StateBlock; |
|
|
|
|
|
|
|
|
},{}],27:[function(require,module,exports){ |
|
|
},{}],27:[function(require,module,exports){ |
|
|
// GFM table, non-standard
|
|
|
// GFM table, non-standard
|
|
@ -4726,18 +4789,22 @@ function lineMatch(state, line, reg) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function table(state, startLine, endLine, silent) { |
|
|
module.exports = function table(state, startLine, endLine, silent) { |
|
|
var ch, firstLineMatch, secondLineMatch, i, nextLine, m, rows, |
|
|
var ch, firstLineMatch, secondLineMatch, pos, i, nextLine, m, rows, |
|
|
aligns, t; |
|
|
aligns, t, tableLines, tbodyLines; |
|
|
|
|
|
|
|
|
// should have at least three lines
|
|
|
// should have at least three lines
|
|
|
if (startLine + 2 > endLine) { return false; } |
|
|
if (startLine + 2 > endLine) { return false; } |
|
|
|
|
|
|
|
|
if (state.tShift[startLine + 1] < state.blkIndent) { return false; } |
|
|
nextLine = startLine + 1; |
|
|
if (state.bqMarks[startLine + 1] < state.bqLevel) { return false; } |
|
|
|
|
|
|
|
|
if (state.tShift[nextLine] < state.blkIndent) { return false; } |
|
|
|
|
|
|
|
|
// first character of the second line should be '|' or '-'
|
|
|
// first character of the second line should be '|' or '-'
|
|
|
ch = state.src.charCodeAt(state.bMarks[startLine + 1] |
|
|
|
|
|
+ state.tShift[startLine + 1]); |
|
|
pos = state.bMarks[nextLine] + state.tShift[nextLine]; |
|
|
|
|
|
if (pos >= state.eMarks[nextLine]) { return false; } |
|
|
|
|
|
|
|
|
|
|
|
ch = state.src.charCodeAt(pos); |
|
|
if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; } |
|
|
if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; } |
|
|
|
|
|
|
|
|
secondLineMatch = lineMatch(state, startLine + 1, |
|
|
secondLineMatch = lineMatch(state, startLine + 1, |
|
@ -4764,26 +4831,49 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
if (aligns.length !== rows.length) { return false; } |
|
|
if (aligns.length !== rows.length) { return false; } |
|
|
if (silent) { return true; } |
|
|
if (silent) { return true; } |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'table_open', level: state.level++ }); |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ type: 'thead_open', level: state.level++ }); |
|
|
type: 'table_open', |
|
|
|
|
|
lines: tableLines = [ startLine, 0 ], |
|
|
|
|
|
level: state.level++ |
|
|
|
|
|
}); |
|
|
|
|
|
state.tokens.push({ |
|
|
|
|
|
type: 'thead_open', |
|
|
|
|
|
lines: [ startLine, startLine + 1 ], |
|
|
|
|
|
level: state.level++ |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
state.tokens.push({ type: 'tr_open', level: state.level++ }); |
|
|
state.tokens.push({ |
|
|
|
|
|
type: 'tr_open', |
|
|
|
|
|
lines: [ startLine, startLine + 1 ], |
|
|
|
|
|
level: state.level++ |
|
|
|
|
|
}); |
|
|
for (i = 0; i < rows.length; i++) { |
|
|
for (i = 0; i < rows.length; i++) { |
|
|
state.tokens.push({ type: 'th_open', align: aligns[i], level: state.level++ }); |
|
|
state.tokens.push({ |
|
|
|
|
|
type: 'th_open', |
|
|
|
|
|
align: aligns[i], |
|
|
|
|
|
lines: [ startLine, startLine + 1 ], |
|
|
|
|
|
level: state.level++ |
|
|
|
|
|
}); |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'inline', |
|
|
type: 'inline', |
|
|
content: rows[i].trim(), |
|
|
content: rows[i].trim(), |
|
|
level: state.level |
|
|
lines: [ startLine, startLine + 1 ], |
|
|
|
|
|
level: state.level, |
|
|
|
|
|
children: [] |
|
|
}); |
|
|
}); |
|
|
state.tokens.push({ type: 'th_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'th_close', level: --state.level }); |
|
|
} |
|
|
} |
|
|
state.tokens.push({ type: 'tr_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'tr_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'thead_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'thead_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'tbody_open', level: state.level++ }); |
|
|
|
|
|
|
|
|
state.tokens.push({ |
|
|
|
|
|
type: 'tbody_open', |
|
|
|
|
|
lines: tbodyLines = [ startLine + 2, 0 ], |
|
|
|
|
|
level: state.level++ |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { |
|
|
for (nextLine = startLine + 2; nextLine < endLine; nextLine++) { |
|
|
if (state.tShift[nextLine] < state.blkIndent) { break; } |
|
|
if (state.tShift[nextLine] < state.blkIndent) { break; } |
|
|
if (state.bqMarks[nextLine] < state.bqLevel) { break; } |
|
|
|
|
|
|
|
|
|
|
|
m = lineMatch(state, nextLine, /^ *\|?(.*?\|.*?)\|? *$/); |
|
|
m = lineMatch(state, nextLine, /^ *\|?(.*?\|.*?)\|? *$/); |
|
|
if (!m) { break; } |
|
|
if (!m) { break; } |
|
@ -4794,7 +4884,9 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
state.tokens.push({ type: 'td_open', align: aligns[i], level: state.level++ }); |
|
|
state.tokens.push({ type: 'td_open', align: aligns[i], level: state.level++ }); |
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'inline', |
|
|
type: 'inline', |
|
|
content: rows[i].replace(/^\|? *| *\|?$/g, '') |
|
|
content: rows[i].replace(/^\|? *| *\|?$/g, ''), |
|
|
|
|
|
level: state.level, |
|
|
|
|
|
children: [] |
|
|
}); |
|
|
}); |
|
|
state.tokens.push({ type: 'td_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'td_close', level: --state.level }); |
|
|
} |
|
|
} |
|
@ -4803,6 +4895,7 @@ module.exports = function table(state, startLine, endLine, silent) { |
|
|
state.tokens.push({ type: 'tbody_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'tbody_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'table_close', level: --state.level }); |
|
|
state.tokens.push({ type: 'table_close', level: --state.level }); |
|
|
|
|
|
|
|
|
|
|
|
tableLines[1] = tbodyLines[1] = nextLine; |
|
|
state.line = nextLine; |
|
|
state.line = nextLine; |
|
|
return true; |
|
|
return true; |
|
|
}; |
|
|
}; |
|
@ -4884,10 +4977,8 @@ module.exports = function autolink(state) { |
|
|
},{"../common/url_schemas":4,"../common/utils":5}],29:[function(require,module,exports){ |
|
|
},{"../common/url_schemas":4,"../common/utils":5}],29:[function(require,module,exports){ |
|
|
// Parse backticks
|
|
|
// Parse backticks
|
|
|
|
|
|
|
|
|
var END_RE = /`+/g; |
|
|
|
|
|
|
|
|
|
|
|
module.exports = function backticks(state) { |
|
|
module.exports = function backticks(state) { |
|
|
var start, code, max, marker, match, |
|
|
var start, max, marker, matchStart, matchEnd, |
|
|
pos = state.pos, |
|
|
pos = state.pos, |
|
|
ch = state.src.charCodeAt(pos); |
|
|
ch = state.src.charCodeAt(pos); |
|
|
|
|
|
|
|
@ -4901,22 +4992,23 @@ module.exports = function backticks(state) { |
|
|
|
|
|
|
|
|
marker = state.src.slice(start, pos); |
|
|
marker = state.src.slice(start, pos); |
|
|
|
|
|
|
|
|
END_RE = /`+/g; |
|
|
matchStart = matchEnd = pos; |
|
|
END_RE.lastIndex = pos; |
|
|
|
|
|
|
|
|
while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) { |
|
|
|
|
|
matchEnd = matchStart + 1; |
|
|
|
|
|
|
|
|
while ((match = END_RE.exec(state.src)) !== null) { |
|
|
while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; } |
|
|
if (match[0].length === marker.length) { |
|
|
|
|
|
code = state.src.slice(pos, END_RE.lastIndex - marker.length); |
|
|
if (matchEnd - matchStart === marker.length) { |
|
|
state.push({ |
|
|
state.push({ |
|
|
type: 'code', |
|
|
type: 'code', |
|
|
content: code |
|
|
content: state.src.slice(pos, matchStart) |
|
|
.replace(/[ \n]+/g,' ') |
|
|
.replace(/[ \n]+/g,' ') |
|
|
.trim(), |
|
|
.trim(), |
|
|
block: false, |
|
|
block: false, |
|
|
level: state.level |
|
|
level: state.level |
|
|
}); |
|
|
}); |
|
|
|
|
|
state.pos = matchEnd; |
|
|
state.pos += marker.length * 2 + code.length; |
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -4944,13 +5036,11 @@ function isAlphaNum(code) { |
|
|
// note: in case if 4+ markers it is still not a valid emphasis,
|
|
|
// note: in case if 4+ markers it is still not a valid emphasis,
|
|
|
// should be treated as a special case
|
|
|
// should be treated as a special case
|
|
|
function parseStart(state, start) { |
|
|
function parseStart(state, start) { |
|
|
var pos = start, lastChar, count, |
|
|
var pos = start, lastChar, nextChar, count, |
|
|
max = state.posMax, |
|
|
max = state.posMax, |
|
|
marker = state.src.charCodeAt(start); |
|
|
marker = state.src.charCodeAt(start); |
|
|
|
|
|
|
|
|
lastChar = state.pending.length !== 0 ? state.pending.charCodeAt(state.pending.length - 1) : -1; |
|
|
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1; |
|
|
|
|
|
|
|
|
if (lastChar === marker) { return -1; } |
|
|
|
|
|
|
|
|
|
|
|
while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; } |
|
|
while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; } |
|
|
if (pos >= max) { return -1; } |
|
|
if (pos >= max) { return -1; } |
|
@ -4971,7 +5061,8 @@ function parseStart(state, start) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// check condition 2, marker followed by whitespace
|
|
|
// check condition 2, marker followed by whitespace
|
|
|
if (state.src.charCodeAt(pos) === 0x20) { return -1; } |
|
|
nextChar = state.src.charCodeAt(pos); |
|
|
|
|
|
if (nextChar === 0x20 || nextChar === 0x0A) { return -1; } |
|
|
|
|
|
|
|
|
if (marker === 0x5F /* _ */) { |
|
|
if (marker === 0x5F /* _ */) { |
|
|
// check condition 3, if it's the beginning of the word
|
|
|
// check condition 3, if it's the beginning of the word
|
|
@ -4992,7 +5083,7 @@ function parseEnd(state, start) { |
|
|
max = state.posMax, |
|
|
max = state.posMax, |
|
|
marker = state.src.charCodeAt(start); |
|
|
marker = state.src.charCodeAt(start); |
|
|
|
|
|
|
|
|
lastChar = state.pending.length !== 0 ? state.pending.charCodeAt(state.pending.length - 1) : -1; |
|
|
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1; |
|
|
|
|
|
|
|
|
while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; } |
|
|
while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; } |
|
|
count = pos - start; |
|
|
count = pos - start; |
|
@ -5011,7 +5102,7 @@ function parseEnd(state, start) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// check condition 2, marker preceded by whitespace
|
|
|
// check condition 2, marker preceded by whitespace
|
|
|
if (lastChar === 0x20) { return -1; } |
|
|
if (lastChar === 0x20 || lastChar === 0x0A) { return -1; } |
|
|
|
|
|
|
|
|
if (marker === 0x5F) { |
|
|
if (marker === 0x5F) { |
|
|
// check condition 3, if it's the end of the word
|
|
|
// check condition 3, if it's the end of the word
|
|
@ -5032,7 +5123,6 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
oldCount, |
|
|
oldCount, |
|
|
newCount, |
|
|
newCount, |
|
|
stack, |
|
|
stack, |
|
|
breakOutOfOuterLoop, |
|
|
|
|
|
max = state.posMax, |
|
|
max = state.posMax, |
|
|
start = state.pos, |
|
|
start = state.pos, |
|
|
haveLiteralAsterisk, |
|
|
haveLiteralAsterisk, |
|
@ -5071,20 +5161,8 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
newCount = count; |
|
|
newCount = count; |
|
|
|
|
|
|
|
|
while (oldCount !== newCount) { |
|
|
while (oldCount !== newCount) { |
|
|
if (oldCount === 3) { |
|
|
|
|
|
// e.g. `***foo*`
|
|
|
|
|
|
stack.push(3 - newCount); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (newCount < oldCount) { |
|
|
if (newCount < oldCount) { |
|
|
// assert(oldCount == 2 && newCount == 1)
|
|
|
stack.push(oldCount - newCount); |
|
|
// i.e. `**foo* bar*`
|
|
|
|
|
|
// not valid for now, but might be in the future
|
|
|
|
|
|
|
|
|
|
|
|
// eslint is misconfigured, so it doesn't accept "break MAIN;"
|
|
|
|
|
|
// here is a crappy workaround
|
|
|
|
|
|
breakOutOfOuterLoop = true; |
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -5096,8 +5174,6 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
oldCount = stack.pop(); |
|
|
oldCount = stack.pop(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (breakOutOfOuterLoop) { break; } |
|
|
|
|
|
|
|
|
|
|
|
if (stack.length === 0) { |
|
|
if (stack.length === 0) { |
|
|
startCount = oldCount; |
|
|
startCount = oldCount; |
|
|
found = true; |
|
|
found = true; |
|
@ -5213,9 +5289,10 @@ module.exports = function entity(state) { |
|
|
},{"../common/entities":1,"../common/utils":5}],32:[function(require,module,exports){ |
|
|
},{"../common/entities":1,"../common/utils":5}],32:[function(require,module,exports){ |
|
|
// Proceess escaped chars and hardbreaks
|
|
|
// Proceess escaped chars and hardbreaks
|
|
|
|
|
|
|
|
|
var ESCAPED = '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-' |
|
|
var ESCAPED = {}; |
|
|
.split('') |
|
|
|
|
|
.map(function(ch) { return ch.charCodeAt(0); }); |
|
|
'\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-' |
|
|
|
|
|
.split('').forEach(function(ch) { ESCAPED[ch.charCodeAt(0)] = true; }); |
|
|
|
|
|
|
|
|
module.exports = function escape(state) { |
|
|
module.exports = function escape(state) { |
|
|
var ch, pos = state.pos, max = state.posMax; |
|
|
var ch, pos = state.pos, max = state.posMax; |
|
@ -5227,7 +5304,7 @@ module.exports = function escape(state) { |
|
|
if (pos < max) { |
|
|
if (pos < max) { |
|
|
ch = state.src.charCodeAt(pos); |
|
|
ch = state.src.charCodeAt(pos); |
|
|
|
|
|
|
|
|
if (ESCAPED.indexOf(ch) >= 0) { |
|
|
if (typeof ESCAPED[ch] !== 'undefined') { |
|
|
// escape html chars if needed
|
|
|
// escape html chars if needed
|
|
|
if (ch === 0x26/* & */) { |
|
|
if (ch === 0x26/* & */) { |
|
|
state.pending += '&'; |
|
|
state.pending += '&'; |
|
@ -5559,24 +5636,23 @@ function StateInline(src, parser, options, env) { |
|
|
this.parser = parser; |
|
|
this.parser = parser; |
|
|
this.tokens = []; |
|
|
this.tokens = []; |
|
|
this.pos = 0; |
|
|
this.pos = 0; |
|
|
this.pending = ''; |
|
|
|
|
|
this.posMax = this.src.length; |
|
|
this.posMax = this.src.length; |
|
|
|
|
|
this.level = 0; |
|
|
|
|
|
this.pending = ''; |
|
|
|
|
|
this.pendingLevel = 0; |
|
|
|
|
|
|
|
|
this.validateInsideEm = false; |
|
|
this.validateInsideEm = false; |
|
|
this.validateInsideLink = false; |
|
|
this.validateInsideLink = false; |
|
|
this.linkLevel = 0; |
|
|
this.linkLevel = 0; |
|
|
this.level = 0; |
|
|
|
|
|
this.link_content = ''; |
|
|
this.link_content = ''; |
|
|
this.pendingLevel = 0; |
|
|
|
|
|
this.label_nest_level = 0; // for stmd-like backtrack optimization
|
|
|
this.label_nest_level = 0; // for stmd-like backtrack optimization
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StateInline.prototype.pushPending = function () { |
|
|
StateInline.prototype.pushPending = function () { |
|
|
var pending = this.pending; |
|
|
|
|
|
|
|
|
|
|
|
this.tokens.push({ |
|
|
this.tokens.push({ |
|
|
type: 'text', |
|
|
type: 'text', |
|
|
content: pending, |
|
|
content: this.pending, |
|
|
level: this.pendingLevel |
|
|
level: this.pendingLevel |
|
|
}); |
|
|
}); |
|
|
this.pending = ''; |
|
|
this.pending = ''; |
|
@ -5591,12 +5667,6 @@ StateInline.prototype.push = function (token) { |
|
|
this.pendingLevel = this.level; |
|
|
this.pendingLevel = this.level; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
StateInline.prototype.skipSpaces = function skipSpaces(pos) { |
|
|
|
|
|
for (var max = this.src.length; pos < max; pos++) { |
|
|
|
|
|
if (this.src.charCodeAt(pos) !== 0x20/* space */) { break; } |
|
|
|
|
|
} |
|
|
|
|
|
return pos; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
module.exports = StateInline; |
|
|
module.exports = StateInline; |
|
|
|
|
|
|
|
@ -5626,14 +5696,14 @@ module.exports = function strikethrough(state) { |
|
|
// this code also prevents recursion
|
|
|
// this code also prevents recursion
|
|
|
if (state.validateInsideEm || state.validateInsideLink) { return false; } |
|
|
if (state.validateInsideEm || state.validateInsideLink) { return false; } |
|
|
|
|
|
|
|
|
if (state.level >= state.options.level) { return false; } |
|
|
if (state.level >= state.options.maxNesting) { return false; } |
|
|
|
|
|
|
|
|
lastChar = state.pending.length !== 0 ? state.pending.charCodeAt(state.pending.length - 1) : -1; |
|
|
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1; |
|
|
nextChar = state.src.charCodeAt(start + 2); |
|
|
nextChar = state.src.charCodeAt(start + 2); |
|
|
|
|
|
|
|
|
if (lastChar === 0x7E/* ~ */) { return false; } |
|
|
if (lastChar === 0x7E/* ~ */) { return false; } |
|
|
if (nextChar === 0x7E/* */) { return false; } |
|
|
if (nextChar === 0x7E/* */) { return false; } |
|
|
if (nextChar === 0x20/* */) { return false; } |
|
|
if (nextChar === 0x20 || nextChar === 0x0A) { return false; } |
|
|
|
|
|
|
|
|
pos = start + 2; |
|
|
pos = start + 2; |
|
|
while (pos < max && state.src.charCodeAt(pos) === 0x7E/* ~ */) { pos++; } |
|
|
while (pos < max && state.src.charCodeAt(pos) === 0x7E/* ~ */) { pos++; } |
|
@ -5655,13 +5725,13 @@ module.exports = function strikethrough(state) { |
|
|
while (state.pos + 1 < max) { |
|
|
while (state.pos + 1 < max) { |
|
|
if (state.src.charCodeAt(state.pos) === 0x7E/* ~ */) { |
|
|
if (state.src.charCodeAt(state.pos) === 0x7E/* ~ */) { |
|
|
if (state.src.charCodeAt(state.pos + 1) === 0x7E/* ~ */) { |
|
|
if (state.src.charCodeAt(state.pos + 1) === 0x7E/* ~ */) { |
|
|
lastChar = state.pending.length !== 0 ? state.pending.charCodeAt(state.pending.length - 1) : -1; |
|
|
lastChar = state.src.charCodeAt(state.pos - 1); |
|
|
nextChar = state.pos + 2 < max ? state.src.charCodeAt(state.pos + 2) : -1; |
|
|
nextChar = state.pos + 2 < max ? state.src.charCodeAt(state.pos + 2) : -1; |
|
|
if (nextChar !== 0x7E/* ~ */ && lastChar !== 0x7E/* ~ */) { |
|
|
if (nextChar !== 0x7E/* ~ */ && lastChar !== 0x7E/* ~ */) { |
|
|
if (lastChar !== 0x20) { |
|
|
if (lastChar !== 0x20 && lastChar !== 0x0A) { |
|
|
// closing '~~'
|
|
|
// closing '~~'
|
|
|
stack--; |
|
|
stack--; |
|
|
} else if (nextChar !== 0x20) { |
|
|
} else if (nextChar !== 0x20 && nextChar !== 0x0A) { |
|
|
// opening '~~'
|
|
|
// opening '~~'
|
|
|
stack++; |
|
|
stack++; |
|
|
} // else {
|
|
|
} // else {
|
|
@ -6037,6 +6107,8 @@ rules.push(require('./rules_typographer/smartquotes')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Typographer() { |
|
|
function Typographer() { |
|
|
|
|
|
this._rules = []; |
|
|
|
|
|
|
|
|
this.options = assign({}, defaults); |
|
|
this.options = assign({}, defaults); |
|
|
|
|
|
|
|
|
this.ruler = new Ruler(this.rulesUpdate.bind(this)); |
|
|
this.ruler = new Ruler(this.rulesUpdate.bind(this)); |
|
@ -6060,8 +6132,6 @@ Typographer.prototype.set = function (options) { |
|
|
Typographer.prototype.process = function (state) { |
|
|
Typographer.prototype.process = function (state) { |
|
|
var i, l, rules; |
|
|
var i, l, rules; |
|
|
|
|
|
|
|
|
if (!state.options.typographer) { return; } |
|
|
|
|
|
|
|
|
|
|
|
rules = this._rules; |
|
|
rules = this._rules; |
|
|
|
|
|
|
|
|
for (i = 0, l = rules.length; i < l; i++) { |
|
|
for (i = 0, l = rules.length; i < l; i++) { |
|
|