New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markdown-it-multimd-table

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-multimd-table - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

test/fixtures/issues.txt

2

bower.json

@@ -30,3 +30,3 @@ {

"coveralls": "^2.11.2",
"eslint": "0.10.2",
"eslint": "^3.19.0",
"eslint-plugin-nodeca": "^1.0.0",

@@ -33,0 +33,0 @@ "istanbul": "*",

@@ -1,15 +0,8 @@

/*! markdown-it-multimd-table 1.0.0 https://github.com//markdown-it/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.markdownitDeflist = f()}})(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})({1:[function(require,module,exports){
// Process definition lists
//
/*! markdown-it-multimd-table 3.0.0 https://github.com//markdown-it/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.markdownitDeflist = f()}})(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})({1:[function(require,module,exports){
'use strict';
module.exports = function multimd_table_plugin(md) {
function isFilledArray(array) {
return typeof array !== 'undefined' && array.length > 0;
}
function getLine(state, line) {
var pos = state.bMarks[line] + state.blkIndent,
max = state.eMarks[line];
max = state.eMarks[line];
return state.src.slice(pos, max);

@@ -22,41 +15,30 @@ }

max = str.length,
escapes = 0,
lastPos = 0,
backTicked = false,
lastBackTick = 0;
escaped = false,
backTicked = false;
while (pos < max) {
for (pos = 0; pos < max; pos++) {
switch (str.charCodeAt(pos)) {
case 0x5c/* \ */:
escapes++;
escaped = true;
break;
case 0x60/* ` */:
if (backTicked || ((escapes & 1) === 0)) {
if (backTicked || !escaped) {
// make \` close code sequence, but not open it;
// the reason is: `\` is correct code block
backTicked = !backTicked;
lastBackTick = pos;
}
escapes = 0;
escaped = false;
break;
case 0x7c/* | */:
if ((escapes & 1) === 0 && !backTicked) {
if (!backTicked && !escaped) {
result.push(str.slice(lastPos, pos));
lastPos = pos + 1;
}
escapes = 0;
escaped = false;
break;
default:
escapes = 0;
escaped = false;
break;
}
pos++;
// If there was an un-closed backtick, go back to just after
// the last backtick, but as if it was a normal character
if (pos === max && backTicked) {
backTicked = false;
pos = lastBackTick + 1;
}
}

@@ -89,162 +71,187 @@

function table(state, startLine, endLine, silent, captionInfo) {
var lineText, i, col, captionLine, headerLine, seperatorLine, nextLine,
columns, columnCount, token, aligns, wraps, colspans, t, tableLines,
tbodyLines, emptyTableBody;
function caption(state, lineText, lineNum, silent) {
var captionInfo, result, token;
// should have at least two lines
if (startLine + 2 > endLine) { return false; }
result = lineText.match(/^\[([^[\]]+)\](\[([^[\]]+)\])?\s*$/);
if (!result) { return false; }
if (silent) { return true; }
seperatorLine = startLine + 1;
if (state.sCount[seperatorLine] < state.blkIndent) { return false; }
// if it's indented more than 3 spaces, it should be a code block
if (state.sCount[seperatorLine] - state.blkIndent >= 4) { return false; }
captionInfo = { caption: null, label: null };
captionInfo.content = result[1];
captionInfo.label = result[2] || result[1];
while (!isFilledArray(aligns)) {
lineText = getLine(state, seperatorLine);
columns = lineText.split('|');
if (columns.length === 1 && !/^\||[^\\]\|$/.test(lineText)) { return false; }
aligns = [];
wraps = [];
for (i = 0; i < columns.length; i++) {
t = columns[i].trim();
if (!t && (i === 0 || i === columns.length - 1)) {
continue;
} else if (!/^:?(-+|=+):?\+?$/.test(t)) {
// might be another header line, so initialize
seperatorLine++;
aligns = [];
wraps = [];
break;
}
token = state.push('caption_open', 'caption', 1);
token.map = [ lineNum, lineNum + 1 ];
token.attrs = [ [ 'id', captionInfo.label.toLowerCase().replace(/\W+/g, '') ] ];
// pushed as wraps[i]
wraps.push(t.charCodeAt(t.length - 1) === 0x2B/* + */);
if (wraps[i]) { t = t.slice(0, -1); }
token = state.push('inline', '', 0);
token.content = captionInfo.content;
token.map = [ lineNum, lineNum + 1 ];
token.children = [];
switch (((t.charCodeAt(0) === 0x3A/* : */) << 4) +
(t.charCodeAt(t.length - 1) === 0x3A/* : */)) {
case 0x00: aligns.push(''); break;
case 0x01: aligns.push('right'); break;
case 0x10: aligns.push('left'); break;
case 0x11: aligns.push('center'); break;
}
}
}
token = state.push('caption_close', 'caption', -1);
for (headerLine = startLine; headerLine < seperatorLine; headerLine++) {
lineText = getLine(state, headerLine).trim();
if (lineText.indexOf('|') === -1) { return false; }
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
return captionInfo;
}
// header row will define an amount of columns in the entire table,
// and align row shouldn't be smaller than that (the rest of the rows can)
columnCount = escapedSplit(lineText.replace(/^\||\|$/g, '')).length;
if (columnCount > aligns.length) { return false; }
if (columnCount === 1 && !/^\||[^\\]\|$/.test(lineText)) { return false; }
}
function tableRow(state, lineText, lineNum, silent, seperatorInfo, rowType) {
var rowInfo, columns, token, i, col;
columns = escapedSplit(lineText.replace(/^\||([^\\])\|$/g, '$1'));
// lineText does not contain valid pipe character
if (columns.length === 1 && !/^\||[^\\]\|$/.test(lineText)) { return false; }
if (silent) { return true; }
token = state.push('table_open', 'table', 1);
token.map = tableLines = [ startLine, 0 ];
rowInfo = { colspans: null, columns: null };
rowInfo.columns = columns.filter(Boolean);
rowInfo.colspans = countColspan(columns);
if (captionInfo[0]) {
captionLine = (captionInfo[2] & 0x10) ? startLine - 1 : endLine + 1;
token = state.push('tr_open', 'tr', 1);
token.map = [ lineNum, lineNum + 1 ];
token = state.push('caption_open', 'caption', 1);
token.map = [ captionLine, captionLine + 1 ];
token.attrs = [ [ 'id', captionInfo[1].toLowerCase().replace(/\W+/g, '') ] ];
for (i = 0, col = 0; i < rowInfo.columns.length && col < seperatorInfo.aligns.length;
col += rowInfo.colspans[i], i++) {
token = state.push(rowType + '_open', rowType, 1);
token.map = [ lineNum, lineNum + 1 ];
token.attrs = [];
if (seperatorInfo.aligns[col]) {
token.attrs.push([ 'style', 'text-align:' + seperatorInfo.aligns[col] ]);
}
if (seperatorInfo.wraps[col]) {
token.attrs.push([ 'class', 'extend' ]);
}
if (rowInfo.colspans[i] > 1) {
token.attrs.push([ 'colspan', rowInfo.colspans[i] ]);
}
token = state.push('inline', '', 0);
token.content = captionInfo[0];
token.map = [ captionLine, captionLine + 1 ];
token.content = rowInfo.columns[i].trim();
token.map = [ lineNum, lineNum + 1 ];
token.children = [];
token = state.push('caption_close', 'caption', -1);
token = state.push(rowType + '_close', rowType, -1);
}
token = state.push('thead_open', 'thead', 1);
token.map = [ startLine, seperatorLine - 1 ];
token = state.push('tr_close', 'tr', -1);
for (headerLine = startLine; headerLine < seperatorLine; headerLine++) {
lineText = getLine(state, headerLine).trim();
columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
colspans = countColspan(columns);
return rowInfo;
}
token = state.push('tr_open', 'tr', 1);
token.map = [ startLine, startLine + 1 ];
function seperator(state, lineText, lineNum, silent) {
var columns, seperatorInfo, i, t;
for (i = 0, col = 0; col < columns.length; i++) {
token = state.push('th_open', 'th', 1);
token.map = [ headerLine, headerLine + 1 ];
token.attrs = [];
if (aligns[col]) { token.attrs.push([ 'style', 'text-align:' + aligns[col] ]); }
if (wraps[col]) { token.attrs.push([ 'class', 'extend' ]); }
if (colspans[i] > 1) { token.attrs.push([ 'colspan', colspans[i] ]); }
// lineText have code indentation
if (state.sCount[lineNum] - state.blkIndent >= 4) { return false; }
token = state.push('inline', '', 0);
token.content = columns[i].trim();
token.map = [ headerLine, headerLine + 1 ];
token.children = [];
// lineText does not contain valid pipe character
columns = escapedSplit(lineText.replace(/^\||([^\\])\|$/g, '$1'));
if (columns.length === 1 && !/^\||[^\\]\|$/.test(lineText)) { return false; }
token = state.push('th_close', 'th', -1);
seperatorInfo = { aligns: [], wraps: [] };
col += colspans[i] || 1;
for (i = 0; i < columns.length; i++) {
t = columns[i].trim();
if (!/^:?(-+|=+):?\+?$/.test(t)) { return false; }
seperatorInfo.wraps.push(t.charCodeAt(t.length - 1) === 0x2B/* + */);
if (seperatorInfo.wraps[i]) {
t = t.slice(0, -1);
}
token = state.push('tr_close', 'tr', -1);
switch (((t.charCodeAt(0) === 0x3A/* : */) << 4) +
(t.charCodeAt(t.length - 1) === 0x3A/* : */)) {
case 0x00: seperatorInfo.aligns.push(''); break;
case 0x01: seperatorInfo.aligns.push('right'); break;
case 0x10: seperatorInfo.aligns.push('left'); break;
case 0x11: seperatorInfo.aligns.push('center'); break;
}
}
token = state.push('thead_close', 'thead', -1);
return silent || seperatorInfo;
}
token = state.push('tbody_open', 'tbody', 1);
token.map = tbodyLines = [ seperatorLine + 1, 0 ];
function table(state, startLine, endLine, silent) {
/* Regex pseudo code for table:
* caption? tableRow+ seperator (tableRow+ | empty)* caption?
*/
var seperatorLine, captionAtFirst, captionAtLast, lineText, nextLine,
seperatorInfo, token, tableLines, tbodyLines, emptyTBody;
emptyTableBody = true;
if (startLine + 2 > endLine) { return false; }
for (nextLine = seperatorLine + 1; nextLine < endLine; nextLine++) {
if (state.sCount[nextLine] < state.blkIndent) { break; }
captionAtFirst = captionAtLast = false;
// first line
lineText = getLine(state, startLine).trim();
if (caption(state, lineText, startLine, true)) {
captionAtFirst = true;
} else if (!tableRow(state, lineText, startLine, true, null, 'tr')) {
return false;
}
// second line ~ seperator line
for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
lineText = getLine(state, nextLine).trim();
// HACK: avoid outer while loop
if (!lineText && !emptyTableBody) {
tbodyLines[1] = nextLine - 1;
token = state.push('tbody_close', 'tbody', -1);
token = state.push('tbody_open', 'tbody', 1);
token.map = tbodyLines = [ nextLine + 1, 0 ];
emptyTableBody = true;
if (seperator(state, lineText, nextLine, true)) {
seperatorLine = nextLine;
break;
} else if (tableRow(state, lineText, nextLine, true, null, 'th')) {
continue;
} else if (!lineText) {
break;
} else {
return false;
}
}
if (!seperatorLine) { return false; }
if (silent) { return true; }
if (lineText.indexOf('|') === -1) { break; }
if (state.sCount[nextLine] - state.blkIndent >= 4) { break; }
columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
if (columns.length === 1 && !/^\||[^\\]\|$/.test(lineText)) { break; }
colspans = countColspan(columns);
token = state.push('table_open', 'table', 1);
token.map = tableLines = [ startLine, 0 ];
emptyTableBody = false;
seperatorInfo = seperator(state, lineText, seperatorLine, false);
token = state.push('tr_open', 'tr', 1);
for (i = 0, col = 0; col < columnCount; i++) {
token = state.push('td_open', 'td', 1);
token.attrs = [];
if (aligns[col]) { token.attrs.push([ 'style', 'text-align:' + aligns[col] ]); }
if (wraps[col]) { token.attrs.push([ 'class', 'extend' ]); }
if (colspans[i] > 1) { token.attrs.push([ 'colspan', colspans[i] ]); }
if (captionAtFirst) {
lineText = getLine(state, startLine).trim();
caption(state, lineText, startLine, false);
}
token = state.push('inline', '', 0);
token.content = columns[i] ? columns[i].trim() : '';
token.children = [];
token = state.push('thead_open', 'thead', 1);
token.map = [ startLine + captionAtFirst, seperatorLine ];
token = state.push('td_close', 'td', -1);
for (nextLine = startLine + captionAtFirst; nextLine < seperatorLine; nextLine++) {
lineText = getLine(state, nextLine).trim();
tableRow(state, lineText, nextLine, false, seperatorInfo, 'th');
}
col += colspans[i] || 1;
token = state.push('thead_close', 'thead', -1);
token = state.push('tbody_open', 'tbody', 1);
token.map = tbodyLines = [ seperatorLine + 1, 0 ];
emptyTBody = true;
for (nextLine = seperatorLine + 1; nextLine < endLine; nextLine++) {
lineText = getLine(state, nextLine).trim();
if (!captionAtFirst && caption(state, lineText, nextLine, true)) {
captionAtLast = true;
break;
} else if (tableRow(state, lineText, nextLine, false, seperatorInfo, 'td')) {
emptyTBody = false;
} else if (!emptyTBody && !lineText) {
tbodyLines[1] = nextLine - 1;
token = state.push('tbody_close', 'tbody', -1);
token = state.push('tbody_open', 'tbody', 1);
token.map = tbodyLines = [ nextLine + 1, 0 ];
emptyTBody = true;
} else {
break;
}
token = state.push('tr_close', 'tr', -1);
}
token = state.push('tbody_close', 'tbody', -1);
if (captionAtLast) {
caption(state, lineText, nextLine, false);
nextLine++;
}
token = state.push('table_close', 'table', -1);

@@ -257,39 +264,9 @@

function tableWithCaption(state, startLine, endLine, silent) {
var lineText, result, captionInfo;
md.block.ruler.at('table', table, { alt: [ 'paragraph', 'reference' ] });
// captionInfo: [ caption, label, captionLinePos ]
captionInfo = [ null, null, 0 ];
};
lineText = getLine(state, endLine - 1);
result = lineText.match(/^\[([^[\]]+)\](\[([^[\]]+)\])?\s*$/);
if (result) {
captionInfo = [ result[1],
result[2] || result[1],
captionInfo[2] | 0x01 ];
}
/* vim: set ts=2 sw=2 et: */
lineText = getLine(state, startLine);
result = lineText.match(/^\[([^[\]]+)\](\[([^[\]]+)\])?\s*$/);
if (result) {
captionInfo = [ result[1],
result[2] || result[1],
captionInfo[2] | 0x10 ];
}
result = table(state,
startLine + ((captionInfo[2] & 0x10) === 0x10),
endLine - ((captionInfo[2] & 0x01) === 0x01),
silent, captionInfo);
if (result && !silent) {
state.line += (captionInfo[2] & 0x01);
}
return result;
}
md.block.ruler.at('table', tableWithCaption, { alt: [ 'paragraph', 'reference' ] });
};
},{}]},{},[1])(1)
});

@@ -1,2 +0,2 @@

/*! markdown-it-multimd-table 1.0.0 https://github.com//markdown-it/markdown-it-multimd-table @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 t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.markdownitDeflist=e()}}(function(){return function e(t,n,r){function s(u,i){if(!n[u]){if(!t[u]){var a="function"==typeof require&&require;if(!i&&a)return a(u,!0);if(o)return o(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var p=n[u]={exports:{}};t[u][0].call(p.exports,function(e){var n=t[u][1][e];return s(n||e)},p,p.exports,e,t,n,r)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)s(r[u]);return s}({1:[function(e,t,n){"use strict";t.exports=function(e){function t(e){return void 0!==e&&e.length>0}function n(e,t){var n=e.bMarks[t]+e.blkIndent,r=e.eMarks[t];return e.src.slice(n,r)}function r(e){for(var t=[],n=0,r=e.length,s=0,o=0,u=!1,i=0;n<r;){switch(e.charCodeAt(n)){case 92:s++;break;case 96:(u||0==(1&s))&&(u=!u,i=n),s=0;break;case 124:0!=(1&s)||u||(t.push(e.slice(o,n)),o=n+1),s=0;break;default:s=0}n++,n===r&&u&&(u=!1,n=i+1)}return t.push(e.slice(o)),t}function s(e){var t,n,r;for(n=0,r=[],t=e.length-1;t>=0;t--)e[t]?(r.unshift(n+1),n=0):n++;return n>0&&r.unshift(n+1),r}function o(e,o,u,i,a){var l,p,f,h,c,d,b,g,m,k,_,y,x,v,C,w,$;if(o+2>u)return!1;if(d=o+1,e.sCount[d]<e.blkIndent)return!1;if(e.sCount[d]-e.blkIndent>=4)return!1;for(;!t(_);){if(l=n(e,d),g=l.split("|"),1===g.length&&!/^\||[^\\]\|$/.test(l))return!1;for(_=[],y=[],p=0;p<g.length;p++)if((v=g[p].trim())||0!==p&&p!==g.length-1){if(!/^:?(-+|=+):?\+?$/.test(v)){d++,_=[],y=[];break}switch(y.push(43===v.charCodeAt(v.length-1)),y[p]&&(v=v.slice(0,-1)),((58===v.charCodeAt(0))<<4)+(58===v.charCodeAt(v.length-1))){case 0:_.push("");break;case 1:_.push("right");break;case 16:_.push("left");break;case 17:_.push("center")}}}for(c=o;c<d;c++){if(l=n(e,c).trim(),-1===l.indexOf("|"))return!1;if(e.sCount[o]-e.blkIndent>=4)return!1;if((m=r(l.replace(/^\||\|$/g,"")).length)>_.length)return!1;if(1===m&&!/^\||[^\\]\|$/.test(l))return!1}if(i)return!0;for(k=e.push("table_open","table",1),k.map=C=[o,0],a[0]&&(h=16&a[2]?o-1:u+1,k=e.push("caption_open","caption",1),k.map=[h,h+1],k.attrs=[["id",a[1].toLowerCase().replace(/\W+/g,"")]],k=e.push("inline","",0),k.content=a[0],k.map=[h,h+1],k.children=[],k=e.push("caption_close","caption",-1)),k=e.push("thead_open","thead",1),k.map=[o,d-1],c=o;c<d;c++){for(l=n(e,c).trim(),g=r(l.replace(/^\||\|$/g,"")),x=s(g),k=e.push("tr_open","tr",1),k.map=[o,o+1],p=0,f=0;f<g.length;p++)k=e.push("th_open","th",1),k.map=[c,c+1],k.attrs=[],_[f]&&k.attrs.push(["style","text-align:"+_[f]]),y[f]&&k.attrs.push(["class","extend"]),x[p]>1&&k.attrs.push(["colspan",x[p]]),k=e.push("inline","",0),k.content=g[p].trim(),k.map=[c,c+1],k.children=[],k=e.push("th_close","th",-1),f+=x[p]||1;k=e.push("tr_close","tr",-1)}for(k=e.push("thead_close","thead",-1),k=e.push("tbody_open","tbody",1),k.map=w=[d+1,0],$=!0,b=d+1;b<u&&!(e.sCount[b]<e.blkIndent);b++)if((l=n(e,b).trim())||$){if(!l)break;if(-1===l.indexOf("|"))break;if(e.sCount[b]-e.blkIndent>=4)break;if(g=r(l.replace(/^\||\|$/g,"")),1===g.length&&!/^\||[^\\]\|$/.test(l))break;for(x=s(g),$=!1,k=e.push("tr_open","tr",1),p=0,f=0;f<m;p++)k=e.push("td_open","td",1),k.attrs=[],_[f]&&k.attrs.push(["style","text-align:"+_[f]]),y[f]&&k.attrs.push(["class","extend"]),x[p]>1&&k.attrs.push(["colspan",x[p]]),k=e.push("inline","",0),k.content=g[p]?g[p].trim():"",k.children=[],k=e.push("td_close","td",-1),f+=x[p]||1;k=e.push("tr_close","tr",-1)}else w[1]=b-1,k=e.push("tbody_close","tbody",-1),k=e.push("tbody_open","tbody",1),k.map=w=[b+1,0],$=!0;return k=e.push("tbody_close","tbody",-1),k=e.push("table_close","table",-1),C[1]=w[1]=b,e.line=b,!0}function u(e,t,r,s){var u,i,a;return a=[null,null,0],u=n(e,r-1),i=u.match(/^\[([^[\]]+)\](\[([^[\]]+)\])?\s*$/),i&&(a=[i[1],i[2]||i[1],1|a[2]]),u=n(e,t),i=u.match(/^\[([^[\]]+)\](\[([^[\]]+)\])?\s*$/),i&&(a=[i[1],i[2]||i[1],16|a[2]]),i=o(e,t+(16==(16&a[2])),r-(1==(1&a[2])),s,a),i&&!s&&(e.line+=1&a[2]),i}e.block.ruler.at("table",u,{alt:["paragraph","reference"]})}},{}]},{},[1])(1)});
/*! markdown-it-multimd-table 3.0.0 https://github.com//markdown-it/markdown-it-multimd-table @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 t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.markdownitDeflist=e()}}(function(){return function e(t,n,r){function s(o,l){if(!n[o]){if(!t[o]){var i="function"==typeof require&&require;if(!l&&i)return i(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var p=n[o]={exports:{}};t[o][0].call(p.exports,function(e){var n=t[o][1][e];return s(n||e)},p,p.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(e,t,n){"use strict";t.exports=function(e){function t(e,t){var n=e.bMarks[t]+e.blkIndent,r=e.eMarks[t];return e.src.slice(n,r)}function n(e){var t=[],n=0,r=e.length,s=0,a=!1,o=!1;for(n=0;n<r;n++)switch(e.charCodeAt(n)){case 92:a=!0;break;case 96:!o&&a||(o=!o),a=!1;break;case 124:o||a||(t.push(e.slice(s,n)),s=n+1),a=!1;break;default:a=!1}return t.push(e.slice(s)),t}function r(e){var t,n,r;for(n=0,r=[],t=e.length-1;t>=0;t--)e[t]?(r.unshift(n+1),n=0):n++;return n>0&&r.unshift(n+1),r}function s(e,t,n,r){var s,a,o;return!!(a=t.match(/^\[([^[\]]+)\](\[([^[\]]+)\])?\s*$/))&&(!!r||(s={caption:null,label:null},s.content=a[1],s.label=a[2]||a[1],o=e.push("caption_open","caption",1),o.map=[n,n+1],o.attrs=[["id",s.label.toLowerCase().replace(/\W+/g,"")]],o=e.push("inline","",0),o.content=s.content,o.map=[n,n+1],o.children=[],o=e.push("caption_close","caption",-1),s))}function a(e,t,s,a,o,l){var i,u,p,c,f;if(u=n(t.replace(/^\||([^\\])\|$/g,"$1")),1===u.length&&!/^\||[^\\]\|$/.test(t))return!1;if(a)return!0;for(i={colspans:null,columns:null},i.columns=u.filter(Boolean),i.colspans=r(u),p=e.push("tr_open","tr",1),p.map=[s,s+1],c=0,f=0;c<i.columns.length&&f<o.aligns.length;f+=i.colspans[c],c++)p=e.push(l+"_open",l,1),p.map=[s,s+1],p.attrs=[],o.aligns[f]&&p.attrs.push(["style","text-align:"+o.aligns[f]]),o.wraps[f]&&p.attrs.push(["class","extend"]),i.colspans[c]>1&&p.attrs.push(["colspan",i.colspans[c]]),p=e.push("inline","",0),p.content=i.columns[c].trim(),p.map=[s,s+1],p.children=[],p=e.push(l+"_close",l,-1);return p=e.push("tr_close","tr",-1),i}function o(e,t,r,s){var a,o,l,i;if(e.sCount[r]-e.blkIndent>=4)return!1;if(a=n(t.replace(/^\||([^\\])\|$/g,"$1")),1===a.length&&!/^\||[^\\]\|$/.test(t))return!1;for(o={aligns:[],wraps:[]},l=0;l<a.length;l++){if(i=a[l].trim(),!/^:?(-+|=+):?\+?$/.test(i))return!1;switch(o.wraps.push(43===i.charCodeAt(i.length-1)),o.wraps[l]&&(i=i.slice(0,-1)),((58===i.charCodeAt(0))<<4)+(58===i.charCodeAt(i.length-1))){case 0:o.aligns.push("");break;case 1:o.aligns.push("right");break;case 16:o.aligns.push("left");break;case 17:o.aligns.push("center")}}return s||o}function l(e,n,r,l){var i,u,p,c,f,h,d,b,g,m;if(n+2>r)return!1;if(u=p=!1,c=t(e,n).trim(),s(e,c,n,!0))u=!0;else if(!a(e,c,n,!0,null,"tr"))return!1;for(f=n+1;f<r;f++){if(c=t(e,f).trim(),o(e,c,f,!0)){i=f;break}if(!a(e,c,f,!0,null,"th"))return!1}if(!i)return!1;if(l)return!0;for(d=e.push("table_open","table",1),d.map=b=[n,0],h=o(e,c,i,!1),u&&(c=t(e,n).trim(),s(e,c,n,!1)),d=e.push("thead_open","thead",1),d.map=[n+u,i],f=n+u;f<i;f++)c=t(e,f).trim(),a(e,c,f,!1,h,"th");for(d=e.push("thead_close","thead",-1),d=e.push("tbody_open","tbody",1),d.map=g=[i+1,0],m=!0,f=i+1;f<r;f++){if(c=t(e,f).trim(),!u&&s(e,c,f,!0)){p=!0;break}if(a(e,c,f,!1,h,"td"))m=!1;else{if(m||c)break;g[1]=f-1,d=e.push("tbody_close","tbody",-1),d=e.push("tbody_open","tbody",1),d.map=g=[f+1,0],m=!0}}return d=e.push("tbody_close","tbody",-1),p&&(s(e,c,f,!1),f++),d=e.push("table_close","table",-1),b[1]=g[1]=f,e.line=f,!0}e.block.ruler.at("table",l,{alt:["paragraph","reference"]})}},{}]},{},[1])(1)});

@@ -6,4 +6,3 @@ 'use strict';

var pos = state.bMarks[line] + state.blkIndent,
max = state.eMarks[line];
max = state.eMarks[line];
return state.src.slice(pos, max);

@@ -76,3 +75,3 @@ }

if (!result) { return false; }
if (silent) { return true; }
if (silent) { return true; }

@@ -104,3 +103,2 @@ captionInfo = { caption: null, label: null };

if (silent) { return true; }
// console.log(lineText + ': ' + columns.length);

@@ -115,4 +113,3 @@ rowInfo = { colspans: null, columns: null };

for (i = 0, col = 0; i < rowInfo.columns.length && col < seperatorInfo.aligns.length;
col += rowInfo.colspans[i], i++) {
// console.log(col)
col += rowInfo.colspans[i], i++) {
token = state.push(rowType + '_open', rowType, 1);

@@ -147,4 +144,7 @@ token.map = [ lineNum, lineNum + 1 ];

// lineText have code indentation
if (state.sCount[lineNum] - state.blkIndent >= 4) { return false; }
// lineText does not contain valid pipe character
columns = escapedSplit(lineText.replace(/^\||([^\\])\|$/g, '$1'));
// lineText does not contain valid pipe character
if (columns.length === 1 && !/^\||[^\\]\|$/.test(lineText)) { return false; }

@@ -156,10 +156,11 @@

t = columns[i].trim();
// console.log(t);
if (!/^:?(-+|=+):?\+?$/.test(t)) { return false; }
seperatorInfo.wraps.push(t.charCodeAt(t.length - 1) === 0x2B/* + */);
if (seperatorInfo.wraps[i]) { t = t.slice(0, -1); }
if (seperatorInfo.wraps[i]) {
t = t.slice(0, -1);
}
switch (((t.charCodeAt(0) === 0x3A/* : */) << 4) +
(t.charCodeAt(t.length - 1) === 0x3A/* : */)) {
(t.charCodeAt(t.length - 1) === 0x3A/* : */)) {
case 0x00: seperatorInfo.aligns.push(''); break;

@@ -176,10 +177,9 @@ case 0x01: seperatorInfo.aligns.push('right'); break;

function table(state, startLine, endLine, silent) {
// Regex pseudo code for table:
// caption? tableRow+ seperator (tableRow+ | empty)* caption?
/* Regex pseudo code for table:
* caption? tableRow+ seperator (tableRow+ | empty)* caption?
*/
var seperatorLine, captionAtFirst, captionAtLast, lineText, nextLine,
seperatorInfo, token, tableLines,
tbodyLines, emptyTBody;
seperatorInfo, token, tableLines, tbodyLines, emptyTBody;
if (startLine + 2 > endLine) { return false; }
if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }

@@ -198,4 +198,4 @@ captionAtFirst = captionAtLast = false;

for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
if (state.sCount[nextLine] - state.blkIndent >= 4) { return false; }
lineText = getLine(state, nextLine).trim();
if (seperator(state, lineText, nextLine, true)) {

@@ -227,3 +227,2 @@ seperatorLine = nextLine;

for (nextLine = startLine + captionAtFirst; nextLine < seperatorLine; nextLine++) {
lineText = getLine(state, nextLine).trim();

@@ -235,6 +234,5 @@ tableRow(state, lineText, nextLine, false, seperatorInfo, 'th');

emptyTBody = true;
token = state.push('tbody_open', 'tbody', 1);
token.map = tbodyLines = [ seperatorLine + 1, 0 ];
emptyTBody = true;

@@ -244,5 +242,3 @@ for (nextLine = seperatorLine + 1; nextLine < endLine; nextLine++) {

if (state.sCount[nextLine] - state.blkIndent >= 4) {
break;
} else if (!captionAtFirst && caption(state, lineText, nextLine, true)) {
if (!captionAtFirst && caption(state, lineText, nextLine, true)) {
captionAtLast = true;

@@ -277,2 +273,5 @@ break;

md.block.ruler.at('table', table, { alt: [ 'paragraph', 'reference' ] });
};
/* vim: set ts=2 sw=2 et: */
{
"name": "markdown-it-multimd-table",
"version": "2.0.1",
"version": "3.0.0",
"description": "Multimarkdown table syntax plugin for markdown-it markdown parser",

@@ -32,3 +32,3 @@ "keywords": [

"coveralls": "^2.11.2",
"eslint": "0.10.2",
"eslint": "^3.19.0",
"eslint-plugin-nodeca": "^1.0.0",

@@ -35,0 +35,0 @@ "istanbul": "*",

@@ -324,5 +324,5 @@ # MultiMarkdown Tables: Other Notes

Content | **Cell** | Cell |
New section | More | Data |
And more | With an escaped '\|' ||
And more | With an escaped '\|' ||
[Prototype table]

@@ -378,3 +378,3 @@ .

New section | More | Data |
And more | With an escaped '\|' ||
And more | With an escaped '\|' ||
[Prototype table]

@@ -399,4 +399,4 @@ .

<p>New section | More | Data |
And more | With an escaped '|' ||<br>
And more | With an escaped '|' ||
[Prototype table]</p>
.

@@ -139,6 +139,8 @@ # MultiMarkdown Tables: Other Notes

</tr>
<tr>
<td>2. MORE!</td>
<td style="text-align:center">Data</td>
</tr>
</tbody>
</table>
<pre><code> 2. MORE! | Data |
</code></pre>
.

@@ -145,0 +147,0 @@

@@ -6,3 +6,3 @@ 'use strict';

/*eslint-env mocha*/
/* eslint-env mocha */

@@ -16,3 +16,2 @@ describe('Basic', function () {

describe('Requirements', function () {

@@ -25,3 +24,2 @@ var md = require('markdown-it')()

describe('Other Notes', function () {

@@ -33,1 +31,8 @@ var md = require('markdown-it')()

});
describe('Issues', function () {
var md = require('markdown-it')()
.use(require('../'));
generate(path.join(__dirname, 'fixtures/issues.txt'), md);
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc