markdown-it-multimd-table
Advanced tools
Comparing version 4.0.3 to 4.1.0
@@ -1,2 +0,2 @@ | ||
/*! markdown-it-multimd-table 4.0.3 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.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){ | ||
'use strict'; | ||
@@ -80,3 +80,9 @@ | ||
module.exports = function multimd_table_plugin(md, options) { | ||
options = options || {}; | ||
var defaults = { | ||
multiline: false, | ||
rowspan: false, | ||
headerless: false, | ||
multibody: true | ||
}; | ||
options = md.utils.assign({}, defaults, options || {}); | ||
@@ -86,7 +92,8 @@ function scan_bound_indices(state, line) { | ||
* Naming convention of positional variables | ||
* ·······longtext······\n | ||
* ^head ^start ^end ^max | ||
* - list-item | ||
* ·········longtext······\n | ||
* ^head ^start ^end ^max | ||
*/ | ||
var start = state.bMarks[line] + state.tShift[line], | ||
head = state.bMarks[line], /* no tShift to detect \n */ | ||
var start = state.bMarks[line] + state.sCount[line], | ||
head = state.bMarks[line] + state.blkIndent, | ||
end = state.skipSpacesBack(state.eMarks[line], head), | ||
@@ -119,3 +126,3 @@ bounds = [], pos, posjump, | ||
/* Pad in newline characters on last and this line */ | ||
if (bounds[0] > start) { bounds.unshift(head - 1); } | ||
if (bounds[0] > head) { bounds.unshift(head - 1); } | ||
if (bounds[bounds.length - 1] < end - 1) { bounds.push(end); } | ||
@@ -128,3 +135,3 @@ | ||
var meta = { text: null, label: null }, | ||
start = state.bMarks[line] + state.tShift[line], | ||
start = state.bMarks[line] + state.sCount[line], | ||
max = state.eMarks[line], | ||
@@ -157,3 +164,3 @@ capRE = /^\[([^\[\]]+)\](\[([^\[\]]+)\])?\s*$/, | ||
if (options.multiline) { | ||
start = state.bMarks[line] + state.tShift[line]; | ||
start = state.bMarks[line] + state.sCount[line]; | ||
pos = state.eMarks[line] - 1; /* where backslash should be */ | ||
@@ -258,4 +265,10 @@ meta.multiline = (state.src.charCodeAt(pos) === 0x5C/* \ */); | ||
} | ||
if (!options.multibody) { | ||
tableDFA.update_transition(0x10010, | ||
{ 0x10000: 0x00000, 0x00010: 0x10010 } // 0x10011 is never reached | ||
); | ||
} | ||
/* 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) { | ||
@@ -262,0 +275,0 @@ case 0x10000: |
@@ -1,1 +0,1 @@ | ||
/*! markdown-it-multimd-table 4.0.3 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.tShift[e],i=t.bMarks[e],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]>n&&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.tShift[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.tShift[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=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,S=[];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("table_fake_header_row","tr",1)).meta=Object()),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("table_fake_tcol_open","",1),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],S=[]),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&&S[v]&&"^^"===k.trim())f=S[v].attrGet("rowspan"),S[v].attrSet("rowspan",null===f?2:f+1);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=S[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)})); | ||
/*! 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)})); |
29
index.js
@@ -5,3 +5,9 @@ 'use strict'; | ||
module.exports = function multimd_table_plugin(md, options) { | ||
options = options || {}; | ||
var defaults = { | ||
multiline: false, | ||
rowspan: false, | ||
headerless: false, | ||
multibody: true | ||
}; | ||
options = md.utils.assign({}, defaults, options || {}); | ||
@@ -11,7 +17,8 @@ function scan_bound_indices(state, line) { | ||
* Naming convention of positional variables | ||
* ·······longtext······\n | ||
* ^head ^start ^end ^max | ||
* - list-item | ||
* ·········longtext······\n | ||
* ^head ^start ^end ^max | ||
*/ | ||
var start = state.bMarks[line] + state.tShift[line], | ||
head = state.bMarks[line], /* no tShift to detect \n */ | ||
var start = state.bMarks[line] + state.sCount[line], | ||
head = state.bMarks[line] + state.blkIndent, | ||
end = state.skipSpacesBack(state.eMarks[line], head), | ||
@@ -44,3 +51,3 @@ bounds = [], pos, posjump, | ||
/* Pad in newline characters on last and this line */ | ||
if (bounds[0] > start) { bounds.unshift(head - 1); } | ||
if (bounds[0] > head) { bounds.unshift(head - 1); } | ||
if (bounds[bounds.length - 1] < end - 1) { bounds.push(end); } | ||
@@ -53,3 +60,3 @@ | ||
var meta = { text: null, label: null }, | ||
start = state.bMarks[line] + state.tShift[line], | ||
start = state.bMarks[line] + state.sCount[line], | ||
max = state.eMarks[line], | ||
@@ -82,3 +89,3 @@ capRE = /^\[([^\[\]]+)\](\[([^\[\]]+)\])?\s*$/, | ||
if (options.multiline) { | ||
start = state.bMarks[line] + state.tShift[line]; | ||
start = state.bMarks[line] + state.sCount[line]; | ||
pos = state.eMarks[line] - 1; /* where backslash should be */ | ||
@@ -183,4 +190,10 @@ meta.multiline = (state.src.charCodeAt(pos) === 0x5C/* \ */); | ||
} | ||
if (!options.multibody) { | ||
tableDFA.update_transition(0x10010, | ||
{ 0x10000: 0x00000, 0x00010: 0x10010 } // 0x10011 is never reached | ||
); | ||
} | ||
/* 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) { | ||
@@ -187,0 +200,0 @@ case 0x10000: |
{ | ||
"name": "markdown-it-multimd-table", | ||
"version": "4.0.3", | ||
"version": "4.1.0", | ||
"description": "Multimarkdown table syntax plugin for markdown-it markdown parser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -276,2 +276,71 @@ --- | ||
[Issue #35](https://github.com/RedBug312/markdown-it-multimd-table/issues/35) | ||
First column left empty and not nested yet | ||
. | ||
x | y | ||
---------|--------- | ||
test1 | test2 \ | ||
| test3 | ||
. | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>x</th> | ||
<th>y</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<p>test1</p> | ||
</td> | ||
<td> | ||
<p>test2 | ||
test3</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
. | ||
NOTE: the empty line seems needed, or the table is viewed as paragraph continuation. | ||
See https://spec.commonmark.org/0.29/#example-227. | ||
First column left empty and nested under list item | ||
. | ||
- list-item | ||
x | y | ||
---------|--------- | ||
test1 | test2 \ | ||
| test3 | ||
. | ||
<ul> | ||
<li> | ||
<p>list-item</p> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>x</th> | ||
<th>y</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<p>test1</p> | ||
</td> | ||
<td> | ||
<p>test2 | ||
test3</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</li> | ||
</ul> | ||
. | ||
rowspan: '^^' in a cell indicates it should be merged with the cell above | ||
@@ -458,1 +527,46 @@ UNDEFINED feature | ||
. | ||
multibody: enable multiple table body by default | ||
AGAINST note 9 if disabled | ||
[Issue #34](https://github.com/RedBug312/markdown-it-multimd-table/issues/34) | ||
Multibody table but disabled the feature | ||
. | ||
| --- | --- | | ||
| 1 | 2 | | ||
| 3 | 4 | | ||
A paragraph contains pipes (|). | ||
| --- | --- | | ||
| 5 | 6 | | ||
| 7 | 8 | | ||
. | ||
<table> | ||
<tbody> | ||
<tr> | ||
<td>1</td> | ||
<td>2</td> | ||
</tr> | ||
<tr> | ||
<td>3</td> | ||
<td>4</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<p>A paragraph contains pipes (|).</p> | ||
<table> | ||
<tbody> | ||
<tr> | ||
<td>5</td> | ||
<td>6</td> | ||
</tr> | ||
<tr> | ||
<td>7</td> | ||
<td>8</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
. |
@@ -6,24 +6,25 @@ 'use strict'; | ||
var markdownit = require('markdown-it'); | ||
var multimd_table = require('../'); | ||
/* eslint-env mocha */ | ||
describe('markdown-it-multimd-table-standard', function () { | ||
var md = require('markdown-it')() | ||
.use(require('../')); | ||
generate(path.join(__dirname, 'fixtures/standard.txt'), {header: true}, md); | ||
var md = markdownit().use(multimd_table); | ||
generate(path.join(__dirname, 'fixtures/standard.txt'), { header: true }, md); | ||
}); | ||
describe('markdown-it-multimd-table-unspecified', function () { | ||
var md = require('markdown-it')() | ||
.use(require('../')); | ||
generate(path.join(__dirname, 'fixtures/unspecified.txt'), {header: true}, md); | ||
var md = markdownit().use(multimd_table); | ||
generate(path.join(__dirname, 'fixtures/unspecified.txt'), { header: true }, md); | ||
}); | ||
describe('markdown-it-multimd-table-options', function () { | ||
var md = require('markdown-it')() | ||
.use(require('../'), { | ||
multiline: true, | ||
rowspan: true, | ||
headerless: true, | ||
}); | ||
generate(path.join(__dirname, 'fixtures/options.txt'), {header: true}, md); | ||
var md = markdownit().use(multimd_table, { | ||
multiline: true, | ||
rowspan: true, | ||
headerless: true, | ||
multibody: false, | ||
}); | ||
generate(path.join(__dirname, 'fixtures/options.txt'), { header: true }, md); | ||
}); |
Sorry, the diff of this file is not supported yet
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
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
430931
835
17