2 lines
5.7 KiB
JavaScript
2 lines
5.7 KiB
JavaScript
|
|
import{f as g}from"./vendor-micromark-factory-space-BM4zcA-B.js";import{m as O,f as R,j as P}from"./vendor-micromark-util-character-Cn8n62xE.js";class N{constructor(){this.map=[]}add(n,i,r){x(this,n,i,r)}consume(n){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let i=this.map.length;const r=[];for(;i>0;)i-=1,r.push(n.slice(this.map[i][0]+this.map[i][1]),this.map[i][2]),n.length=this.map[i][0];r.push(n.slice()),n.length=0;let a=r.pop();for(;a;){for(const l of a)n.push(l);a=r.pop()}this.map.length=0}}function x(t,n,i,r){let a=0;if(!(i===0&&r.length===0)){for(;a<t.map.length;){if(t.map[a][0]===n){t.map[a][1]+=i,t.map[a][2].push(...r);return}a+=1}t.map.push([n,i,r])}}function V(t,n){let i=!1;const r=[];for(;n<t.length;){const a=t[n];if(i){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(t[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(t[n-1][1].type==="tableDelimiterMarker"){const l=r.length-1;r[l]=r[l]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(i=!0);n+=1}return r}function Q(){return{flow:{null:{name:"table",tokenize:_,resolveAll:q}}}}function _(t,n,i){const r=this;let a=0,l=0,u;return w;function w(e){let o=r.events.length-1;for(;o>-1;){const M=r.events[o][1].type;if(M==="lineEnding"||M==="linePrefix")o--;else break}const S=o>-1?r.events[o][1].type:null,z=S==="tableHead"||S==="tableRow"?H:h;return z===H&&r.parser.lazy[r.now().line]?i(e):z(e)}function h(e){return t.enter("tableHead"),t.enter("tableRow"),D(e)}function D(e){return e===124||(u=!0,l+=1),p(e)}function p(e){return e===null?i(e):O(e)?l>1?(l=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(e),t.exit("lineEnding"),f):i(e):R(e)?g(t,p,"whitespace")(e):(l+=1,u&&(u=!1,a+=1),e===124?(t.enter("tableCellDivider"),t.consume(e),t.exit("tableCellDivider"),u=!0,p):(t.enter("data"),b(e)))}function b(e){return e===null||e===124||P(e)?(t.exit("data"),p(e)):(t.consume(e),e===92?m:b)}function m(e){return e===92||e===124?(t.consume(e),b):b(e)}function f(e){return r.interrupt=!1,r.parser.lazy[r.now().line]?i(e):(t.enter("tableDelimiterRow"),u=!1,R(e)?g(t,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(e):s(e))}function s(e){return e===45||e===58?A(e):e===124?(u=!0,t.enter("tableCellDivider"),t.consume(e),t.exit("tableCellDivider"),T):d(e)}function T(e){return R(e)?g(t,A,"whitespace")(e):A(e)}function A(e){return e===58?(l+=1,u=!0,t.enter("tableDelimiterMarker"),t.consume(e),t.exit("tableDelimiterMarker"),E):e===45?(l+=1,E(e)):e===null||O(e)?C(e):d(e)}function E(e){return e===45?(t.enter("tableDelimiterFiller"),B(e)):d(e)}function B(e){return e===45?(t.consume(e),B):e===58?(u=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(e),t.exit("tableDelimiterMarker"),F):(t.exit("tableDelimiterFiller"),F(e))}function F(e){return R(e)?g(t,C,"whitespace")(e):C(e)}function C(e){return e===124?s(e):e===null||O(e)?!u||a!==l?d(e):(t.exit("tableDelimiterRow"),t.exit("tableHead"),n(e)):d(e)}function d(e){return i(e)}function H(e){return t.enter("tableRow"),k(e)}function k(e){return e===124?(t.enter("tableCellDivider"),t.consume(e),t.exit("tableCellDivider"),k):e===null||O(e)?(t.exit("tableRow"),n(e)):R(e)?g(t,k,"whitespace")(e):(t.enter("data"),j(e))}function j(e){return e===null||e===124||P(e)?(t.exit("data"),k(e)):(t.consume(e),e===92?L:j)}function L(e){return e===92||e===124?(t.consume(e),j):j(e)}}function q(t,n){let i=-1,r=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],w=!1,h=0,D,p,b;const m=new N;for(;++i<t.length;){const f=t[i],s=f[1];f[0]==="enter"?s.type==="tableHead"?(w=!1,h!==0&&(I(m,n,h,D,p),p=void 0,h=0),D={type:"table",start:Object.assign({},s.start),end:Object.assign({},s.end)},m.add(i,0,[["enter",D,n]])):s.type==="tableRow"||s.type==="tableDelimiterRow"?(r=!0,b=void 0,l=[0,0,0,0],u=[0,i+1,0,0],w&&(w=!1,p={type:"tableBody",start:Object.assign({},s.start),end:Object.assign({},s.end)},m.add(i,0,[["enter",p,n]])),a=s.type==="tableDelimiterRow"?2:p?3:1):a&&(s.type==="d
|