github-markdown-adf 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -2
- package/dist/browser/index.iife.js +25 -25
- package/dist/browser/index.js +16 -16
- package/dist/index.cjs +229 -83
- package/dist/index.d.cts +14 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +14 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +229 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -15,34 +15,34 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
15
15
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
16
16
|
`,...a.current()});return/^[\t ]/.test(l)&&(l=bi(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Di.peek=Oi;function Di(e){return e.value||``}function Oi(){return`<`}ki.peek=Ai;function ki(e,t,n,r){let i=_i(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Ai(){return`!`}ji.peek=Mi;function ji(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Mi(){return`!`}Ni.peek=Pi;function Ni(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Pi(){return"`"}function Fi(e,t){let n=ge(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Ii.peek=Li;function Ii(e,t,n,r){let i=_i(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Fi(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Li(e,t,n){return Fi(e,n)?`<`:`[`}Ri.peek=zi;function Ri(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function zi(){return`[`}function Bi(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Vi(e){let t=Bi(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Hi(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ui(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Wi(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Hi(n):Bi(n),s=e.ordered?o===`.`?`)`:`.`:Vi(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Ui(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Gi(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ki(e,t,n,r){let i=Gi(n),a=n.bulletCurrent||Bi(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function qi(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}const Ji=ar([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Yi(e,t,n,r){return(e.children.some(function(e){return Ji(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Xi(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Zi.peek=Qi;function Zi(e,t,n,r){let i=Xi(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=xi(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=bi(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=xi(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+bi(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Qi(e,t,n){return n.options.strong||`*`}function $i(e,t,n,r){return n.safe(e.value,r)}function ea(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function ta(e,t,n){let r=(Ui(n)+(n.options.ruleSpaces?` `:``)).repeat(ea(n));return n.options.ruleSpaces?r.slice(0,-1):r}const na={blockquote:si,break:di,code:hi,definition:vi,emphasis:Si,hardBreak:di,heading:Ei,html:Di,image:ki,imageReference:ji,inlineCode:Ni,link:Ii,linkReference:Ri,list:Wi,listItem:Ki,paragraph:qi,root:Yi,strong:Zi,text:$i,thematicBreak:ta};function ra(){return{enter:{table:ia,tableData:ca,tableHeader:ca,tableRow:oa},exit:{codeText:la,table:aa,tableData:sa,tableHeader:sa,tableRow:sa}}}function ia(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function aa(e){this.exit(e),this.data.inTable=void 0}function oa(e){this.enter({type:`tableRow`,children:[]},e)}function sa(e){this.exit(e)}function ca(e){this.enter({type:`tableCell`,children:[]},e)}function la(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,ua));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function ua(e,t){return t===`|`?t:e}function da(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
17
17
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
18
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return ii(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=na.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function fa(){return{exit:{taskListCheckValueChecked:ma,taskListCheckValueUnchecked:ma,paragraph:ha}}}function pa(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:ga}}}function ma(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function ha(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function ga(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=na.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function _a(){return[Sr(),Kr(),Zr(),ra(),fa()]}function va(e){return{extensions:[Cr(),qr(e),Qr(),da(e),pa()]}}const ya={tokenize:Aa,partial:!0},ba={tokenize:ja,partial:!0},xa={tokenize:Ma,partial:!0},Sa={tokenize:Na,partial:!0},Ca={tokenize:Pa,partial:!0},wa={name:`wwwAutolink`,tokenize:Oa,previous:Fa},Ta={name:`protocolAutolink`,tokenize:ka,previous:Ia},Z={name:`emailAutolink`,tokenize:Da,previous:La},Q={};function Ea(){return{text:Q}}let $=48;for(;$<123;)Q[$]=Z,$++,$===58?$=65:$===91&&($=97);Q[43]=Z,Q[45]=Z,Q[46]=Z,Q[95]=Z,Q[72]=[Z,Ta],Q[104]=[Z,Ta],Q[87]=[Z,wa],Q[119]=[Z,wa];function Da(e,t,n){let r=this,i,a;return o;function o(t){return!Ra(t)||!La.call(r,r.previous)||za(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Ra(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Ca,u,l)(t):t===45||t===95||V(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&B(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Oa(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Fa.call(r,r.previous)||za(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(ya,e.attempt(ba,e.attempt(xa,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function ka(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Ia.call(r,r.previous)&&!za(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(B(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Oe(t)||U(t)||G(t)||Me(t)?n(t):e.attempt(ba,e.attempt(xa,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Aa(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function ja(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Sa,c,s)(t):t===null||U(t)||G(t)||t!==45&&Me(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Ma(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Sa,t,a)(o):o===null||U(o)||G(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Na(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||U(o)||G(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||U(e)||G(e)?t(e):r(e)}function a(e){return B(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):B(t)?(e.consume(t),o):n(t)}}function Pa(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return V(e)?n(e):t(e)}}function Fa(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||U(e)}function Ia(e){return!B(e)}function La(e){return!(e===47||Ra(e))}function Ra(e){return e===43||e===45||e===46||e===95||V(e)}function za(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Ba={tokenize:Ja,partial:!0};function Va(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Ga,continuation:{tokenize:Ka},exit:qa}},text:{91:{name:`gfmFootnoteCall`,tokenize:Wa},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Ha,resolveTo:Ua}}}}function Ha(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=z(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Ua(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Wa(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||U(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(z(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return U(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Ga(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||U(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=z(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return U(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),q(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Ka(e,t,n){return e.check(Ke,t,e.attempt(Ba,t,n))}function qa(e){e.exit(`gfmFootnoteDefinition`)}function Ja(e,t,n){let r=this;return q(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Ya(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&L(o,o.length,0,ze(s,e.slice(r+1,n),t)),L(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),L(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=J(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=J(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Xa=class{constructor(){this.map=[]}add(e,t,n){Za(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Za(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Qa(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function $a(){return{flow:{null:{name:`table`,tokenize:eo,resolveAll:to}}}}function eo(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):H(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):W(t)?q(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||U(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,W(t)?q(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return W(t)?q(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||H(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return W(t)?q(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||H(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||H(n)?(e.exit(`tableRow`),t(n)):W(n)?q(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||U(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function to(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Xa;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(ro(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=no(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=no(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=no(f,t,o,i,n,d)):(o[0]=o[1],d=no(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&ro(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Qa(t.events,n))}return e}function no(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},io(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=io(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=io(t.events,n[2]),a=io(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},io(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function ro(e,t,n,r,i){let a=[],o=io(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function io(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}const ao={name:`tasklistCheck`,tokenize:so};function oo(){return{text:{91:ao}}}function so(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return U(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return H(r)?t(r):W(r)?e.check({tokenize:co},t,n)(r):n(r)}}function co(e,t,n){return q(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function lo(e){return Ce([Ea(),Va(),Ya(e),$a(),oo()])}const uo={};function fo(e){let t=this,n=e||uo,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(lo(n)),a.push(_a()),o.push(va(n))}function po(e){return oe().use(nr).use(fo).parse(e)}const mo={ts:`typescript`,js:`javascript`,jsx:`javascript`,tsx:`typescript`,py:`python`,rb:`ruby`,sh:`bash`,zsh:`bash`,shell:`bash`,yml:`yaml`,md:`markdown`,rs:`rust`,kt:`kotlin`,tf:`hcl`,dockerfile:`docker`};function ho(e){if(!e)return;let t=e.toLowerCase().trim();if(t)return mo[t]??t}const go=/^<(ins|sub|sup)>$/i,_o=/^<\/(ins|sub|sup)>$/i;function vo(e){let t=e.toLowerCase();return t===`ins`?{type:`underline`}:t===`sub`?{type:`subsup`,attrs:{type:`sub`}}:t===`sup`?{type:`subsup`,attrs:{type:`sup`}}:null}function yo(e){let t=[],n=[];for(let r of e){if(r.type===`html`){let e=go.exec(r.value);if(e){let n=vo(e[1]??``);n&&t.push(n);continue}if(_o.exec(r.value)){t.pop();continue}}n.push(...bo(r,t.slice()))}return n}function bo(e,t){switch(e.type){case`text`:return e.value?[xo(e.value,t)]:[];case`inlineCode`:{let n=[...t.filter(e=>e.type===`link`),{type:`code`}];return[xo(e.value,n)]}case`strong`:return e.children.flatMap(e=>bo(e,[...t,{type:`strong`}]));case`emphasis`:return e.children.flatMap(e=>bo(e,[...t,{type:`em`}]));case`delete`:return e.children.flatMap(e=>bo(e,[...t,{type:`strike`}]));case`link`:{let n={type:`link`,attrs:{href:e.url,...e.title?{title:e.title}:{}}};return e.children.flatMap(e=>bo(e,[...t,n]))}case`image`:return[{type:`inlineCard`,attrs:{url:e.url}}];case`break`:return[{type:`hardBreak`}];case`html`:return So(e.value,t);case`linkReference`:case`imageReference`:return[];default:return[]}}function xo(e,t){let n={type:`text`,text:e};return t.length>0&&(n.marks=t),n}function So(e,t){let n=e.replace(/<[^>]+>/g,``);return n?[xo(n,t)]:[]}function Co(e){return{type:`heading`,attrs:{level:e.depth},content:yo(e.children)}}function wo(e){return{type:`paragraph`,content:yo(e.children)}}function To(e){let t={type:`codeBlock`},n=ho(e.lang);return n&&(t.attrs={language:n}),e.value&&(t.content=[{type:`text`,text:e.value}]),t}function Eo(e){return{type:`rule`}}const Do=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i,Oo={NOTE:`note`,TIP:`info`,IMPORTANT:`warning`,WARNING:`warning`,CAUTION:`error`};function ko(e,t){let n=e.children[0];if(n?.type===`paragraph`){let r=n.children[0];if(r?.type===`text`){let i=Do.exec(r.value);if(i){let a=Oo[(i[1]??`NOTE`).toUpperCase()]??`info`,o=r.value.replace(Do,``).trim(),s=[...n.children.slice(1)],c=[];if(o||s.length>0){let e={type:`paragraph`,children:[...o?[{type:`text`,value:o}]:[],...s]};e.children.length>0&&c.push(wo(e))}let l=e.children.slice(1);return c.push(...t(l)),c.length===0&&c.push({type:`paragraph`,content:[]}),{type:`panel`,attrs:{panelType:a},content:c}}}}let r=t(e.children);return{type:`blockquote`,content:r.length>0?r:[{type:`paragraph`,content:[]}]}}function Ao(e){let t=/<details[^>]*>\s*<summary[^>]*>(.*?)<\/summary>([\s\S]*?)<\/details>/i.exec(e.value);if(t)return{type:`paragraph`,content:[{type:`text`,text:(t[1]??``).trim()}]};let n=e.value.replace(/<[^>]+>/g,``).trim();return n?{type:`paragraph`,content:[{type:`text`,text:n}]}:null}function jo(){return crypto.randomUUID()}function Mo(e,t){return e.children.some(e=>e.checked!==null&&e.checked!==void 0)?Io(e):e.ordered?Po(e,t):No(e,t)}function No(e,t){return{type:`bulletList`,content:e.children.map(e=>Fo(e,t))}}function Po(e,t){let n={type:`orderedList`,content:e.children.map(e=>Fo(e,t))};return e.start!==null&&e.start!==void 0&&e.start!==1&&(n.attrs={order:e.start}),n}function Fo(e,t){let n=[];for(let r of e.children)if(r.type===`paragraph`)n.push({type:`paragraph`,content:yo(r.children)});else if(r.type===`list`){let e=Mo(r,t);e.type===`taskList`?n.length===0&&n.push({type:`paragraph`,content:[]}):(n.length===0&&n.push({type:`paragraph`,content:[]}),n.push(e))}else if(r.type===`code`)n.push({type:`codeBlock`,content:[{type:`text`,text:r.value}],...r.lang?{attrs:{language:r.lang}}:{}});else{let e=t(r);e&&e.type===`paragraph`&&n.push(e)}return n.length===0&&n.push({type:`paragraph`,content:[]}),{type:`listItem`,content:n}}function Io(e){let t=jo(),n=e.children.map(e=>{let t=e.checked===!0?`DONE`:`TODO`,n=e.children.filter(e=>e.type===`paragraph`).flatMap(e=>yo(e.children)),r={type:`taskItem`,attrs:{localId:jo(),state:t}};return n.length>0&&(r.content=n),r});return{type:`taskList`,attrs:{localId:t},content:n}}function Lo(e){let t=e.children;if(t.length===0)return{type:`table`,content:[]};let n=t[0],r=t.slice(1),i=[];n&&i.push({type:`tableRow`,content:n.children.map(e=>Ro(e))});for(let e of r)i.push({type:`tableRow`,content:e.children.map(e=>zo(e))});return{type:`table`,content:i}}function Ro(e){let t=yo(e.children);return{type:`tableHeader`,attrs:{},content:[{type:`paragraph`,content:t.length>0?t:[]}]}}function zo(e){let t=yo(e.children);return{type:`tableCell`,attrs:{},content:[{type:`paragraph`,content:t.length>0?t:[]}]}}function Bo(e){return{version:1,type:`doc`,content:e.children.flatMap(e=>{let t=Vo(e);return t?[t]:[]})}}function Vo(e){switch(e.type){case`heading`:return Co(e);case`paragraph`:return wo(e);case`code`:return To(e);case`thematicBreak`:return Eo(e);case`blockquote`:return ko(e,e=>e.flatMap(e=>{let t=Vo(e);return t?[t]:[]}));case`list`:return Mo(e,Vo);case`table`:return Lo(e);case`html`:return Ao(e);default:return null}}function Ho(e){return e.replace(/\0/g,``)}function Uo(e){return e.replace(/\r\n/g,`
|
|
18
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return ii(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=na.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function fa(){return{exit:{taskListCheckValueChecked:ma,taskListCheckValueUnchecked:ma,paragraph:ha}}}function pa(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:ga}}}function ma(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function ha(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function ga(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=na.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function _a(){return[Sr(),Kr(),Zr(),ra(),fa()]}function va(e){return{extensions:[Cr(),qr(e),Qr(),da(e),pa()]}}const ya={tokenize:Aa,partial:!0},ba={tokenize:ja,partial:!0},xa={tokenize:Ma,partial:!0},Sa={tokenize:Na,partial:!0},Ca={tokenize:Pa,partial:!0},wa={name:`wwwAutolink`,tokenize:Oa,previous:Fa},Ta={name:`protocolAutolink`,tokenize:ka,previous:Ia},Z={name:`emailAutolink`,tokenize:Da,previous:La},Q={};function Ea(){return{text:Q}}let $=48;for(;$<123;)Q[$]=Z,$++,$===58?$=65:$===91&&($=97);Q[43]=Z,Q[45]=Z,Q[46]=Z,Q[95]=Z,Q[72]=[Z,Ta],Q[104]=[Z,Ta],Q[87]=[Z,wa],Q[119]=[Z,wa];function Da(e,t,n){let r=this,i,a;return o;function o(t){return!Ra(t)||!La.call(r,r.previous)||za(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Ra(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Ca,u,l)(t):t===45||t===95||V(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&B(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Oa(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Fa.call(r,r.previous)||za(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(ya,e.attempt(ba,e.attempt(xa,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function ka(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Ia.call(r,r.previous)&&!za(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(B(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Oe(t)||U(t)||G(t)||Me(t)?n(t):e.attempt(ba,e.attempt(xa,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Aa(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function ja(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Sa,c,s)(t):t===null||U(t)||G(t)||t!==45&&Me(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Ma(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Sa,t,a)(o):o===null||U(o)||G(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Na(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||U(o)||G(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||U(e)||G(e)?t(e):r(e)}function a(e){return B(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):B(t)?(e.consume(t),o):n(t)}}function Pa(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return V(e)?n(e):t(e)}}function Fa(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||U(e)}function Ia(e){return!B(e)}function La(e){return!(e===47||Ra(e))}function Ra(e){return e===43||e===45||e===46||e===95||V(e)}function za(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Ba={tokenize:Ja,partial:!0};function Va(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Ga,continuation:{tokenize:Ka},exit:qa}},text:{91:{name:`gfmFootnoteCall`,tokenize:Wa},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Ha,resolveTo:Ua}}}}function Ha(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=z(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Ua(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Wa(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||U(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(z(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return U(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Ga(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||U(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=z(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return U(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),q(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Ka(e,t,n){return e.check(Ke,t,e.attempt(Ba,t,n))}function qa(e){e.exit(`gfmFootnoteDefinition`)}function Ja(e,t,n){let r=this;return q(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Ya(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&L(o,o.length,0,ze(s,e.slice(r+1,n),t)),L(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),L(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=J(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=J(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Xa=class{constructor(){this.map=[]}add(e,t,n){Za(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Za(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Qa(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function $a(){return{flow:{null:{name:`table`,tokenize:eo,resolveAll:to}}}}function eo(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):H(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):W(t)?q(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||U(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,W(t)?q(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return W(t)?q(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||H(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return W(t)?q(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||H(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||H(n)?(e.exit(`tableRow`),t(n)):W(n)?q(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||U(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function to(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Xa;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(ro(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=no(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=no(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=no(f,t,o,i,n,d)):(o[0]=o[1],d=no(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&ro(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Qa(t.events,n))}return e}function no(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},io(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=io(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=io(t.events,n[2]),a=io(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},io(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function ro(e,t,n,r,i){let a=[],o=io(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function io(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}const ao={name:`tasklistCheck`,tokenize:so};function oo(){return{text:{91:ao}}}function so(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return U(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return H(r)?t(r):W(r)?e.check({tokenize:co},t,n)(r):n(r)}}function co(e,t,n){return q(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function lo(e){return Ce([Ea(),Va(),Ya(e),$a(),oo()])}const uo={};function fo(e){let t=this,n=e||uo,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(lo(n)),a.push(_a()),o.push(va(n))}const po=oe().use(nr).use(fo);function mo(e){return po.parse(e)}const ho={ts:`typescript`,js:`javascript`,jsx:`javascript`,tsx:`typescript`,py:`python`,rb:`ruby`,sh:`bash`,zsh:`bash`,shell:`bash`,yml:`yaml`,md:`markdown`,rs:`rust`,kt:`kotlin`,tf:`hcl`,dockerfile:`docker`};function go(e){if(!e)return;let t=e.toLowerCase().trim();if(t)return ho[t]??t}const _o=/^<(ins|sub|sup)>$/i,vo=/^<\/(ins|sub|sup)>$/i;function yo(e){let t=e.toLowerCase();return t===`ins`?{type:`underline`}:t===`sub`?{type:`subsup`,attrs:{type:`sub`}}:t===`sup`?{type:`subsup`,attrs:{type:`sup`}}:null}function bo(e){let t=[],n=[];for(let r of e){if(r.type===`html`){let e=_o.exec(r.value);if(e){let n=yo(e[1]??``);n&&t.push(n);continue}if(vo.exec(r.value)){t.pop();continue}}n.push(...xo(r,t.slice()))}return n}function xo(e,t){switch(e.type){case`text`:return e.value?[So(e.value,t)]:[];case`inlineCode`:{let n=[...t.filter(e=>e.type===`link`),{type:`code`}];return[So(e.value,n)]}case`strong`:return e.children.flatMap(e=>xo(e,[...t,{type:`strong`}]));case`emphasis`:return e.children.flatMap(e=>xo(e,[...t,{type:`em`}]));case`delete`:return e.children.flatMap(e=>xo(e,[...t,{type:`strike`}]));case`link`:{let n={type:`link`,attrs:{href:e.url,...e.title?{title:e.title}:{}}};return e.children.flatMap(e=>xo(e,[...t,n]))}case`image`:return[{type:`inlineCard`,attrs:{url:e.url}}];case`break`:return[{type:`hardBreak`}];case`html`:return Co(e.value,t);case`linkReference`:case`imageReference`:return[];default:return[]}}function So(e,t){let n={type:`text`,text:e};return t.length>0&&(n.marks=t),n}function Co(e,t){let n=e.replace(/<[^>]+>/g,``);return n?[So(n,t)]:[]}function wo(e){return{type:`heading`,attrs:{level:e.depth},content:bo(e.children)}}function To(e){return{type:`paragraph`,content:bo(e.children)}}function Eo(e){let t={type:`codeBlock`},n=go(e.lang);return n&&(t.attrs={language:n}),e.value&&(t.content=[{type:`text`,text:e.value}]),t}function Do(e){return{type:`rule`}}const Oo=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i,ko={NOTE:`note`,TIP:`info`,IMPORTANT:`warning`,WARNING:`warning`,CAUTION:`error`};function Ao(e,t,n){let r=e.children[0].value.replace(Oo,``).trim(),i=e.children.slice(1),a=[];if(r||i.length>0){let e={type:`paragraph`,children:[...r?[{type:`text`,value:r}]:[],...i]};e.children.length>0&&a.push(To(e))}return a.push(...n(t)),a.length===0&&a.push({type:`paragraph`,content:[]}),a}function jo(e,t){let n=e.children[0];if(n?.type!==`paragraph`)return null;let r=n.children[0];if(r?.type!==`text`)return null;let i=Oo.exec(r.value);if(!i)return null;let a=ko[(i[1]??`NOTE`).toUpperCase()]??`info`,o=Ao(n,e.children.slice(1),t);return{type:`panel`,attrs:{panelType:a},content:o}}function Mo(e,t){let n=jo(e,t);if(n)return n;let r=t(e.children);return{type:`blockquote`,content:r.length>0?r:[{type:`paragraph`,content:[]}]}}const No=/^<details[^>]*>\s*<summary[^>]*>([\s\S]*?)<\/summary>\s*$/i,Po=/^<\/details>\s*$/i,Fo=new Set([`paragraph`,`heading`,`bulletList`,`orderedList`,`codeBlock`,`blockquote`,`panel`,`rule`,`table`,`mediaGroup`,`mediaSingle`,`nestedExpand`]);function Io(e){return Fo.has(e.type)}function Lo(e){let t=/^<details[^>]*>\s*/i.exec(e);if(!t)return null;let n=t[0].length,r=e.slice(n),i=/^<summary[^>]*>/i.exec(r);if(!i)return null;n+=i[0].length;let a=e.slice(n),o=a.search(/<\/summary>/i);if(o===-1)return null;let s=a.slice(0,o);n+=o+10;let c=n,l=/<details[^>]*>/gi,u=/<\/details>/gi,d=1;l.lastIndex=c,u.lastIndex=c;let f=-1;for(;d>0;){let t=l.exec(e),r=u.exec(e);if(!r)return null;if(t&&t.index<r.index){d++,u.lastIndex=l.lastIndex;continue}if(d--,d===0){f=r.index,n=r.index+r[0].length;break}l.lastIndex=u.lastIndex}return f===-1||e.slice(n).trim().length>0?null:{title:s,body:e.slice(c,f)}}function Ro(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.type===`html`){let e=i.value;if(No.test(e))n.push(r);else if(Po.test(e)){let e=n.pop();e!==void 0&&t.set(e,r)}}}return t}function zo(e,t){let n=[],r=Ro(e),i=0;for(;i<e.length;){let a=Bo(e,i,r,t);if(a){Io(a.node)&&n.push(a.node),i=a.next;continue}let o=t(e[i]);o&&Io(o)&&n.push(o),i++}return n}function Bo(e,t,n,r){let i=e[t];if(i.type!==`html`)return null;let a=Lo(i.value);if(a){let e=a.title.trim(),n=a.body.trim(),i=n?zo(mo(n).children,r):[];return{node:{type:`expand`,attrs:{title:e},content:i},next:t+1}}let o=No.exec(i.value);if(o){let i=(o[1]??``).trim(),a=n.get(t)??-1;if(a!==-1){let n=zo(e.slice(t+1,a),r);return{node:{type:`expand`,attrs:{title:i},content:n},next:a+1}}}return null}function Vo(e){let t=e.value.replace(/<[^>]+>/g,``).trim();return t?{type:`paragraph`,content:[{type:`text`,text:t}]}:null}function Ho(){return crypto.randomUUID()}function Uo(e,t){return e.children.some(e=>e.checked!==null&&e.checked!==void 0)?qo(e):e.ordered?Go(e,t):Wo(e,t)}function Wo(e,t){return{type:`bulletList`,content:e.children.map(e=>Ko(e,t))}}function Go(e,t){let n={type:`orderedList`,content:e.children.map(e=>Ko(e,t))};return e.start!==null&&e.start!==void 0&&e.start!==1&&(n.attrs={order:e.start}),n}function Ko(e,t){let n=[];for(let r of e.children)if(r.type===`paragraph`)n.push({type:`paragraph`,content:bo(r.children)});else if(r.type===`list`){let e=Uo(r,t);e.type===`taskList`?n.length===0&&n.push({type:`paragraph`,content:[]}):(n.length===0&&n.push({type:`paragraph`,content:[]}),n.push(e))}else if(r.type===`code`)n.push({type:`codeBlock`,content:[{type:`text`,text:r.value}],...r.lang?{attrs:{language:r.lang}}:{}});else{let e=t(r);e&&e.type===`paragraph`&&n.push(e)}return n.length===0&&n.push({type:`paragraph`,content:[]}),{type:`listItem`,content:n}}function qo(e){let t=Ho(),n=e.children.map(e=>{let t=e.checked===!0?`DONE`:`TODO`,n=e.children.filter(e=>e.type===`paragraph`).flatMap(e=>bo(e.children)),r={type:`taskItem`,attrs:{localId:Ho(),state:t}};return n.length>0&&(r.content=n),r});return{type:`taskList`,attrs:{localId:t},content:n}}function Jo(e){let t=e.children;if(t.length===0)return{type:`table`,content:[]};let n=t[0],r=t.slice(1),i=[];n&&i.push({type:`tableRow`,content:n.children.map(e=>Yo(e))});for(let e of r)i.push({type:`tableRow`,content:e.children.map(e=>Xo(e))});return{type:`table`,content:i}}function Yo(e){let t=bo(e.children);return{type:`tableHeader`,attrs:{},content:[{type:`paragraph`,content:t.length>0?t:[]}]}}function Xo(e){let t=bo(e.children);return{type:`tableCell`,attrs:{},content:[{type:`paragraph`,content:t.length>0?t:[]}]}}function Zo(e){return{version:1,type:`doc`,content:Qo(e.children)}}function Qo(e){let t=[],n=Ro(e),r=0;for(;r<e.length;){let i=Bo(e,r,n,$o);if(i){t.push(i.node),r=i.next;continue}let a=$o(e[r]);a&&t.push(a),r++}return t}function $o(e){switch(e.type){case`heading`:return wo(e);case`paragraph`:return To(e);case`code`:return Eo(e);case`thematicBreak`:return Do(e);case`blockquote`:return Mo(e,e=>e.flatMap(e=>{let t=$o(e);return t?[t]:[]}));case`list`:return Uo(e,$o);case`table`:return Jo(e);case`html`:return Vo(e);default:return null}}function es(e){return e.replace(/\0/g,``)}function ts(e){return e.replace(/\r\n/g,`
|
|
19
19
|
`).replace(/\r/g,`
|
|
20
|
-
`)}function
|
|
20
|
+
`)}function ns(e){return e.replace(/[^\S\n]+$/gm,``)}function rs(e){return e.replace(/\n{3,}/g,`
|
|
21
21
|
|
|
22
|
-
`)}function
|
|
23
|
-
`;case`mention`:return e.attrs.text??`@${e.attrs.id}`;case`emoji`:return e.attrs.text??`:${e.attrs.shortName}:`;case`date`:return e.attrs.timestamp;case`status`:return`\`[${e.attrs.text}]\``;case`inlineCard`:return e.attrs.url?`<${e.attrs.url}>`:``;case`mediaInline`:return``;default:return``}}function
|
|
22
|
+
`)}function is(e){return rs(ns(ts(es(e))))}function as(e){return es(ts(e))}function os(e){return Zo(mo(as(e)))}const ss=/([\\`*_[\]~|<])/g;function cs(e){let t=e.replace(ss,`\\$1`);return t=t.replace(/^(#{1,6} )/m,`\\$1`),t=t.replace(/^([-+]) /m,`\\$1 `),t=t.replace(/^> /m,`\\> `),t=t.replace(/^(\d+)\./m,`$1\\.`),t}function ls(e,t){if(!t||t.length===0)return e;let n=e;if(t.some(e=>e.type===`code`)){let e=t.find(e=>e.type===`link`);return n=`\`${n}\``,e&&(n=`[${n}](${e.attrs.href})`),n}for(let e of t)switch(e.type){case`strong`:n=`**${n}**`;break;case`em`:n=`*${n}*`;break;case`strike`:n=`~~${n}~~`;break;case`underline`:n=`<ins>${n}</ins>`;break;case`subsup`:n=e.attrs.type===`sub`?`<sub>${n}</sub>`:`<sup>${n}</sup>`;break;case`link`:n=`[${n}](${e.attrs.href}${e.attrs.title?` "${e.attrs.title}"`:``})`;break;case`textColor`:case`backgroundColor`:case`alignment`:case`indentation`:case`breakout`:case`border`:case`annotation`:case`dataConsumer`:case`fragment`:break}return n}function us(e,t){return!e||e.length===0?``:e.map(e=>ds(e,t)).join(``)}function ds(e,t){switch(e.type){case`text`:return ls(cs(e.text),e.marks);case`hardBreak`:return`\\
|
|
23
|
+
`;case`mention`:return t?.mentions===!1?e.attrs.text??e.attrs.id:e.attrs.text??`@${e.attrs.id}`;case`emoji`:return e.attrs.text??`:${e.attrs.shortName}:`;case`date`:return e.attrs.timestamp;case`status`:return`\`[${e.attrs.text}]\``;case`inlineCard`:return e.attrs.url?`<${e.attrs.url}>`:``;case`mediaInline`:return``;default:return``}}function fs(e,t){return`${`#`.repeat(e.attrs.level)} ${us(e.content,t)}`}function ps(e,t){return us(e.content,t)}function ms(e){return`\`\`\`${e.attrs?.language??``}\n${e.content?.map(e=>e.text).join(``)??``}\n\`\`\``}function hs(e){return`---`}function gs(e,t){return e.content.map(e=>t(e)).join(`
|
|
24
24
|
|
|
25
25
|
`).split(`
|
|
26
26
|
`).map(e=>`> ${e}`).join(`
|
|
27
|
-
`)}function
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
30
|
-
`)}function
|
|
31
|
-
`)}function
|
|
32
|
-
`+
|
|
33
|
-
`+
|
|
27
|
+
`)}function _s(e,t=0,n){return e.content.map(e=>xs(e,`-`,t,n)).join(`
|
|
28
|
+
`)}function vs(e,t=0,n){let r=e.attrs?.order??1;return e.content.map((e,i)=>xs(e,`${r+i}.`,t,n)).join(`
|
|
29
|
+
`)}function ys(e,t=0,n){return e.content.map(e=>`${` `.repeat(t)}- ${e.attrs.state===`DONE`?`[x]`:`[ ]`} ${us(e.content,n)}`).join(`
|
|
30
|
+
`)}function bs(e,t=0,n){return e.content.map(e=>`${` `.repeat(t)}- [x] ${us(e.content,n)}`).join(`
|
|
31
|
+
`)}function xs(e,t,n,r){let i=` `.repeat(n),a=[];for(let t of e.content)if(t.type===`paragraph`)a.push(us(t.content,r));else if(t.type===`bulletList`)a.push(`
|
|
32
|
+
`+_s(t,n+1,r));else if(t.type===`orderedList`)a.push(`
|
|
33
|
+
`+vs(t,n+1,r));else if(t.type===`codeBlock`){let e=t.attrs?.language??``,n=t.content?.map(e=>e.text).join(``)??``;a.push(`\n\`\`\`${e}\n${n}\n\`\`\``)}return`${i}${t} ${a.join(``)}`}const Ss={note:`NOTE`,info:`TIP`,tip:`TIP`,warning:`WARNING`,success:`NOTE`,error:`CAUTION`,custom:`NOTE`};function Cs(e,t){let n=Ss[e.attrs.panelType]??`NOTE`,r=e.content.map(e=>t(e)).join(`
|
|
34
34
|
|
|
35
35
|
`);return[`> [!${n}]`,...r.split(`
|
|
36
36
|
`).map(e=>`> ${e}`)].join(`
|
|
37
|
-
`)}function
|
|
37
|
+
`)}function ws(e,t){return`<details>\n<summary>${e.attrs.title??``}</summary>\n\n${e.content.map(e=>t(e)).join(`
|
|
38
38
|
|
|
39
|
-
`)}\n</details>`}function
|
|
40
|
-
`)}function
|
|
39
|
+
`)}\n</details>`}function Ts(e){let t=e.content[0];if(!t)return``;let n=t.attrs.alt??`image`;if(t.attrs.type===`link`){let e=t.attrs.url;if(e)return``}return`[media: ${t.attrs.id}]`}function Es(e){let t=e.attrs.url;return t?`[${t}](${t})`:``}function Ds(e){return`[${e.attrs.url}](${e.attrs.url})`}function Os(e){let t=e.content;if(t.length===0)return``;let n=t[0];if(!n)return``;let r=n.content.some(e=>e.type===`tableHeader`),i=e=>{let t=e.content.find(e=>e.type===`paragraph`);return t&&us(t.content).trim()||` `},a=[];if(r){let e=n.content.map(i);a.push(`| ${e.join(` | `)} |`),a.push(`| ${e.map(()=>`---`).join(` | `)} |`);for(let e of t.slice(1)){let t=e.content.map(i);a.push(`| ${t.join(` | `)} |`)}}else{let e=n.content.length,r=Array(e).fill(` `);a.push(`| ${r.join(` | `)} |`),a.push(`| ${r.map(()=>`---`).join(` | `)} |`);for(let e of t){let t=e.content.map(i);a.push(`| ${t.join(` | `)} |`)}}return a.join(`
|
|
40
|
+
`)}function ks(e,t){switch(e.type){case`paragraph`:return ps(e,t);case`heading`:return fs(e,t);case`codeBlock`:return ms(e);case`rule`:return hs(e);case`blockquote`:return gs(e,e=>ks(e,t));case`bulletList`:return _s(e,0,t);case`orderedList`:return vs(e,0,t);case`taskList`:return ys(e,0,t);case`decisionList`:return bs(e,0,t);case`table`:return Os(e);case`panel`:return Cs(e,e=>ks(e,t));case`expand`:return ws(e,e=>ks(e,t));case`nestedExpand`:return ws(e,e=>ks(e,t));case`mediaSingle`:return Ts(e);case`blockCard`:return Es(e);case`embedCard`:return Ds(e);case`layoutSection`:return As(e,t);default:return``}}function As(e,t){return e.content.map(e=>e.content.map(e=>ks(e,t)).join(`
|
|
41
41
|
|
|
42
42
|
`)).join(`
|
|
43
43
|
|
|
44
44
|
---
|
|
45
45
|
|
|
46
|
-
`)}function
|
|
46
|
+
`)}function js(e,t){return is(e.content.map(e=>ks(e,t)).filter(e=>e.length>0).join(`
|
|
47
47
|
|
|
48
|
-
`))}export{
|
|
48
|
+
`))}export{js as adfToMd,os as mdToAdf};
|
package/dist/index.cjs
CHANGED
|
@@ -27,8 +27,9 @@ remark_parse = __toESM(remark_parse);
|
|
|
27
27
|
let remark_gfm = require("remark-gfm");
|
|
28
28
|
remark_gfm = __toESM(remark_gfm);
|
|
29
29
|
//#region src/md-to-adf/parser.ts
|
|
30
|
+
const processor = (0, unified.unified)().use(remark_parse.default).use(remark_gfm.default);
|
|
30
31
|
function parseMarkdown(markdown) {
|
|
31
|
-
return
|
|
32
|
+
return processor.parse(markdown);
|
|
32
33
|
}
|
|
33
34
|
//#endregion
|
|
34
35
|
//#region src/utils/language.ts
|
|
@@ -174,41 +175,45 @@ const ALERT_TO_PANEL = {
|
|
|
174
175
|
WARNING: "warning",
|
|
175
176
|
CAUTION: "error"
|
|
176
177
|
};
|
|
177
|
-
function
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
type: "paragraph",
|
|
191
|
-
children: [...remainingFirstParagraphText ? [{
|
|
192
|
-
type: "text",
|
|
193
|
-
value: remainingFirstParagraphText
|
|
194
|
-
}] : [], ...remainingChildren]
|
|
195
|
-
};
|
|
196
|
-
if (newParagraph.children.length > 0) contentNodes.push(transformParagraph(newParagraph));
|
|
197
|
-
}
|
|
198
|
-
const restChildren = node.children.slice(1);
|
|
199
|
-
contentNodes.push(...transformChildren(restChildren));
|
|
200
|
-
if (contentNodes.length === 0) contentNodes.push({
|
|
201
|
-
type: "paragraph",
|
|
202
|
-
content: []
|
|
203
|
-
});
|
|
204
|
-
return {
|
|
205
|
-
type: "panel",
|
|
206
|
-
attrs: { panelType },
|
|
207
|
-
content: contentNodes
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
}
|
|
178
|
+
function buildPanelContent(firstChild, restChildren, transformChildren) {
|
|
179
|
+
const remainingText = firstChild.children[0].value.replace(ALERT_PATTERN, "").trim();
|
|
180
|
+
const remainingInlines = firstChild.children.slice(1);
|
|
181
|
+
const contentNodes = [];
|
|
182
|
+
if (remainingText || remainingInlines.length > 0) {
|
|
183
|
+
const paragraph = {
|
|
184
|
+
type: "paragraph",
|
|
185
|
+
children: [...remainingText ? [{
|
|
186
|
+
type: "text",
|
|
187
|
+
value: remainingText
|
|
188
|
+
}] : [], ...remainingInlines]
|
|
189
|
+
};
|
|
190
|
+
if (paragraph.children.length > 0) contentNodes.push(transformParagraph(paragraph));
|
|
211
191
|
}
|
|
192
|
+
contentNodes.push(...transformChildren(restChildren));
|
|
193
|
+
if (contentNodes.length === 0) contentNodes.push({
|
|
194
|
+
type: "paragraph",
|
|
195
|
+
content: []
|
|
196
|
+
});
|
|
197
|
+
return contentNodes;
|
|
198
|
+
}
|
|
199
|
+
function tryTransformAlert(node, transformChildren) {
|
|
200
|
+
const firstChild = node.children[0];
|
|
201
|
+
if (firstChild?.type !== "paragraph") return null;
|
|
202
|
+
const firstText = firstChild.children[0];
|
|
203
|
+
if (firstText?.type !== "text") return null;
|
|
204
|
+
const match = ALERT_PATTERN.exec(firstText.value);
|
|
205
|
+
if (!match) return null;
|
|
206
|
+
const panelType = ALERT_TO_PANEL[(match[1] ?? "NOTE").toUpperCase()] ?? "info";
|
|
207
|
+
const content = buildPanelContent(firstChild, node.children.slice(1), transformChildren);
|
|
208
|
+
return {
|
|
209
|
+
type: "panel",
|
|
210
|
+
attrs: { panelType },
|
|
211
|
+
content
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function transformBlockquote(node, transformChildren) {
|
|
215
|
+
const panel = tryTransformAlert(node, transformChildren);
|
|
216
|
+
if (panel) return panel;
|
|
212
217
|
const content = transformChildren(node.children);
|
|
213
218
|
return {
|
|
214
219
|
type: "blockquote",
|
|
@@ -219,16 +224,141 @@ function transformBlockquote(node, transformChildren) {
|
|
|
219
224
|
};
|
|
220
225
|
}
|
|
221
226
|
//#endregion
|
|
227
|
+
//#region src/md-to-adf/transform/expand.ts
|
|
228
|
+
const DETAILS_OPENER = /^<details[^>]*>\s*<summary[^>]*>([\s\S]*?)<\/summary>\s*$/i;
|
|
229
|
+
const DETAILS_CLOSER = /^<\/details>\s*$/i;
|
|
230
|
+
const EXPAND_CONTENT_TYPES = new Set([
|
|
231
|
+
"paragraph",
|
|
232
|
+
"heading",
|
|
233
|
+
"bulletList",
|
|
234
|
+
"orderedList",
|
|
235
|
+
"codeBlock",
|
|
236
|
+
"blockquote",
|
|
237
|
+
"panel",
|
|
238
|
+
"rule",
|
|
239
|
+
"table",
|
|
240
|
+
"mediaGroup",
|
|
241
|
+
"mediaSingle",
|
|
242
|
+
"nestedExpand"
|
|
243
|
+
]);
|
|
244
|
+
function isExpandContent(node) {
|
|
245
|
+
return EXPAND_CONTENT_TYPES.has(node.type);
|
|
246
|
+
}
|
|
247
|
+
function parseSingleDetails(html) {
|
|
248
|
+
const detailsOpenMatch = /^<details[^>]*>\s*/i.exec(html);
|
|
249
|
+
if (!detailsOpenMatch) return null;
|
|
250
|
+
let offset = detailsOpenMatch[0].length;
|
|
251
|
+
const afterDetailsOpen = html.slice(offset);
|
|
252
|
+
const summaryOpenMatch = /^<summary[^>]*>/i.exec(afterDetailsOpen);
|
|
253
|
+
if (!summaryOpenMatch) return null;
|
|
254
|
+
offset += summaryOpenMatch[0].length;
|
|
255
|
+
const afterSummaryOpen = html.slice(offset);
|
|
256
|
+
const summaryCloseIdx = afterSummaryOpen.search(/<\/summary>/i);
|
|
257
|
+
if (summaryCloseIdx === -1) return null;
|
|
258
|
+
const title = afterSummaryOpen.slice(0, summaryCloseIdx);
|
|
259
|
+
offset += summaryCloseIdx + 10;
|
|
260
|
+
const bodyStart = offset;
|
|
261
|
+
const openRe = /<details[^>]*>/gi;
|
|
262
|
+
const closeRe = /<\/details>/gi;
|
|
263
|
+
let depth = 1;
|
|
264
|
+
openRe.lastIndex = bodyStart;
|
|
265
|
+
closeRe.lastIndex = bodyStart;
|
|
266
|
+
let closingIndex = -1;
|
|
267
|
+
while (depth > 0) {
|
|
268
|
+
const nextOpen = openRe.exec(html);
|
|
269
|
+
const nextClose = closeRe.exec(html);
|
|
270
|
+
if (!nextClose) return null;
|
|
271
|
+
if (nextOpen && nextOpen.index < nextClose.index) {
|
|
272
|
+
depth++;
|
|
273
|
+
closeRe.lastIndex = openRe.lastIndex;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
depth--;
|
|
277
|
+
if (depth === 0) {
|
|
278
|
+
closingIndex = nextClose.index;
|
|
279
|
+
offset = nextClose.index + nextClose[0].length;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
openRe.lastIndex = closeRe.lastIndex;
|
|
283
|
+
}
|
|
284
|
+
if (closingIndex === -1) return null;
|
|
285
|
+
if (html.slice(offset).trim().length > 0) return null;
|
|
286
|
+
return {
|
|
287
|
+
title,
|
|
288
|
+
body: html.slice(bodyStart, closingIndex)
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function buildDetailsPairs(nodes) {
|
|
292
|
+
const pairs = /* @__PURE__ */ new Map();
|
|
293
|
+
const stack = [];
|
|
294
|
+
for (let idx = 0; idx < nodes.length; idx++) {
|
|
295
|
+
const n = nodes[idx];
|
|
296
|
+
if (n.type === "html") {
|
|
297
|
+
const value = n.value;
|
|
298
|
+
if (DETAILS_OPENER.test(value)) stack.push(idx);
|
|
299
|
+
else if (DETAILS_CLOSER.test(value)) {
|
|
300
|
+
const openerIdx = stack.pop();
|
|
301
|
+
if (openerIdx !== void 0) pairs.set(openerIdx, idx);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return pairs;
|
|
306
|
+
}
|
|
307
|
+
function transformExpandNodes(nodes, transformBlock) {
|
|
308
|
+
const result = [];
|
|
309
|
+
const pairs = buildDetailsPairs(nodes);
|
|
310
|
+
let i = 0;
|
|
311
|
+
while (i < nodes.length) {
|
|
312
|
+
const expand = tryTransformExpand(nodes, i, pairs, transformBlock);
|
|
313
|
+
if (expand) {
|
|
314
|
+
if (isExpandContent(expand.node)) result.push(expand.node);
|
|
315
|
+
i = expand.next;
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
const transformed = transformBlock(nodes[i]);
|
|
319
|
+
if (transformed && isExpandContent(transformed)) result.push(transformed);
|
|
320
|
+
i++;
|
|
321
|
+
}
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
function tryTransformExpand(nodes, i, detailsPairs, transformBlock) {
|
|
325
|
+
const node = nodes[i];
|
|
326
|
+
if (node.type !== "html") return null;
|
|
327
|
+
const parsedDetails = parseSingleDetails(node.value);
|
|
328
|
+
if (parsedDetails) {
|
|
329
|
+
const title = parsedDetails.title.trim();
|
|
330
|
+
const innerContent = parsedDetails.body.trim();
|
|
331
|
+
const content = innerContent ? transformExpandNodes(parseMarkdown(innerContent).children, transformBlock) : [];
|
|
332
|
+
return {
|
|
333
|
+
node: {
|
|
334
|
+
type: "expand",
|
|
335
|
+
attrs: { title },
|
|
336
|
+
content
|
|
337
|
+
},
|
|
338
|
+
next: i + 1
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
const openerMatch = DETAILS_OPENER.exec(node.value);
|
|
342
|
+
if (openerMatch) {
|
|
343
|
+
const title = (openerMatch[1] ?? "").trim();
|
|
344
|
+
const closerIdx = detailsPairs.get(i) ?? -1;
|
|
345
|
+
if (closerIdx !== -1) {
|
|
346
|
+
const content = transformExpandNodes(nodes.slice(i + 1, closerIdx), transformBlock);
|
|
347
|
+
return {
|
|
348
|
+
node: {
|
|
349
|
+
type: "expand",
|
|
350
|
+
attrs: { title },
|
|
351
|
+
content
|
|
352
|
+
},
|
|
353
|
+
next: closerIdx + 1
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
//#endregion
|
|
222
360
|
//#region src/md-to-adf/transform/inlines.ts
|
|
223
361
|
function transformHtmlBlock(node) {
|
|
224
|
-
const detailsMatch = /<details[^>]*>\s*<summary[^>]*>(.*?)<\/summary>([\s\S]*?)<\/details>/i.exec(node.value);
|
|
225
|
-
if (detailsMatch) return {
|
|
226
|
-
type: "paragraph",
|
|
227
|
-
content: [{
|
|
228
|
-
type: "text",
|
|
229
|
-
text: (detailsMatch[1] ?? "").trim()
|
|
230
|
-
}]
|
|
231
|
-
};
|
|
232
362
|
const stripped = node.value.replace(/<[^>]+>/g, "").trim();
|
|
233
363
|
if (!stripped) return null;
|
|
234
364
|
return {
|
|
@@ -382,12 +512,26 @@ function transformRoot(root) {
|
|
|
382
512
|
return {
|
|
383
513
|
version: 1,
|
|
384
514
|
type: "doc",
|
|
385
|
-
content: root.children
|
|
386
|
-
const result = transformBlock(node);
|
|
387
|
-
return result ? [result] : [];
|
|
388
|
-
})
|
|
515
|
+
content: transformNodes(root.children)
|
|
389
516
|
};
|
|
390
517
|
}
|
|
518
|
+
function transformNodes(nodes) {
|
|
519
|
+
const result = [];
|
|
520
|
+
const detailsPairs = buildDetailsPairs(nodes);
|
|
521
|
+
let i = 0;
|
|
522
|
+
while (i < nodes.length) {
|
|
523
|
+
const expand = tryTransformExpand(nodes, i, detailsPairs, transformBlock);
|
|
524
|
+
if (expand) {
|
|
525
|
+
result.push(expand.node);
|
|
526
|
+
i = expand.next;
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
const transformed = transformBlock(nodes[i]);
|
|
530
|
+
if (transformed) result.push(transformed);
|
|
531
|
+
i++;
|
|
532
|
+
}
|
|
533
|
+
return result;
|
|
534
|
+
}
|
|
391
535
|
function transformBlock(node) {
|
|
392
536
|
switch (node.type) {
|
|
393
537
|
case "heading": return transformHeading(node);
|
|
@@ -484,15 +628,17 @@ function applyMarks(text, marks) {
|
|
|
484
628
|
}
|
|
485
629
|
//#endregion
|
|
486
630
|
//#region src/adf-to-md/serialize/inlines.ts
|
|
487
|
-
function serializeInlineNodes(nodes) {
|
|
631
|
+
function serializeInlineNodes(nodes, options) {
|
|
488
632
|
if (!nodes || nodes.length === 0) return "";
|
|
489
|
-
return nodes.map(serializeInline).join("");
|
|
633
|
+
return nodes.map((node) => serializeInline(node, options)).join("");
|
|
490
634
|
}
|
|
491
|
-
function serializeInline(node) {
|
|
635
|
+
function serializeInline(node, options) {
|
|
492
636
|
switch (node.type) {
|
|
493
637
|
case "text": return applyMarks(escapeMarkdown(node.text), node.marks);
|
|
494
638
|
case "hardBreak": return "\\\n";
|
|
495
|
-
case "mention":
|
|
639
|
+
case "mention":
|
|
640
|
+
if (options?.mentions === false) return node.attrs.text ?? node.attrs.id;
|
|
641
|
+
return node.attrs.text ?? `@${node.attrs.id}`;
|
|
496
642
|
case "emoji": return node.attrs.text ?? `:${node.attrs.shortName}:`;
|
|
497
643
|
case "date": return node.attrs.timestamp;
|
|
498
644
|
case "status": return `\`[${node.attrs.text}]\``;
|
|
@@ -503,11 +649,11 @@ function serializeInline(node) {
|
|
|
503
649
|
}
|
|
504
650
|
//#endregion
|
|
505
651
|
//#region src/adf-to-md/serialize/blocks.ts
|
|
506
|
-
function serializeHeading(node) {
|
|
507
|
-
return `${"#".repeat(node.attrs.level)} ${serializeInlineNodes(node.content)}`;
|
|
652
|
+
function serializeHeading(node, options) {
|
|
653
|
+
return `${"#".repeat(node.attrs.level)} ${serializeInlineNodes(node.content, options)}`;
|
|
508
654
|
}
|
|
509
|
-
function serializeParagraph(node) {
|
|
510
|
-
return serializeInlineNodes(node.content);
|
|
655
|
+
function serializeParagraph(node, options) {
|
|
656
|
+
return serializeInlineNodes(node.content, options);
|
|
511
657
|
}
|
|
512
658
|
function serializeCodeBlock(node) {
|
|
513
659
|
return `\`\`\`${node.attrs?.language ?? ""}\n${node.content?.map((t) => t.text).join("") ?? ""}\n\`\`\``;
|
|
@@ -520,29 +666,29 @@ function serializeBlockquote(node, serializeBlock) {
|
|
|
520
666
|
}
|
|
521
667
|
//#endregion
|
|
522
668
|
//#region src/adf-to-md/serialize/lists.ts
|
|
523
|
-
function serializeBulletList(node, depth = 0) {
|
|
524
|
-
return node.content.map((item) => serializeListItem(item, "-", depth)).join("\n");
|
|
669
|
+
function serializeBulletList(node, depth = 0, options) {
|
|
670
|
+
return node.content.map((item) => serializeListItem(item, "-", depth, options)).join("\n");
|
|
525
671
|
}
|
|
526
|
-
function serializeOrderedList(node, depth = 0) {
|
|
672
|
+
function serializeOrderedList(node, depth = 0, options) {
|
|
527
673
|
const start = node.attrs?.order ?? 1;
|
|
528
|
-
return node.content.map((item, i) => serializeListItem(item, `${start + i}.`, depth)).join("\n");
|
|
674
|
+
return node.content.map((item, i) => serializeListItem(item, `${start + i}.`, depth, options)).join("\n");
|
|
529
675
|
}
|
|
530
|
-
function serializeTaskList(node, depth = 0) {
|
|
676
|
+
function serializeTaskList(node, depth = 0, options) {
|
|
531
677
|
return node.content.map((item) => {
|
|
532
|
-
return `${" ".repeat(depth)}- ${item.attrs.state === "DONE" ? "[x]" : "[ ]"} ${serializeInlineNodes(item.content)}`;
|
|
678
|
+
return `${" ".repeat(depth)}- ${item.attrs.state === "DONE" ? "[x]" : "[ ]"} ${serializeInlineNodes(item.content, options)}`;
|
|
533
679
|
}).join("\n");
|
|
534
680
|
}
|
|
535
|
-
function serializeDecisionList(node, depth = 0) {
|
|
681
|
+
function serializeDecisionList(node, depth = 0, options) {
|
|
536
682
|
return node.content.map((item) => {
|
|
537
|
-
return `${" ".repeat(depth)}- [x] ${serializeInlineNodes(item.content)}`;
|
|
683
|
+
return `${" ".repeat(depth)}- [x] ${serializeInlineNodes(item.content, options)}`;
|
|
538
684
|
}).join("\n");
|
|
539
685
|
}
|
|
540
|
-
function serializeListItem(node, bullet, depth) {
|
|
686
|
+
function serializeListItem(node, bullet, depth, options) {
|
|
541
687
|
const indent = " ".repeat(depth);
|
|
542
688
|
const parts = [];
|
|
543
|
-
for (const child of node.content) if (child.type === "paragraph") parts.push(serializeInlineNodes(child.content));
|
|
544
|
-
else if (child.type === "bulletList") parts.push("\n" + serializeBulletList(child, depth + 1));
|
|
545
|
-
else if (child.type === "orderedList") parts.push("\n" + serializeOrderedList(child, depth + 1));
|
|
689
|
+
for (const child of node.content) if (child.type === "paragraph") parts.push(serializeInlineNodes(child.content, options));
|
|
690
|
+
else if (child.type === "bulletList") parts.push("\n" + serializeBulletList(child, depth + 1, options));
|
|
691
|
+
else if (child.type === "orderedList") parts.push("\n" + serializeOrderedList(child, depth + 1, options));
|
|
546
692
|
else if (child.type === "codeBlock") {
|
|
547
693
|
const lang = child.attrs?.language ?? "";
|
|
548
694
|
const code = child.content?.map((t) => t.text).join("") ?? "";
|
|
@@ -623,35 +769,35 @@ function serializeTable(node) {
|
|
|
623
769
|
}
|
|
624
770
|
//#endregion
|
|
625
771
|
//#region src/adf-to-md/serialize/index.ts
|
|
626
|
-
function serializeBlock(node) {
|
|
772
|
+
function serializeBlock(node, options) {
|
|
627
773
|
switch (node.type) {
|
|
628
|
-
case "paragraph": return serializeParagraph(node);
|
|
629
|
-
case "heading": return serializeHeading(node);
|
|
774
|
+
case "paragraph": return serializeParagraph(node, options);
|
|
775
|
+
case "heading": return serializeHeading(node, options);
|
|
630
776
|
case "codeBlock": return serializeCodeBlock(node);
|
|
631
777
|
case "rule": return serializeRule(node);
|
|
632
|
-
case "blockquote": return serializeBlockquote(node, serializeBlock);
|
|
633
|
-
case "bulletList": return serializeBulletList(node);
|
|
634
|
-
case "orderedList": return serializeOrderedList(node);
|
|
635
|
-
case "taskList": return serializeTaskList(node);
|
|
636
|
-
case "decisionList": return serializeDecisionList(node);
|
|
778
|
+
case "blockquote": return serializeBlockquote(node, (n) => serializeBlock(n, options));
|
|
779
|
+
case "bulletList": return serializeBulletList(node, 0, options);
|
|
780
|
+
case "orderedList": return serializeOrderedList(node, 0, options);
|
|
781
|
+
case "taskList": return serializeTaskList(node, 0, options);
|
|
782
|
+
case "decisionList": return serializeDecisionList(node, 0, options);
|
|
637
783
|
case "table": return serializeTable(node);
|
|
638
|
-
case "panel": return serializePanel(node, serializeBlock);
|
|
639
|
-
case "expand": return serializeExpand(node, serializeBlock);
|
|
640
|
-
case "nestedExpand": return serializeExpand(node, serializeBlock);
|
|
784
|
+
case "panel": return serializePanel(node, (n) => serializeBlock(n, options));
|
|
785
|
+
case "expand": return serializeExpand(node, (n) => serializeBlock(n, options));
|
|
786
|
+
case "nestedExpand": return serializeExpand(node, (n) => serializeBlock(n, options));
|
|
641
787
|
case "mediaSingle": return serializeMediaSingle(node);
|
|
642
788
|
case "blockCard": return serializeBlockCard(node);
|
|
643
789
|
case "embedCard": return serializeEmbedCard(node);
|
|
644
|
-
case "layoutSection": return serializeLayoutSection(node);
|
|
790
|
+
case "layoutSection": return serializeLayoutSection(node, options);
|
|
645
791
|
default: return "";
|
|
646
792
|
}
|
|
647
793
|
}
|
|
648
|
-
function serializeLayoutSection(node) {
|
|
649
|
-
return node.content.map((col) => col.content.map((child) => serializeBlock(child)).join("\n\n")).join("\n\n---\n\n");
|
|
794
|
+
function serializeLayoutSection(node, options) {
|
|
795
|
+
return node.content.map((col) => col.content.map((child) => serializeBlock(child, options)).join("\n\n")).join("\n\n---\n\n");
|
|
650
796
|
}
|
|
651
797
|
//#endregion
|
|
652
798
|
//#region src/adf-to-md/index.ts
|
|
653
|
-
function adfToMd(adf) {
|
|
654
|
-
return sanitizeMarkdown(adf.content.map((node) => serializeBlock(node)).filter((p) => p.length > 0).join("\n\n"));
|
|
799
|
+
function adfToMd(adf, options) {
|
|
800
|
+
return sanitizeMarkdown(adf.content.map((node) => serializeBlock(node, options)).filter((p) => p.length > 0).join("\n\n"));
|
|
655
801
|
}
|
|
656
802
|
//#endregion
|
|
657
803
|
exports.adfToMd = adfToMd;
|
package/dist/index.d.cts
CHANGED
|
@@ -403,11 +403,23 @@ interface AdfDoc {
|
|
|
403
403
|
content: AdfTopLevelBlockNode[];
|
|
404
404
|
}
|
|
405
405
|
//#endregion
|
|
406
|
+
//#region src/types/options.d.ts
|
|
407
|
+
interface AdfToMdOptions {
|
|
408
|
+
/**
|
|
409
|
+
* Whether to render ADF mention nodes as tagged mentions. When `true`
|
|
410
|
+
* (default), a mention renders as the display text if available, otherwise
|
|
411
|
+
* as `@{id}`. When `false`, it renders as plain text: the display text if
|
|
412
|
+
* available, otherwise just the bare `{id}` without the `@` prefix.
|
|
413
|
+
* @default true
|
|
414
|
+
*/
|
|
415
|
+
mentions?: boolean;
|
|
416
|
+
}
|
|
417
|
+
//#endregion
|
|
406
418
|
//#region src/md-to-adf/index.d.ts
|
|
407
419
|
declare function mdToAdf(markdown: string): AdfDoc;
|
|
408
420
|
//#endregion
|
|
409
421
|
//#region src/adf-to-md/index.d.ts
|
|
410
|
-
declare function adfToMd(adf: AdfDoc): string;
|
|
422
|
+
declare function adfToMd(adf: AdfDoc, options?: AdfToMdOptions): string;
|
|
411
423
|
//#endregion
|
|
412
|
-
export { type AdfDoc, type AdfInlineNode, type AdfMark, type AdfNode, type AnnotationMark, type BackgroundColorMark, type BlockCardNode, type BlockquoteNode, type BulletListNode, type CodeBlockNode, type CodeMark, type DateNode, type DecisionItemNode, type DecisionListNode, type EmMark, type EmbedCardNode, type EmojiNode, type ExpandNode, type HardBreakNode, type HeadingNode, type InlineCardNode, type LayoutColumnNode, type LayoutSectionNode, type LinkMark, type ListItemNode, type MediaGroupNode, type MediaNode, type MediaSingleNode, type MentionNode, type NestedExpandNode, type OrderedListNode, type PanelNode, type ParagraphNode, type RuleNode, type StatusNode, type StrikeMark, type StrongMark, type SubsupMark, type TableCellNode, type TableHeaderNode, type TableNode, type TableRowNode, type TaskItemNode, type TaskListNode, type TextColorMark, type TextNode, type UnderlineMark, adfToMd, mdToAdf };
|
|
424
|
+
export { type AdfDoc, type AdfInlineNode, type AdfMark, type AdfNode, type AdfToMdOptions, type AnnotationMark, type BackgroundColorMark, type BlockCardNode, type BlockquoteNode, type BulletListNode, type CodeBlockNode, type CodeMark, type DateNode, type DecisionItemNode, type DecisionListNode, type EmMark, type EmbedCardNode, type EmojiNode, type ExpandNode, type HardBreakNode, type HeadingNode, type InlineCardNode, type LayoutColumnNode, type LayoutSectionNode, type LinkMark, type ListItemNode, type MediaGroupNode, type MediaNode, type MediaSingleNode, type MentionNode, type NestedExpandNode, type OrderedListNode, type PanelNode, type ParagraphNode, type RuleNode, type StatusNode, type StrikeMark, type StrongMark, type SubsupMark, type TableCellNode, type TableHeaderNode, type TableNode, type TableRowNode, type TaskItemNode, type TaskListNode, type TextColorMark, type TextNode, type UnderlineMark, adfToMd, mdToAdf };
|
|
413
425
|
//# sourceMappingURL=index.d.cts.map
|