markdown-it-multimd-table
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -1,2 +0,2 @@ | ||
/*! markdown-it-multimd-table 4.1.0 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){ | ||
/*! markdown-it-multimd-table 4.1.1 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'; | ||
@@ -257,3 +257,3 @@ | ||
); | ||
trToken = new state.Token('table_fake_header_row', 'tr', 1); | ||
trToken = new state.Token('tr_placeholder', 'tr', 0); | ||
trToken.meta = Object(); // avoid trToken.meta.grp throws exception | ||
@@ -347,3 +347,3 @@ } | ||
for (r = 0; r < tableToken.meta.tr.length; r++) { | ||
leftToken = new state.Token('table_fake_tcol_open', '', 1); | ||
leftToken = new state.Token('td_th_placeholder', '', 0); | ||
@@ -376,2 +376,3 @@ /* Push in thead/tbody and tr open tokens */ | ||
upTokens[c].attrSet('rowspan', rowspan === null ? 2 : rowspan + 1); | ||
leftToken = new state.Token('td_th_placeholder', '', 0); | ||
continue; | ||
@@ -390,2 +391,3 @@ } | ||
} | ||
leftToken = upTokens[c] = token; | ||
@@ -392,0 +394,0 @@ |
@@ -1,1 +0,1 @@ | ||
/*! markdown-it-multimd-table 4.1.0 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,s){function n(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 _=a[r]={exports:{}};e[r][0].call(_.exports,(function(t){return n(e[r][1][t]||t)}),_,_.exports,t,e,a,s)}return a[r].exports}for(var i="function"==typeof require&&require,r=0;r<s.length;r++)n(s[r]);return n}({1:[function(t,e,a){"use strict";function s(){this.__highest_alphabet__=0,this.__match_alphabets__={},this.__initial_state__=0,this.__accept_states__={},this.__transitions__={},this.__actions__={}}s.prototype.set_highest_alphabet=function(t){this.__highest_alphabet__=t},s.prototype.set_match_alphabets=function(t){this.__match_alphabets__=t},s.prototype.set_initial_state=function(t){this.__initial_state__=t},s.prototype.set_accept_states=function(t){for(var e=0;e<t.length;e++)this.__accept_states__[t[e]]=!0},s.prototype.set_transitions=function(t){this.__transitions__=t},s.prototype.set_actions=function(t){this.__actions__=t},s.prototype.update_transition=function(t,e){this.__transitions__[t]=Object.assign(this.__transitions__[t]||Object(),e)},s.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]},e.exports=s},{}],2:[function(t,e,a){"use strict";var s=t("./lib/dfa.js");e.exports=function(t,e){function a(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=[],o=!1,p=!1;for(a=n;a<r;a++)switch(t.src.charCodeAt(a)){case 92:o=!0;break;case 96:(s=t.skipChars(a,96)-1)>a?a=s:!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 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,s,n){var i,r,l,o={bounds:null,multiline:null},p=a(t,n);return!(p.length<2)&&(!!s||(o.bounds=p,e.multiline&&(i=t.bMarks[n]+t.sCount[n],r=t.eMarks[n]-1,o.multiline=92===t.src.charCodeAt(r),o.multiline&&(l=t.eMarks[n],t.eMarks[n]=t.skipSpacesBack(r,i),o.bounds=a(t,n),t.eMarks[n]=l)),o))}function r(t,e,s){var n,i,r={aligns:[],wraps:[]},l=a(t,s),o=/^:?(-+|=+):?\+?$/;if(t.sCount[s]-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(),!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[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)}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=new s,C=16,j=-1,O=[];if(a+2>o)return!1;if((c=new t.Token("table_open","table",1)).meta={sep:null,cap:null,tr:[]},M.set_highest_alphabet(65536),M.set_initial_state(65792),M.set_accept_states([65552,65553,0]),M.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)}),M.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&&(M.set_initial_state(69888),M.update_transition(69888,{65536:4352,4096:65552,256:4352}),(u=new t.Token("table_fake_header_row","tr",1)).meta=Object()),e.multibody||M.update_transition(65552,{65536:0,16:65552}),M.set_actions((function(s,l,o){switch(o){case 65536:if(c.meta.cap)break;c.meta.cap=n(t,!1,s),c.meta.cap.map=[s,s+1],c.meta.cap.first=s===a;break;case 4096:c.meta.sep=r(t,!1,s),c.meta.sep.map=[s,s+1],u.meta.grp|=1,C=16;break;case 256:case 16:(u=new t.Token("tr_open","tr",1)).map=[s,s+1],u.meta=i(t,!1,s),u.meta.type=o,u.meta.grp=C,C=0,c.meta.tr.push(u),e.multiline&&(u.meta.multiline&&j<0?j=c.meta.tr.length-1:!u.meta.multiline&&j>=0&&((_=c.meta.tr[j]).meta.mbounds=c.meta.tr.slice(j).map((function(t){return t.meta.bounds})),_.map[1]=u.map[1],c.meta.tr=c.meta.tr.slice(0,j+1),j=-1));break;case 1:u.meta.grp|=1,C=16}})),!1===M.execute(a,o))return!1;if(!c.meta.tr.length)return!1;if(p)return!0;for(c.meta.tr[c.meta.tr.length-1].meta.grp|=1,c.map=b=[a,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(m=new t.Token("table_fake_tcol_open","",1),16&(u=c.meta.tr[w]).meta.grp&&(g=256===u.meta.type?"thead":"tbody",(_=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);else{if(g=256===u.meta.type?"th":"td",(_=t.push(g+"_open",g,1)).map=u.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"]),m=O[v]=_,e.multiline&&u.meta.multiline&&u.meta.mbounds){for(k=[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()));t.md.block.parse(k.join("\n"),t.md,t.env,t.tokens)}else(_=t.push("inline","",0)).content=k.trim(),_.map=u.map,_.children=[];_=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",_=t.push(g+"_close",g,-1),d[1]=u.map[1])}return b[1]=Math.max(d[1],c.meta.sep.map[1],c.meta.cap?c.meta.cap.map[1]:-1),_=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.1 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,s){function n(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 n(e[r][1][t]||t)}),c,c.exports,t,e,a,s)}return a[r].exports}for(var i="function"==typeof require&&require,r=0;r<s.length;r++)n(s[r]);return n}({1:[function(t,e,a){"use strict";function s(){this.__highest_alphabet__=0,this.__match_alphabets__={},this.__initial_state__=0,this.__accept_states__={},this.__transitions__={},this.__actions__={}}s.prototype.set_highest_alphabet=function(t){this.__highest_alphabet__=t},s.prototype.set_match_alphabets=function(t){this.__match_alphabets__=t},s.prototype.set_initial_state=function(t){this.__initial_state__=t},s.prototype.set_accept_states=function(t){for(var e=0;e<t.length;e++)this.__accept_states__[t[e]]=!0},s.prototype.set_transitions=function(t){this.__transitions__=t},s.prototype.set_actions=function(t){this.__actions__=t},s.prototype.update_transition=function(t,e){this.__transitions__[t]=Object.assign(this.__transitions__[t]||Object(),e)},s.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]},e.exports=s},{}],2:[function(t,e,a){"use strict";var s=t("./lib/dfa.js");e.exports=function(t,e){function a(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=[],o=!1,p=!1;for(a=n;a<r;a++)switch(t.src.charCodeAt(a)){case 92:o=!0;break;case 96:(s=t.skipChars(a,96)-1)>a?a=s:!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 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,s,n){var i,r,l,o={bounds:null,multiline:null},p=a(t,n);return!(p.length<2)&&(!!s||(o.bounds=p,e.multiline&&(i=t.bMarks[n]+t.sCount[n],r=t.eMarks[n]-1,o.multiline=92===t.src.charCodeAt(r),o.multiline&&(l=t.eMarks[n],t.eMarks[n]=t.skipSpacesBack(r,i),o.bounds=a(t,n),t.eMarks[n]=l)),o))}function r(t,e,s){var n,i,r={aligns:[],wraps:[]},l=a(t,s),o=/^:?(-+|=+):?\+?$/;if(t.sCount[s]-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(),!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[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)}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=new s,C=16,j=-1,T=[];if(a+2>o)return!1;if((_=new t.Token("table_open","table",1)).meta={sep:null,cap:null,tr:[]},M.set_highest_alphabet(65536),M.set_initial_state(65792),M.set_accept_states([65552,65553,0]),M.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)}),M.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&&(M.set_initial_state(69888),M.update_transition(69888,{65536:4352,4096:65552,256:4352}),(u=new t.Token("tr_placeholder","tr",0)).meta=Object()),e.multibody||M.update_transition(65552,{65536:0,16:65552}),M.set_actions((function(s,l,o){switch(o){case 65536:if(_.meta.cap)break;_.meta.cap=n(t,!1,s),_.meta.cap.map=[s,s+1],_.meta.cap.first=s===a;break;case 4096:_.meta.sep=r(t,!1,s),_.meta.sep.map=[s,s+1],u.meta.grp|=1,C=16;break;case 256:case 16:(u=new t.Token("tr_open","tr",1)).map=[s,s+1],u.meta=i(t,!1,s),u.meta.type=o,u.meta.grp=C,C=0,_.meta.tr.push(u),e.multiline&&(u.meta.multiline&&j<0?j=_.meta.tr.length-1:!u.meta.multiline&&j>=0&&((c=_.meta.tr[j]).meta.mbounds=_.meta.tr.slice(j).map((function(t){return t.meta.bounds})),c.map[1]=u.map[1],_.meta.tr=_.meta.tr.slice(0,j+1),j=-1));break;case 1:u.meta.grp|=1,C=16}})),!1===M.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],T=[]),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&&T[v]&&"^^"===k.trim())f=T[v].attrGet("rowspan"),T[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=T[v]=c,e.multiline&&u.meta.multiline&&u.meta.mbounds){for(k=[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()));t.md.block.parse(k.join("\n"),t.md,t.env,t.tokens)}else(c=t.push("inline","",0)).content=k.trim(),c.map=u.map,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)})); |
@@ -182,3 +182,3 @@ 'use strict'; | ||
); | ||
trToken = new state.Token('table_fake_header_row', 'tr', 1); | ||
trToken = new state.Token('tr_placeholder', 'tr', 0); | ||
trToken.meta = Object(); // avoid trToken.meta.grp throws exception | ||
@@ -272,3 +272,3 @@ } | ||
for (r = 0; r < tableToken.meta.tr.length; r++) { | ||
leftToken = new state.Token('table_fake_tcol_open', '', 1); | ||
leftToken = new state.Token('td_th_placeholder', '', 0); | ||
@@ -301,2 +301,3 @@ /* Push in thead/tbody and tr open tokens */ | ||
upTokens[c].attrSet('rowspan', rowspan === null ? 2 : rowspan + 1); | ||
leftToken = new state.Token('td_th_placeholder', '', 0); | ||
continue; | ||
@@ -315,2 +316,3 @@ } | ||
} | ||
leftToken = upTokens[c] = token; | ||
@@ -317,0 +319,0 @@ |
{ | ||
"name": "markdown-it-multimd-table", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "Multimarkdown table syntax plugin for markdown-it markdown parser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -349,3 +349,3 @@ --- | ||
Rowspan and Colspan in one table cell | ||
Rowspan and colspan in one table cell | ||
. | ||
@@ -390,2 +390,30 @@ | A ||| | ||
[Issue #39](github.com/redbug312/markdown-it-multimd-table/issues/39) | ||
Rowspan and colspan in one table cell base case | ||
. | ||
| | | | | ||
|----|----|----| | ||
| A | B || | ||
| C | ^^ || | ||
. | ||
<table> | ||
<thead> | ||
<tr> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>A</td> | ||
<td colspan="2" rowspan="2">B</td> | ||
</tr> | ||
<tr> | ||
<td>C</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
. | ||
Rowspan at first line | ||
@@ -392,0 +420,0 @@ . |
837
84841
16