markdown-it-multimd-table
Advanced tools
Comparing version 4.1.2 to 4.1.3
@@ -1,293 +0,307 @@ | ||
/*! markdown-it-multimd-table 4.1.2 https://github.com/RedBug312/markdown-it-multimd-table @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownitMultimdTable = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
'use strict'; | ||
// constructor | ||
function DFA() { | ||
// alphabets are encoded by numbers in 16^N form, presenting its precedence | ||
this.__highest_alphabet__ = 0x0; | ||
this.__match_alphabets__ = {}; | ||
// states are union (bitwise OR) of its accepted alphabets | ||
this.__initial_state__ = 0x0; | ||
this.__accept_states__ = {}; | ||
// transitions are in the form: {prev_state: {alphabet: next_state}} | ||
this.__transitions__ = {}; | ||
// actions take two parameters: step (line number), prev_state and alphabet | ||
this.__actions__ = {}; | ||
} | ||
// setters | ||
DFA.prototype.set_highest_alphabet = function (alphabet) { | ||
this.__highest_alphabet__ = alphabet; | ||
}; | ||
DFA.prototype.set_match_alphabets = function (matches) { | ||
this.__match_alphabets__ = matches; | ||
}; | ||
DFA.prototype.set_initial_state = function (initial) { | ||
this.__initial_state__ = initial; | ||
}; | ||
DFA.prototype.set_accept_states = function (accepts) { | ||
for (var i = 0; i < accepts.length; i++) { | ||
this.__accept_states__[accepts[i]] = true; | ||
/*! markdown-it-multimd-table 4.1.3 https://github.com/redbug312/markdown-it-multimd-table @license MIT */ | ||
(function(global, factory) { | ||
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, | ||
global.markdownit = factory()); | ||
})(this, (function() { | ||
"use strict"; | ||
// constructor | ||
function DFA() { | ||
// alphabets are encoded by numbers in 16^N form, presenting its precedence | ||
this.__highest_alphabet__ = 0; | ||
this.__match_alphabets__ = {}; | ||
// states are union (bitwise OR) of its accepted alphabets | ||
this.__initial_state__ = 0; | ||
this.__accept_states__ = {}; | ||
// transitions are in the form: {prev_state: {alphabet: next_state}} | ||
this.__transitions__ = {}; | ||
// actions take two parameters: step (line number), prev_state and alphabet | ||
this.__actions__ = {}; | ||
} | ||
}; | ||
DFA.prototype.set_transitions = function (transitions) { | ||
this.__transitions__ = transitions; | ||
}; | ||
DFA.prototype.set_actions = function (actions) { | ||
this.__actions__ = actions; | ||
}; | ||
DFA.prototype.update_transition = function (state, alphabets) { | ||
this.__transitions__[state] = Object.assign( | ||
this.__transitions__[state] || Object(), alphabets | ||
); | ||
}; | ||
// methods | ||
DFA.prototype.execute = function (start, end) { | ||
var state, step, alphabet; | ||
for (state = this.__initial_state__, step = start; state && step < end; step++) { | ||
for (alphabet = this.__highest_alphabet__; alphabet > 0x0; alphabet >>= 4) { | ||
if ((state & alphabet) | ||
&& this.__match_alphabets__[alphabet].call(this, step, state, alphabet)) { break; } | ||
// setters | ||
DFA.prototype.set_highest_alphabet = function(alphabet) { | ||
this.__highest_alphabet__ = alphabet; | ||
}; | ||
DFA.prototype.set_match_alphabets = function(matches) { | ||
this.__match_alphabets__ = matches; | ||
}; | ||
DFA.prototype.set_initial_state = function(initial) { | ||
this.__initial_state__ = initial; | ||
}; | ||
DFA.prototype.set_accept_states = function(accepts) { | ||
for (var i = 0; i < accepts.length; i++) { | ||
this.__accept_states__[accepts[i]] = true; | ||
} | ||
this.__actions__(step, state, alphabet); | ||
if (alphabet === 0x0) { break; } | ||
state = this.__transitions__[state][alphabet] || 0x0; | ||
} | ||
return !!this.__accept_states__[state]; | ||
}; | ||
module.exports = DFA; | ||
/* vim: set ts=2 sw=2 et: */ | ||
},{}],2:[function(require,module,exports){ | ||
'use strict'; | ||
var DFA = require('./lib/dfa.js'); | ||
module.exports = function multimd_table_plugin(md, options) { | ||
var defaults = { | ||
multiline: false, | ||
rowspan: false, | ||
headerless: false, | ||
multibody: true | ||
}; | ||
options = md.utils.assign({}, defaults, options || {}); | ||
function scan_bound_indices(state, line) { | ||
/** | ||
* Naming convention of positional variables | ||
* - list-item | ||
* ·········longtext······\n | ||
* ^head ^start ^end ^max | ||
*/ | ||
var start = state.bMarks[line] + state.sCount[line], | ||
head = state.bMarks[line] + state.blkIndent, | ||
end = state.skipSpacesBack(state.eMarks[line], head), | ||
bounds = [], pos, posjump, | ||
escape = false, code = false; | ||
/* Scan for valid pipe character position */ | ||
for (pos = start; pos < end; pos++) { | ||
switch (state.src.charCodeAt(pos)) { | ||
case 0x5c /* \ */: | ||
escape = true; break; | ||
case 0x60 /* ` */: | ||
posjump = state.skipChars(pos, 0x60) - 1; | ||
/* make \` closes the code sequence, but not open it; | ||
the reason is that `\` is correct code block */ | ||
/* eslint-disable-next-line brace-style */ | ||
if (posjump > pos) { pos = posjump; } | ||
else if (code || !escape) { code = !code; } | ||
escape = false; break; | ||
case 0x7c /* | */: | ||
if (!code && !escape) { bounds.push(pos); } | ||
escape = false; break; | ||
default: | ||
escape = false; break; | ||
DFA.prototype.set_transitions = function(transitions) { | ||
this.__transitions__ = transitions; | ||
}; | ||
DFA.prototype.set_actions = function(actions) { | ||
this.__actions__ = actions; | ||
}; | ||
DFA.prototype.update_transition = function(state, alphabets) { | ||
this.__transitions__[state] = Object.assign(this.__transitions__[state] || Object(), alphabets); | ||
}; | ||
// methods | ||
DFA.prototype.execute = function(start, end) { | ||
var state, step, alphabet; | ||
for (state = this.__initial_state__, step = start; state && step < end; step++) { | ||
for (alphabet = this.__highest_alphabet__; alphabet > 0; alphabet >>= 4) { | ||
if (state & alphabet && this.__match_alphabets__[alphabet].call(this, step, state, alphabet)) { | ||
break; | ||
} | ||
} | ||
this.__actions__(step, state, alphabet); | ||
if (alphabet === 0) { | ||
break; | ||
} | ||
state = this.__transitions__[state][alphabet] || 0; | ||
} | ||
if (bounds.length === 0) return bounds; | ||
return !!this.__accept_states__[state]; | ||
}; | ||
var dfa = DFA; | ||
var markdownItMultimdTable = function multimd_table_plugin(md, options) { | ||
var defaults = { | ||
multiline: false, | ||
rowspan: false, | ||
headerless: false, | ||
multibody: true | ||
}; | ||
options = md.utils.assign({}, defaults, options || {}); | ||
function scan_bound_indices(state, line) { | ||
/** | ||
* Naming convention of positional variables | ||
* - list-item | ||
* ·········longtext······\n | ||
* ^head ^start ^end ^max | ||
*/ | ||
var start = state.bMarks[line] + state.sCount[line], head = state.bMarks[line] + state.blkIndent, end = state.skipSpacesBack(state.eMarks[line], head), bounds = [], pos, posjump, escape = false, code = false; | ||
/* Scan for valid pipe character position */ for (pos = start; pos < end; pos++) { | ||
switch (state.src.charCodeAt(pos)) { | ||
case 92 /* \ */ : | ||
escape = true; | ||
break; | ||
/* Pad in newline characters on last and this line */ | ||
if (bounds[0] > head) { bounds.unshift(head - 1); } | ||
if (bounds[bounds.length - 1] < end - 1) { bounds.push(end); } | ||
case 96 /* ` */ : | ||
posjump = state.skipChars(pos, 96) - 1; | ||
/* make \` closes the code sequence, but not open it; | ||
the reason is that `\` is correct code block */ | ||
/* eslint-disable-next-line brace-style */ if (posjump > pos) { | ||
pos = posjump; | ||
} else if (code || !escape) { | ||
code = !code; | ||
} | ||
escape = false; | ||
break; | ||
return bounds; | ||
} | ||
case 124 /* | */ : | ||
if (!code && !escape) { | ||
bounds.push(pos); | ||
} | ||
escape = false; | ||
break; | ||
function table_caption(state, silent, line) { | ||
var meta = { text: null, label: null }, | ||
start = state.bMarks[line] + state.sCount[line], | ||
max = state.eMarks[line], | ||
capRE = /^\[([^\[\]]+)\](\[([^\[\]]+)\])?\s*$/, | ||
matches = state.src.slice(start, max).match(capRE); | ||
if (!matches) { return false; } | ||
if (silent) { return true; } | ||
// TODO eliminate capRE by simple checking | ||
meta.text = matches[1]; | ||
meta.label = matches[2] || matches[1]; | ||
meta.label = meta.label.toLowerCase().replace(/\W+/g, ''); | ||
return meta; | ||
} | ||
function table_row(state, silent, line) { | ||
var meta = { bounds: null, multiline: null }, | ||
bounds = scan_bound_indices(state, line), | ||
start, pos, oldMax; | ||
if (bounds.length < 2) { return false; } | ||
if (silent) { return true; } | ||
meta.bounds = bounds; | ||
/* Multiline. Scan boundaries again since it's very complicated */ | ||
if (options.multiline) { | ||
start = state.bMarks[line] + state.sCount[line]; | ||
pos = state.eMarks[line] - 1; /* where backslash should be */ | ||
meta.multiline = (state.src.charCodeAt(pos) === 0x5C/* \ */); | ||
if (meta.multiline) { | ||
oldMax = state.eMarks[line]; | ||
state.eMarks[line] = state.skipSpacesBack(pos, start); | ||
meta.bounds = scan_bound_indices(state, line); | ||
state.eMarks[line] = oldMax; | ||
default: | ||
escape = false; | ||
break; | ||
} | ||
} | ||
if (bounds.length === 0) return bounds; | ||
/* Pad in newline characters on last and this line */ if (bounds[0] > head) { | ||
bounds.unshift(head - 1); | ||
} | ||
if (bounds[bounds.length - 1] < end - 1) { | ||
bounds.push(end); | ||
} | ||
return bounds; | ||
} | ||
return meta; | ||
} | ||
function table_separator(state, silent, line) { | ||
var meta = { aligns: [], wraps: [] }, | ||
bounds = scan_bound_indices(state, line), | ||
sepRE = /^:?(-+|=+):?\+?$/, | ||
c, text, align; | ||
/* Only separator needs to check indents */ | ||
if (state.sCount[line] - state.blkIndent >= 4) { return false; } | ||
if (bounds.length === 0) { return false; } | ||
for (c = 0; c < bounds.length - 1; c++) { | ||
text = state.src.slice(bounds[c] + 1, bounds[c + 1]).trim(); | ||
if (!sepRE.test(text)) { return false; } | ||
meta.wraps.push(text.charCodeAt(text.length - 1) === 0x2B/* + */); | ||
align = ((text.charCodeAt(0) === 0x3A/* : */) << 4) | | ||
(text.charCodeAt(text.length - 1 - meta.wraps[c]) === 0x3A); | ||
switch (align) { | ||
case 0x00: meta.aligns.push(''); break; | ||
case 0x01: meta.aligns.push('right'); break; | ||
case 0x10: meta.aligns.push('left'); break; | ||
case 0x11: meta.aligns.push('center'); break; | ||
function table_caption(state, silent, line) { | ||
var meta = { | ||
text: null, | ||
label: null | ||
}, start = state.bMarks[line] + state.sCount[line], max = state.eMarks[line], capRE = /^\[([^\[\]]+)\](\[([^\[\]]+)\])?\s*$/, matches = state.src.slice(start, max).match(capRE); | ||
if (!matches) { | ||
return false; | ||
} | ||
if (silent) { | ||
return true; | ||
} | ||
// TODO eliminate capRE by simple checking | ||
meta.text = matches[1]; | ||
meta.label = matches[2] || matches[1]; | ||
meta.label = meta.label.toLowerCase().replace(/\W+/g, ""); | ||
return meta; | ||
} | ||
if (silent) { return true; } | ||
return meta; | ||
} | ||
function table_row(state, silent, line) { | ||
var meta = { | ||
bounds: null, | ||
multiline: null | ||
}, bounds = scan_bound_indices(state, line), start, pos, oldMax; | ||
if (bounds.length < 2) { | ||
return false; | ||
} | ||
if (silent) { | ||
return true; | ||
} | ||
meta.bounds = bounds; | ||
/* Multiline. Scan boundaries again since it's very complicated */ if (options.multiline) { | ||
start = state.bMarks[line] + state.sCount[line]; | ||
pos = state.eMarks[line] - 1; | ||
/* where backslash should be */ meta.multiline = state.src.charCodeAt(pos) === 92 /* \ */; | ||
if (meta.multiline) { | ||
oldMax = state.eMarks[line]; | ||
state.eMarks[line] = state.skipSpacesBack(pos, start); | ||
meta.bounds = scan_bound_indices(state, line); | ||
state.eMarks[line] = oldMax; | ||
} | ||
} | ||
return meta; | ||
} | ||
function table_separator(state, silent, line) { | ||
var meta = { | ||
aligns: [], | ||
wraps: [] | ||
}, bounds = scan_bound_indices(state, line), sepRE = /^:?(-+|=+):?\+?$/, c, text, align; | ||
/* Only separator needs to check indents */ if (state.sCount[line] - state.blkIndent >= 4) { | ||
return false; | ||
} | ||
if (bounds.length === 0) { | ||
return false; | ||
} | ||
for (c = 0; c < bounds.length - 1; c++) { | ||
text = state.src.slice(bounds[c] + 1, bounds[c + 1]).trim(); | ||
if (!sepRE.test(text)) { | ||
return false; | ||
} | ||
meta.wraps.push(text.charCodeAt(text.length - 1) === 43 /* + */); | ||
align = (text.charCodeAt(0) === 58 /* : */) << 4 | text.charCodeAt(text.length - 1 - meta.wraps[c]) === 58; | ||
switch (align) { | ||
case 0: | ||
meta.aligns.push(""); | ||
break; | ||
function table_empty(state, silent, line) { | ||
return state.isEmpty(line); | ||
} | ||
case 1: | ||
meta.aligns.push("right"); | ||
break; | ||
function table(state, startLine, endLine, silent) { | ||
/** | ||
* Regex pseudo code for table: | ||
* caption? header+ separator (data+ empty)* data+ caption? | ||
* | ||
* We use DFA to emulate this plugin. Types with lower precedence are | ||
* set-minus from all the formers. Noted that separator should have higher | ||
* precedence than header or data. | ||
* | state | caption separator header data empty | --> lower precedence | ||
* | 0x10100 | 1 0 1 0 0 | | ||
*/ | ||
var tableDFA = new DFA(), | ||
grp = 0x10, mtr = -1, | ||
token, tableToken, trToken, | ||
colspan, leftToken, | ||
rowspan, upTokens = [], | ||
tableLines, tgroupLines, | ||
tag, text, range, r, c, b, t, | ||
blockState; | ||
case 16: | ||
meta.aligns.push("left"); | ||
break; | ||
if (startLine + 2 > endLine) { return false; } | ||
/** | ||
* First pass: validate and collect info into table token. IR is stored in | ||
* markdown-it `token.meta` to be pushed later. table/tr open tokens are | ||
* generated here. | ||
*/ | ||
tableToken = new state.Token('table_open', 'table', 1); | ||
tableToken.meta = { sep: null, cap: null, tr: [] }; | ||
tableDFA.set_highest_alphabet(0x10000); | ||
tableDFA.set_initial_state(0x10100); | ||
tableDFA.set_accept_states([ 0x10010, 0x10011, 0x00000 ]); | ||
tableDFA.set_match_alphabets({ | ||
0x10000: table_caption.bind(this, state, true), | ||
0x01000: table_separator.bind(this, state, true), | ||
0x00100: table_row.bind(this, state, true), | ||
0x00010: table_row.bind(this, state, true), | ||
0x00001: table_empty.bind(this, state, true) | ||
}); | ||
tableDFA.set_transitions({ | ||
0x10100: { 0x10000: 0x00100, 0x00100: 0x01100 }, | ||
0x00100: { 0x00100: 0x01100 }, | ||
0x01100: { 0x01000: 0x10010, 0x00100: 0x01100 }, | ||
0x10010: { 0x10000: 0x00000, 0x00010: 0x10011 }, | ||
0x10011: { 0x10000: 0x00000, 0x00010: 0x10011, 0x00001: 0x10010 } | ||
}); | ||
if (options.headerless) { | ||
tableDFA.set_initial_state(0x11100); | ||
tableDFA.update_transition(0x11100, | ||
{ 0x10000: 0x01100, 0x01000: 0x10010, 0x00100: 0x01100 } | ||
); | ||
trToken = new state.Token('tr_placeholder', 'tr', 0); | ||
trToken.meta = Object(); // avoid trToken.meta.grp throws exception | ||
case 17: | ||
meta.aligns.push("center"); | ||
break; | ||
} | ||
} | ||
if (silent) { | ||
return true; | ||
} | ||
return meta; | ||
} | ||
if (!options.multibody) { | ||
tableDFA.update_transition(0x10010, | ||
{ 0x10000: 0x00000, 0x00010: 0x10010 } // 0x10011 is never reached | ||
); | ||
function table_empty(state, silent, line) { | ||
return state.isEmpty(line); | ||
} | ||
/* Don't mix up DFA `_state` and markdown-it `state` */ | ||
tableDFA.set_actions(function (_line, _state, _type) { | ||
// console.log(_line, _state.toString(16), _type.toString(16)) // for test | ||
switch (_type) { | ||
case 0x10000: | ||
if (tableToken.meta.cap) { break; } | ||
tableToken.meta.cap = table_caption(state, false, _line); | ||
tableToken.meta.cap.map = [ _line, _line + 1 ]; | ||
tableToken.meta.cap.first = (_line === startLine); | ||
function table(state, startLine, endLine, silent) { | ||
/** | ||
* Regex pseudo code for table: | ||
* caption? header+ separator (data+ empty)* data+ caption? | ||
* | ||
* We use DFA to emulate this plugin. Types with lower precedence are | ||
* set-minus from all the formers. Noted that separator should have higher | ||
* precedence than header or data. | ||
* | state | caption separator header data empty | --> lower precedence | ||
* | 0x10100 | 1 0 1 0 0 | | ||
*/ | ||
var tableDFA = new dfa, grp = 16, mtr = -1, token, tableToken, trToken, colspan, leftToken, rowspan, upTokens = [], tableLines, tgroupLines, tag, text, range, r, c, b, t, blockState; | ||
if (startLine + 2 > endLine) { | ||
return false; | ||
} | ||
/** | ||
* First pass: validate and collect info into table token. IR is stored in | ||
* markdown-it `token.meta` to be pushed later. table/tr open tokens are | ||
* generated here. | ||
*/ tableToken = new state.Token("table_open", "table", 1); | ||
tableToken.meta = { | ||
sep: null, | ||
cap: null, | ||
tr: [] | ||
}; | ||
tableDFA.set_highest_alphabet(65536); | ||
tableDFA.set_initial_state(65792); | ||
tableDFA.set_accept_states([ 65552, 65553, 0 ]); | ||
tableDFA.set_match_alphabets({ | ||
65536: table_caption.bind(this, state, true), | ||
4096: table_separator.bind(this, state, true), | ||
256: table_row.bind(this, state, true), | ||
16: table_row.bind(this, state, true), | ||
1: table_empty.bind(this, state, true) | ||
}); | ||
tableDFA.set_transitions({ | ||
65792: { | ||
65536: 256, | ||
256: 4352 | ||
}, | ||
256: { | ||
256: 4352 | ||
}, | ||
4352: { | ||
4096: 65552, | ||
256: 4352 | ||
}, | ||
65552: { | ||
65536: 0, | ||
16: 65553 | ||
}, | ||
65553: { | ||
65536: 0, | ||
16: 65553, | ||
1: 65552 | ||
} | ||
}); | ||
if (options.headerless) { | ||
tableDFA.set_initial_state(69888); | ||
tableDFA.update_transition(69888, { | ||
65536: 4352, | ||
4096: 65552, | ||
256: 4352 | ||
}); | ||
trToken = new state.Token("tr_placeholder", "tr", 0); | ||
trToken.meta = Object(); | ||
// avoid trToken.meta.grp throws exception | ||
} | ||
if (!options.multibody) { | ||
tableDFA.update_transition(65552, { | ||
65536: 0, | ||
16: 65552 | ||
}); | ||
} | ||
/* Don't mix up DFA `_state` and markdown-it `state` */ tableDFA.set_actions((function(_line, _state, _type) { | ||
// console.log(_line, _state.toString(16), _type.toString(16)) // for test | ||
switch (_type) { | ||
case 65536: | ||
if (tableToken.meta.cap) { | ||
break; | ||
} | ||
tableToken.meta.cap = table_caption(state, false, _line); | ||
tableToken.meta.cap.map = [ _line, _line + 1 ]; | ||
tableToken.meta.cap.first = _line === startLine; | ||
break; | ||
case 0x01000: | ||
tableToken.meta.sep = table_separator(state, false, _line); | ||
case 4096: | ||
tableToken.meta.sep = table_separator(state, false, _line); | ||
tableToken.meta.sep.map = [ _line, _line + 1 ]; | ||
trToken.meta.grp |= 0x01; // previously assigned at case 0x00110 | ||
grp = 0x10; | ||
trToken.meta.grp |= 1; | ||
// previously assigned at case 0x00110 | ||
grp = 16; | ||
break; | ||
case 0x00100: | ||
case 0x00010: | ||
trToken = new state.Token('tr_open', 'tr', 1); | ||
trToken.map = [ _line, _line + 1 ]; | ||
trToken.meta = table_row(state, false, _line); | ||
case 256: | ||
case 16: | ||
trToken = new state.Token("tr_open", "tr", 1); | ||
trToken.map = [ _line, _line + 1 ]; | ||
trToken.meta = table_row(state, false, _line); | ||
trToken.meta.type = _type; | ||
trToken.meta.grp = grp; | ||
grp = 0x00; | ||
trToken.meta.grp = grp; | ||
grp = 0; | ||
tableToken.meta.tr.push(trToken); | ||
/* Multiline. Merge trTokens as an entire multiline trToken */ | ||
if (options.multiline) { | ||
/* Multiline. Merge trTokens as an entire multiline trToken */ if (options.multiline) { | ||
if (trToken.meta.multiline && mtr < 0) { | ||
@@ -298,7 +312,8 @@ /* Start line of multiline row. mark this trToken */ | ||
/* End line of multiline row. merge forward until the marked trToken */ | ||
token = tableToken.meta.tr[mtr]; | ||
token.meta.mbounds = tableToken.meta.tr | ||
.slice(mtr).map(function (tk) { return tk.meta.bounds; }); | ||
token.map[1] = trToken.map[1]; | ||
tableToken.meta.tr = tableToken.meta.tr.slice(0, mtr + 1); | ||
token = tableToken.meta.tr[mtr]; | ||
token.meta.mbounds = tableToken.meta.tr.slice(mtr).map((function(tk) { | ||
return tk.meta.bounds; | ||
})); | ||
token.map[1] = trToken.map[1]; | ||
tableToken.meta.tr = tableToken.meta.tr.slice(0, mtr + 1); | ||
mtr = -1; | ||
@@ -308,141 +323,122 @@ } | ||
break; | ||
case 0x00001: | ||
trToken.meta.grp |= 0x01; | ||
grp = 0x10; | ||
case 1: | ||
trToken.meta.grp |= 1; | ||
grp = 16; | ||
break; | ||
} | ||
})); | ||
if (tableDFA.execute(startLine, endLine) === false) { | ||
return false; | ||
} | ||
}); | ||
if (tableDFA.execute(startLine, endLine) === false) { return false; } | ||
// if (!tableToken.meta.sep) { return false; } // always evaluated true | ||
if (!tableToken.meta.tr.length) { return false; } // false under headerless corner case | ||
if (silent) { return true; } | ||
/* Last data row cannot be detected. not stored to trToken outside? */ | ||
tableToken.meta.tr[tableToken.meta.tr.length - 1].meta.grp |= 0x01; | ||
/** | ||
* Second pass: actually push the tokens into `state.tokens`. | ||
* thead/tbody/th/td open tokens and all closed tokens are generated here; | ||
* thead/tbody are generally called tgroup; td/th are generally called tcol. | ||
*/ | ||
tableToken.map = tableLines = [ startLine, 0 ]; | ||
tableToken.block = true; | ||
tableToken.level = state.level++; | ||
state.tokens.push(tableToken); | ||
if (tableToken.meta.cap) { | ||
token = state.push('caption_open', 'caption', 1); | ||
token.map = tableToken.meta.cap.map; | ||
token.attrs = [ [ 'id', tableToken.meta.cap.label ] ]; | ||
token = state.push('inline', '', 0); | ||
token.content = tableToken.meta.cap.text; | ||
token.map = tableToken.meta.cap.map; | ||
token.children = []; | ||
token = state.push('caption_close', 'caption', -1); | ||
} | ||
for (r = 0; r < tableToken.meta.tr.length; r++) { | ||
leftToken = new state.Token('td_th_placeholder', '', 0); | ||
/* Push in thead/tbody and tr open tokens */ | ||
trToken = tableToken.meta.tr[r]; | ||
// console.log(trToken.meta); // for test | ||
if (trToken.meta.grp & 0x10) { | ||
tag = (trToken.meta.type === 0x00100) ? 'thead' : 'tbody'; | ||
token = state.push(tag + '_open', tag, 1); | ||
token.map = tgroupLines = [ trToken.map[0], 0 ]; // array ref | ||
upTokens = []; | ||
// if (!tableToken.meta.sep) { return false; } // always evaluated true | ||
if (!tableToken.meta.tr.length) { | ||
return false; | ||
} | ||
trToken.block = true; | ||
trToken.level = state.level++; | ||
state.tokens.push(trToken); | ||
/* Push in th/td tokens */ | ||
for (c = 0; c < trToken.meta.bounds.length - 1; c++) { | ||
range = [ trToken.meta.bounds[c] + 1, trToken.meta.bounds[c + 1] ]; | ||
text = state.src.slice.apply(state.src, range); | ||
if (text === '') { | ||
colspan = leftToken.attrGet('colspan'); | ||
leftToken.attrSet('colspan', colspan === null ? 2 : colspan + 1); | ||
continue; | ||
// false under headerless corner case | ||
if (silent) { | ||
return true; | ||
} | ||
/* Last data row cannot be detected. not stored to trToken outside? */ tableToken.meta.tr[tableToken.meta.tr.length - 1].meta.grp |= 1; | ||
/** | ||
* Second pass: actually push the tokens into `state.tokens`. | ||
* thead/tbody/th/td open tokens and all closed tokens are generated here; | ||
* thead/tbody are generally called tgroup; td/th are generally called tcol. | ||
*/ tableToken.map = tableLines = [ startLine, 0 ]; | ||
tableToken.block = true; | ||
tableToken.level = state.level++; | ||
state.tokens.push(tableToken); | ||
if (tableToken.meta.cap) { | ||
token = state.push("caption_open", "caption", 1); | ||
token.map = tableToken.meta.cap.map; | ||
token.attrs = [ [ "id", tableToken.meta.cap.label ] ]; | ||
token = state.push("inline", "", 0); | ||
token.content = tableToken.meta.cap.text; | ||
token.map = tableToken.meta.cap.map; | ||
token.children = []; | ||
token = state.push("caption_close", "caption", -1); | ||
} | ||
for (r = 0; r < tableToken.meta.tr.length; r++) { | ||
leftToken = new state.Token("td_th_placeholder", "", 0); | ||
/* Push in thead/tbody and tr open tokens */ trToken = tableToken.meta.tr[r]; | ||
// console.log(trToken.meta); // for test | ||
if (trToken.meta.grp & 16) { | ||
tag = trToken.meta.type === 256 ? "thead" : "tbody"; | ||
token = state.push(tag + "_open", tag, 1); | ||
token.map = tgroupLines = [ trToken.map[0], 0 ]; | ||
// array ref | ||
upTokens = []; | ||
} | ||
if (options.rowspan && upTokens[c] && text.trim() === '^^') { | ||
rowspan = upTokens[c].attrGet('rowspan'); | ||
upTokens[c].attrSet('rowspan', rowspan === null ? 2 : rowspan + 1); | ||
leftToken = new state.Token('td_th_placeholder', '', 0); | ||
continue; | ||
} | ||
tag = (trToken.meta.type === 0x00100) ? 'th' : 'td'; | ||
token = state.push(tag + '_open', tag, 1); | ||
token.map = trToken.map; | ||
token.attrs = []; | ||
if (tableToken.meta.sep.aligns[c]) { | ||
token.attrs.push([ 'style', 'text-align:' + tableToken.meta.sep.aligns[c] ]); | ||
} | ||
if (tableToken.meta.sep.wraps[c]) { | ||
token.attrs.push([ 'class', 'extend' ]); | ||
} | ||
leftToken = upTokens[c] = token; | ||
/* Multiline. Join the text and feed into markdown-it blockParser. */ | ||
if (options.multiline && trToken.meta.multiline && trToken.meta.mbounds) { | ||
// Pad the text with empty lines to ensure the line number mapping is correct | ||
text = new Array(trToken.map[0]).fill('').concat([ text.trimRight() ]); | ||
for (b = 1; b < trToken.meta.mbounds.length; b++) { | ||
/* Line with N bounds has cells indexed from 0 to N-2 */ | ||
if (c > trToken.meta.mbounds[b].length - 2) { continue; } | ||
range = [ trToken.meta.mbounds[b][c] + 1, trToken.meta.mbounds[b][c + 1] ]; | ||
text.push(state.src.slice.apply(state.src, range).trimRight()); | ||
trToken.block = true; | ||
trToken.level = state.level++; | ||
state.tokens.push(trToken); | ||
/* Push in th/td tokens */ for (c = 0; c < trToken.meta.bounds.length - 1; c++) { | ||
range = [ trToken.meta.bounds[c] + 1, trToken.meta.bounds[c + 1] ]; | ||
text = state.src.slice.apply(state.src, range); | ||
if (text === "") { | ||
colspan = leftToken.attrGet("colspan"); | ||
leftToken.attrSet("colspan", colspan === null ? 2 : colspan + 1); | ||
continue; | ||
} | ||
blockState = new state.md.block.State(text.join('\n'), state.md, state.env, []); | ||
blockState.level = trToken.level + 1; | ||
// Start tokenizing from the actual content (trToken.map[0]) | ||
state.md.block.tokenize(blockState, trToken.map[0], blockState.lineMax); | ||
for (t = 0; t < blockState.tokens.length; t++) { | ||
state.tokens.push(blockState.tokens[t]); | ||
if (options.rowspan && upTokens[c] && text.trim() === "^^") { | ||
rowspan = upTokens[c].attrGet("rowspan"); | ||
upTokens[c].attrSet("rowspan", rowspan === null ? 2 : rowspan + 1); | ||
leftToken = new state.Token("td_th_placeholder", "", 0); | ||
continue; | ||
} | ||
} else { | ||
token = state.push('inline', '', 0); | ||
token.content = text.trim(); | ||
token.map = trToken.map; | ||
token.level = trToken.level + 1; | ||
token.children = []; | ||
tag = trToken.meta.type === 256 ? "th" : "td"; | ||
token = state.push(tag + "_open", tag, 1); | ||
token.map = trToken.map; | ||
token.attrs = []; | ||
if (tableToken.meta.sep.aligns[c]) { | ||
token.attrs.push([ "style", "text-align:" + tableToken.meta.sep.aligns[c] ]); | ||
} | ||
if (tableToken.meta.sep.wraps[c]) { | ||
token.attrs.push([ "class", "extend" ]); | ||
} | ||
leftToken = upTokens[c] = token; | ||
/* Multiline. Join the text and feed into markdown-it blockParser. */ if (options.multiline && trToken.meta.multiline && trToken.meta.mbounds) { | ||
// Pad the text with empty lines to ensure the line number mapping is correct | ||
text = new Array(trToken.map[0]).fill("").concat([ text.trimRight() ]); | ||
for (b = 1; b < trToken.meta.mbounds.length; b++) { | ||
/* Line with N bounds has cells indexed from 0 to N-2 */ | ||
if (c > trToken.meta.mbounds[b].length - 2) { | ||
continue; | ||
} | ||
range = [ trToken.meta.mbounds[b][c] + 1, trToken.meta.mbounds[b][c + 1] ]; | ||
text.push(state.src.slice.apply(state.src, range).trimRight()); | ||
} | ||
blockState = new state.md.block.State(text.join("\n"), state.md, state.env, []); | ||
blockState.level = trToken.level + 1; | ||
// Start tokenizing from the actual content (trToken.map[0]) | ||
state.md.block.tokenize(blockState, trToken.map[0], blockState.lineMax); | ||
for (t = 0; t < blockState.tokens.length; t++) { | ||
state.tokens.push(blockState.tokens[t]); | ||
} | ||
} else { | ||
token = state.push("inline", "", 0); | ||
token.content = text.trim(); | ||
token.map = trToken.map; | ||
token.level = trToken.level + 1; | ||
token.children = []; | ||
} | ||
token = state.push(tag + "_close", tag, -1); | ||
} | ||
token = state.push(tag + '_close', tag, -1); | ||
/* Push in tr and thead/tbody closed tokens */ state.push("tr_close", "tr", -1); | ||
if (trToken.meta.grp & 1) { | ||
tag = trToken.meta.type === 256 ? "thead" : "tbody"; | ||
token = state.push(tag + "_close", tag, -1); | ||
tgroupLines[1] = trToken.map[1]; | ||
} | ||
} | ||
/* Push in tr and thead/tbody closed tokens */ | ||
state.push('tr_close', 'tr', -1); | ||
if (trToken.meta.grp & 0x01) { | ||
tag = (trToken.meta.type === 0x00100) ? 'thead' : 'tbody'; | ||
token = state.push(tag + '_close', tag, -1); | ||
tgroupLines[1] = trToken.map[1]; | ||
} | ||
tableLines[1] = Math.max(tgroupLines[1], tableToken.meta.sep.map[1], tableToken.meta.cap ? tableToken.meta.cap.map[1] : -1); | ||
token = state.push("table_close", "table", -1); | ||
state.line = tableLines[1]; | ||
return true; | ||
} | ||
tableLines[1] = Math.max( | ||
tgroupLines[1], | ||
tableToken.meta.sep.map[1], | ||
tableToken.meta.cap ? tableToken.meta.cap.map[1] : -1 | ||
); | ||
token = state.push('table_close', 'table', -1); | ||
state.line = tableLines[1]; | ||
return true; | ||
} | ||
md.block.ruler.at('table', table, { alt: [ 'paragraph', 'reference' ] }); | ||
}; | ||
/* vim: set ts=2 sw=2 et: */ | ||
},{"./lib/dfa.js":1}]},{},[2])(2) | ||
}); | ||
md.block.ruler.at("table", table, { | ||
alt: [ "paragraph", "reference" ] | ||
}); | ||
}; | ||
return markdownItMultimdTable; | ||
})); |
@@ -1,1 +0,2 @@ | ||
/*! markdown-it-multimd-table 4.1.2 https://github.com/RedBug312/markdown-it-multimd-table @license MIT */!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).markdownitMultimdTable=t()}}((function(){return function t(e,a,n){function s(r,l){if(!a[r]){if(!e[r]){var o="function"==typeof require&&require;if(!l&&o)return o(r,!0);if(i)return i(r,!0);var p=new Error("Cannot find module '"+r+"'");throw p.code="MODULE_NOT_FOUND",p}var c=a[r]={exports:{}};e[r][0].call(c.exports,(function(t){return s(e[r][1][t]||t)}),c,c.exports,t,e,a,n)}return a[r].exports}for(var i="function"==typeof require&&require,r=0;r<n.length;r++)s(n[r]);return s}({1:[function(t,e,a){"use strict";function n(){this.__highest_alphabet__=0,this.__match_alphabets__={},this.__initial_state__=0,this.__accept_states__={},this.__transitions__={},this.__actions__={}}n.prototype.set_highest_alphabet=function(t){this.__highest_alphabet__=t},n.prototype.set_match_alphabets=function(t){this.__match_alphabets__=t},n.prototype.set_initial_state=function(t){this.__initial_state__=t},n.prototype.set_accept_states=function(t){for(var e=0;e<t.length;e++)this.__accept_states__[t[e]]=!0},n.prototype.set_transitions=function(t){this.__transitions__=t},n.prototype.set_actions=function(t){this.__actions__=t},n.prototype.update_transition=function(t,e){this.__transitions__[t]=Object.assign(this.__transitions__[t]||Object(),e)},n.prototype.execute=function(t,e){var a,n,s;for(a=this.__initial_state__,n=t;a&&n<e;n++){for(s=this.__highest_alphabet__;s>0&&!(a&s&&this.__match_alphabets__[s].call(this,n,a,s));s>>=4);if(this.__actions__(n,a,s),0===s)break;a=this.__transitions__[a][s]||0}return!!this.__accept_states__[a]},e.exports=n},{}],2:[function(t,e,a){"use strict";var n=t("./lib/dfa.js");e.exports=function(t,e){function a(t,e){var a,n,s=t.bMarks[e]+t.sCount[e],i=t.bMarks[e]+t.blkIndent,r=t.skipSpacesBack(t.eMarks[e],i),l=[],o=!1,p=!1;for(a=s;a<r;a++)switch(t.src.charCodeAt(a)){case 92:o=!0;break;case 96:(n=t.skipChars(a,96)-1)>a?a=n:!p&&o||(p=!p),o=!1;break;case 124:p||o||l.push(a),o=!1;break;default:o=!1}return 0===l.length||(l[0]>i&&l.unshift(i-1),l[l.length-1]<r-1&&l.push(r)),l}function s(t,e,a){var n={text:null,label:null},s=t.bMarks[a]+t.sCount[a],i=t.eMarks[a],r=t.src.slice(s,i).match(/^\[([^\[\]]+)\](\[([^\[\]]+)\])?\s*$/);return!!r&&(!!e||(n.text=r[1],n.label=r[2]||r[1],n.label=n.label.toLowerCase().replace(/\W+/g,""),n))}function i(t,n,s){var i,r,l,o={bounds:null,multiline:null},p=a(t,s);return!(p.length<2)&&(!!n||(o.bounds=p,e.multiline&&(i=t.bMarks[s]+t.sCount[s],r=t.eMarks[s]-1,o.multiline=92===t.src.charCodeAt(r),o.multiline&&(l=t.eMarks[s],t.eMarks[s]=t.skipSpacesBack(r,i),o.bounds=a(t,s),t.eMarks[s]=l)),o))}function r(t,e,n){var s,i,r={aligns:[],wraps:[]},l=a(t,n),o=/^:?(-+|=+):?\+?$/;if(t.sCount[n]-t.blkIndent>=4)return!1;if(0===l.length)return!1;for(s=0;s<l.length-1;s++){if(i=t.src.slice(l[s]+1,l[s+1]).trim(),!o.test(i))return!1;switch(r.wraps.push(43===i.charCodeAt(i.length-1)),(58===i.charCodeAt(0))<<4|58===i.charCodeAt(i.length-1-r.wraps[s])){case 0:r.aligns.push("");break;case 1:r.aligns.push("right");break;case 16:r.aligns.push("left");break;case 17:r.aligns.push("center")}}return!!e||r}function l(t,e,a){return t.isEmpty(a)}e=t.utils.assign({},{multiline:!1,rowspan:!1,headerless:!1,multibody:!0},e||{}),t.block.ruler.at("table",(function(t,a,o,p){var c,_,u,h,m,f,b,d,g,k,y,w,v,x,M,C,j=new n,T=16,A=-1,O=[];if(a+2>o)return!1;if((_=new t.Token("table_open","table",1)).meta={sep:null,cap:null,tr:[]},j.set_highest_alphabet(65536),j.set_initial_state(65792),j.set_accept_states([65552,65553,0]),j.set_match_alphabets({65536:s.bind(this,t,!0),4096:r.bind(this,t,!0),256:i.bind(this,t,!0),16:i.bind(this,t,!0),1:l.bind(this,t,!0)}),j.set_transitions({65792:{65536:256,256:4352},256:{256:4352},4352:{4096:65552,256:4352},65552:{65536:0,16:65553},65553:{65536:0,16:65553,1:65552}}),e.headerless&&(j.set_initial_state(69888),j.update_transition(69888,{65536:4352,4096:65552,256:4352}),(u=new t.Token("tr_placeholder","tr",0)).meta=Object()),e.multibody||j.update_transition(65552,{65536:0,16:65552}),j.set_actions((function(n,l,o){switch(o){case 65536:if(_.meta.cap)break;_.meta.cap=s(t,!1,n),_.meta.cap.map=[n,n+1],_.meta.cap.first=n===a;break;case 4096:_.meta.sep=r(t,!1,n),_.meta.sep.map=[n,n+1],u.meta.grp|=1,T=16;break;case 256:case 16:(u=new t.Token("tr_open","tr",1)).map=[n,n+1],u.meta=i(t,!1,n),u.meta.type=o,u.meta.grp=T,T=0,_.meta.tr.push(u),e.multiline&&(u.meta.multiline&&A<0?A=_.meta.tr.length-1:!u.meta.multiline&&A>=0&&((c=_.meta.tr[A]).meta.mbounds=_.meta.tr.slice(A).map((function(t){return t.meta.bounds})),c.map[1]=u.map[1],_.meta.tr=_.meta.tr.slice(0,A+1),A=-1));break;case 1:u.meta.grp|=1,T=16}})),!1===j.execute(a,o))return!1;if(!_.meta.tr.length)return!1;if(p)return!0;for(_.meta.tr[_.meta.tr.length-1].meta.grp|=1,_.map=b=[a,0],_.block=!0,_.level=t.level++,t.tokens.push(_),_.meta.cap&&((c=t.push("caption_open","caption",1)).map=_.meta.cap.map,c.attrs=[["id",_.meta.cap.label]],(c=t.push("inline","",0)).content=_.meta.cap.text,c.map=_.meta.cap.map,c.children=[],c=t.push("caption_close","caption",-1)),w=0;w<_.meta.tr.length;w++){for(m=new t.Token("td_th_placeholder","",0),16&(u=_.meta.tr[w]).meta.grp&&(g=256===u.meta.type?"thead":"tbody",(c=t.push(g+"_open",g,1)).map=d=[u.map[0],0],O=[]),u.block=!0,u.level=t.level++,t.tokens.push(u),v=0;v<u.meta.bounds.length-1;v++)if(y=[u.meta.bounds[v]+1,u.meta.bounds[v+1]],""!==(k=t.src.slice.apply(t.src,y)))if(e.rowspan&&O[v]&&"^^"===k.trim())f=O[v].attrGet("rowspan"),O[v].attrSet("rowspan",null===f?2:f+1),m=new t.Token("td_th_placeholder","",0);else{if(g=256===u.meta.type?"th":"td",(c=t.push(g+"_open",g,1)).map=u.map,c.attrs=[],_.meta.sep.aligns[v]&&c.attrs.push(["style","text-align:"+_.meta.sep.aligns[v]]),_.meta.sep.wraps[v]&&c.attrs.push(["class","extend"]),m=O[v]=c,e.multiline&&u.meta.multiline&&u.meta.mbounds){for(k=new Array(u.map[0]).fill("").concat([k.trimRight()]),x=1;x<u.meta.mbounds.length;x++)v>u.meta.mbounds[x].length-2||(y=[u.meta.mbounds[x][v]+1,u.meta.mbounds[x][v+1]],k.push(t.src.slice.apply(t.src,y).trimRight()));for((C=new t.md.block.State(k.join("\n"),t.md,t.env,[])).level=u.level+1,t.md.block.tokenize(C,u.map[0],C.lineMax),M=0;M<C.tokens.length;M++)t.tokens.push(C.tokens[M])}else(c=t.push("inline","",0)).content=k.trim(),c.map=u.map,c.level=u.level+1,c.children=[];c=t.push(g+"_close",g,-1)}else h=m.attrGet("colspan"),m.attrSet("colspan",null===h?2:h+1);t.push("tr_close","tr",-1),1&u.meta.grp&&(g=256===u.meta.type?"thead":"tbody",c=t.push(g+"_close",g,-1),d[1]=u.map[1])}return b[1]=Math.max(d[1],_.meta.sep.map[1],_.meta.cap?_.meta.cap.map[1]:-1),c=t.push("table_close","table",-1),t.line=b[1],!0}),{alt:["paragraph","reference"]})}},{"./lib/dfa.js":1}]},{},[2])(2)})); | ||
/*! markdown-it-multimd-table 4.1.3 https://github.com/redbug312/markdown-it-multimd-table @license MIT */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).markdownit=e()}(this,(function(){"use strict";function t(){this.__highest_alphabet__=0,this.__match_alphabets__={},this.__initial_state__=0,this.__accept_states__={},this.__transitions__={},this.__actions__={}}t.prototype.set_highest_alphabet=function(t){this.__highest_alphabet__=t},t.prototype.set_match_alphabets=function(t){this.__match_alphabets__=t},t.prototype.set_initial_state=function(t){this.__initial_state__=t},t.prototype.set_accept_states=function(t){for(var e=0;e<t.length;e++)this.__accept_states__[t[e]]=!0},t.prototype.set_transitions=function(t){this.__transitions__=t},t.prototype.set_actions=function(t){this.__actions__=t},t.prototype.update_transition=function(t,e){this.__transitions__[t]=Object.assign(this.__transitions__[t]||Object(),e)},t.prototype.execute=function(t,e){var a,s,n;for(a=this.__initial_state__,s=t;a&&s<e;s++){for(n=this.__highest_alphabet__;n>0&&!(a&n&&this.__match_alphabets__[n].call(this,s,a,n));n>>=4);if(this.__actions__(s,a,n),0===n)break;a=this.__transitions__[a][n]||0}return!!this.__accept_states__[a]};var e=t;return function(t,a){function s(t,e){var a,s,n=t.bMarks[e]+t.sCount[e],i=t.bMarks[e]+t.blkIndent,r=t.skipSpacesBack(t.eMarks[e],i),l=[],p=!1,o=!1;for(a=n;a<r;a++)switch(t.src.charCodeAt(a)){case 92:p=!0;break;case 96:(s=t.skipChars(a,96)-1)>a?a=s:!o&&p||(o=!o),p=!1;break;case 124:o||p||l.push(a),p=!1;break;default:p=!1}return 0===l.length||(l[0]>i&&l.unshift(i-1),l[l.length-1]<r-1&&l.push(r)),l}function n(t,e,a){var s={text:null,label:null},n=t.bMarks[a]+t.sCount[a],i=t.eMarks[a],r=t.src.slice(n,i).match(/^\[([^\[\]]+)\](\[([^\[\]]+)\])?\s*$/);return!!r&&(!!e||(s.text=r[1],s.label=r[2]||r[1],s.label=s.label.toLowerCase().replace(/\W+/g,""),s))}function i(t,e,n){var i,r,l,p={bounds:null,multiline:null},o=s(t,n);return!(o.length<2)&&(!!e||(p.bounds=o,a.multiline&&(i=t.bMarks[n]+t.sCount[n],r=t.eMarks[n]-1,p.multiline=92===t.src.charCodeAt(r),p.multiline&&(l=t.eMarks[n],t.eMarks[n]=t.skipSpacesBack(r,i),p.bounds=s(t,n),t.eMarks[n]=l)),p))}function r(t,e,a){var n,i,r={aligns:[],wraps:[]},l=s(t,a),p=/^:?(-+|=+):?\+?$/;if(t.sCount[a]-t.blkIndent>=4)return!1;if(0===l.length)return!1;for(n=0;n<l.length-1;n++){if(i=t.src.slice(l[n]+1,l[n+1]).trim(),!p.test(i))return!1;switch(r.wraps.push(43===i.charCodeAt(i.length-1)),(58===i.charCodeAt(0))<<4|58===i.charCodeAt(i.length-1-r.wraps[n])){case 0:r.aligns.push("");break;case 1:r.aligns.push("right");break;case 16:r.aligns.push("left");break;case 17:r.aligns.push("center")}}return!!e||r}function l(t,e,a){return t.isEmpty(a)}a=t.utils.assign({},{multiline:!1,rowspan:!1,headerless:!1,multibody:!0},a||{}),t.block.ruler.at("table",(function(t,s,p,o){var _,c,h,m,u,b,d,f,k,g,y,w,v,M,x,C,T=new e,A=16,j=-1,S=[];if(s+2>p)return!1;if((c=new t.Token("table_open","table",1)).meta={sep:null,cap:null,tr:[]},T.set_highest_alphabet(65536),T.set_initial_state(65792),T.set_accept_states([65552,65553,0]),T.set_match_alphabets({65536:n.bind(this,t,!0),4096:r.bind(this,t,!0),256:i.bind(this,t,!0),16:i.bind(this,t,!0),1:l.bind(this,t,!0)}),T.set_transitions({65792:{65536:256,256:4352},256:{256:4352},4352:{4096:65552,256:4352},65552:{65536:0,16:65553},65553:{65536:0,16:65553,1:65552}}),a.headerless&&(T.set_initial_state(69888),T.update_transition(69888,{65536:4352,4096:65552,256:4352}),(h=new t.Token("tr_placeholder","tr",0)).meta=Object()),a.multibody||T.update_transition(65552,{65536:0,16:65552}),T.set_actions((function(e,l,p){switch(p){case 65536:if(c.meta.cap)break;c.meta.cap=n(t,!1,e),c.meta.cap.map=[e,e+1],c.meta.cap.first=e===s;break;case 4096:c.meta.sep=r(t,!1,e),c.meta.sep.map=[e,e+1],h.meta.grp|=1,A=16;break;case 256:case 16:(h=new t.Token("tr_open","tr",1)).map=[e,e+1],h.meta=i(t,!1,e),h.meta.type=p,h.meta.grp=A,A=0,c.meta.tr.push(h),a.multiline&&(h.meta.multiline&&j<0?j=c.meta.tr.length-1:!h.meta.multiline&&j>=0&&((_=c.meta.tr[j]).meta.mbounds=c.meta.tr.slice(j).map((function(t){return t.meta.bounds})),_.map[1]=h.map[1],c.meta.tr=c.meta.tr.slice(0,j+1),j=-1));break;case 1:h.meta.grp|=1,A=16}})),!1===T.execute(s,p))return!1;if(!c.meta.tr.length)return!1;if(o)return!0;for(c.meta.tr[c.meta.tr.length-1].meta.grp|=1,c.map=d=[s,0],c.block=!0,c.level=t.level++,t.tokens.push(c),c.meta.cap&&((_=t.push("caption_open","caption",1)).map=c.meta.cap.map,_.attrs=[["id",c.meta.cap.label]],(_=t.push("inline","",0)).content=c.meta.cap.text,_.map=c.meta.cap.map,_.children=[],_=t.push("caption_close","caption",-1)),w=0;w<c.meta.tr.length;w++){for(u=new t.Token("td_th_placeholder","",0),16&(h=c.meta.tr[w]).meta.grp&&(k=256===h.meta.type?"thead":"tbody",(_=t.push(k+"_open",k,1)).map=f=[h.map[0],0],S=[]),h.block=!0,h.level=t.level++,t.tokens.push(h),v=0;v<h.meta.bounds.length-1;v++)if(y=[h.meta.bounds[v]+1,h.meta.bounds[v+1]],""!==(g=t.src.slice.apply(t.src,y)))if(a.rowspan&&S[v]&&"^^"===g.trim())b=S[v].attrGet("rowspan"),S[v].attrSet("rowspan",null===b?2:b+1),u=new t.Token("td_th_placeholder","",0);else{if(k=256===h.meta.type?"th":"td",(_=t.push(k+"_open",k,1)).map=h.map,_.attrs=[],c.meta.sep.aligns[v]&&_.attrs.push(["style","text-align:"+c.meta.sep.aligns[v]]),c.meta.sep.wraps[v]&&_.attrs.push(["class","extend"]),u=S[v]=_,a.multiline&&h.meta.multiline&&h.meta.mbounds){for(g=new Array(h.map[0]).fill("").concat([g.trimRight()]),M=1;M<h.meta.mbounds.length;M++)v>h.meta.mbounds[M].length-2||(y=[h.meta.mbounds[M][v]+1,h.meta.mbounds[M][v+1]],g.push(t.src.slice.apply(t.src,y).trimRight()));for((C=new t.md.block.State(g.join("\n"),t.md,t.env,[])).level=h.level+1,t.md.block.tokenize(C,h.map[0],C.lineMax),x=0;x<C.tokens.length;x++)t.tokens.push(C.tokens[x])}else(_=t.push("inline","",0)).content=g.trim(),_.map=h.map,_.level=h.level+1,_.children=[];_=t.push(k+"_close",k,-1)}else m=u.attrGet("colspan"),u.attrSet("colspan",null===m?2:m+1);t.push("tr_close","tr",-1),1&h.meta.grp&&(k=256===h.meta.type?"thead":"tbody",_=t.push(k+"_close",k,-1),f[1]=h.map[1])}return d[1]=Math.max(f[1],c.meta.sep.map[1],c.meta.cap?c.meta.cap.map[1]:-1),_=t.push("table_close","table",-1),t.line=d[1],!0}),{alt:["paragraph","reference"]})}})); |
{ | ||
"name": "markdown-it-multimd-table", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"description": "Multimarkdown table syntax plugin for markdown-it markdown parser", | ||
@@ -12,11 +12,4 @@ "keywords": [ | ||
], | ||
"homepage": "https://github.com/RedBug312/markdown-it-multimd-table", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/RedBug312/markdown-it-multimd-table.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/RedBug312/markdown-it-multimd-table/issues" | ||
}, | ||
"author": "RedBug312", | ||
"repository": "redbug312/markdown-it-multimd-table", | ||
"author": "redbug312", | ||
"license": "MIT", | ||
@@ -27,14 +20,16 @@ "main": "index.js", | ||
}, | ||
"dependencies": { | ||
"markdown-it": "^12.3.2" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^16.3.0", | ||
"@rollup/plugin-commonjs": "^16.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"coveralls": "^3.0.4", | ||
"eslint": "^8.6.0", | ||
"istanbul": "^0.4.5", | ||
"markdown-it": "^12.3.2", | ||
"markdown-it-testgen": "^0.1.3", | ||
"mocha": "^9.1.4", | ||
"terser": "^4.1.2" | ||
"nyc": "^15.1.0", | ||
"rollup": "^2.29.0", | ||
"rollup-plugin-node-polyfills": "^0.2.1", | ||
"rollup-plugin-terser": "^7.0.2" | ||
} | ||
} |
@@ -0,4 +1,4 @@ | ||
[![GitHub Action](https://github.com/redbug312/markdown-it-multimd-table/workflows/Node.js/badge.svg)](https://github.com/redbug312/markdown-it-multimd-table/actions) | ||
[![NPM version](https://img.shields.io/npm/v/markdown-it-multimd-table.svg?style=flat)](https://www.npmjs.org/package/markdown-it-multimd-table) | ||
[![Build Status](https://travis-ci.org/RedBug312/markdown-it-multimd-table.svg?branch=master)](https://travis-ci.org/RedBug312/markdown-it-multimd-table) | ||
[![Coverage Status](https://coveralls.io/repos/github/RedBug312/markdown-it-multimd-table/badge.svg?branch=master)](https://coveralls.io/github/RedBug312/markdown-it-multimd-table?branch=master) | ||
[![Coverage Status](https://coveralls.io/repos/redbug312/markdown-it-multimd-table/badge.svg?branch=master&service=github)](https://coveralls.io/github/redbug312/markdown-it-multimd-table?branch=master) | ||
@@ -60,3 +60,3 @@ MultiMarkdown table syntax plugin for markdown-it markdown parser | ||
$ cd markdown-it-multimd-table | ||
$ npm install markdown-it-multimd-table --prefix . | ||
$ npm install markdown-it-multimd-table --save-dev --prefix . | ||
$ vim test.js | ||
@@ -63,0 +63,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
86625
0
17
951
1
12
1
- Removedmarkdown-it@^12.3.2
- Removedargparse@2.0.1(transitive)
- Removedentities@2.1.0(transitive)
- Removedlinkify-it@3.0.3(transitive)
- Removedmarkdown-it@12.3.2(transitive)
- Removedmdurl@1.0.1(transitive)
- Removeduc.micro@1.0.6(transitive)