@mdgate/ipynb 0.5.1 → 0.5.3
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/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -7,4 +7,4 @@ import{ConvertError as k}from"@mdgate/core";import{documentToMarkdown as F}from"
|
|
|
7
7
|
`),i=0;while(i<e.length){let o=e[i];if(o.trim().length===0){i+=1;continue}let s=o.match(/^(```+|~~~+)(.*)$/);if(s!==null){let l=s[1],f=s[2].trim(),x=[];i+=1;while(i<e.length&&!e[i].startsWith(l))x.push(e[i]),i+=1;if(i<e.length)i+=1;n.blocks.push({type:"codeBlock",lang:f.length>0?f:void 0,text:x.join(`
|
|
8
8
|
`)});continue}let u=o.match(/^(#{1,6})[ \t]+(.*)$/);if(u!==null){let l=u[2].replace(/[ \t]+#*[ \t]*$/,"").trim();if(l.length>0)n.blocks.push(v(u[1].length,d(l)));i+=1;continue}if(I(o)){n.blocks.push({type:"rule"}),i+=1;continue}if(/^>[ \t]?/.test(o)){let l=[];while(i<e.length&&/^>[ \t]?/.test(e[i]))l.push(e[i].replace(/^>[ \t]?/,"")),i+=1;let f=_();if(m(f,l.join(`
|
|
9
9
|
`)),f.blocks.length>0)n.blocks.push({type:"blockQuote",blocks:f.blocks});continue}if(N(o)){i=B(n,e,i);continue}let w=[o];i+=1;while(i<e.length&&e[i].trim().length>0&&!J(e[i]))w.push(e[i]),i+=1;n.blocks.push({type:"paragraph",inlines:d(w.join(`
|
|
10
|
-
`))})}}function I(n){let r=n.trim();return/^(\*[ \t]*){3,}$/.test(r)||/^(-[ \t]*){3,}$/.test(r)||/^(_[ \t]*){3,}$/.test(r)}function N(n){return/^\s*(?:[-*+]|\d+[.)])\s+\S/.test(n)}function J(n){return/^(```+|~~~+)/.test(n)||/^#{1,6}[ \t]+/.test(n)||I(n)||/^>[ \t]?/.test(n)||N(n)}function B(n,r,t){let e=/^\s*\d+[.)]\s+\S/.test(r[t]),i=e?/^\s*\d+[.)]\s+(.*)$/:/^\s*[-*+]\s+(.*)$/,o=[],s=t;while(s<r.length){let u=r[s].match(i);if(u===null)break;o.push({blocks:[{type:"paragraph",inlines:d(u[1])}],checked:void 0,markerLabel:void 0}),s+=1}if(o.length>0)n.blocks.push({type:"list",list:{marker:e?"decimal":"bullet",start:1,items:o}});return s}function d(n){let r=[],t="",e=0,i=()=>{if(t.length===0)return;r.push(g(t)),t=""};while(e<n.length){if(n.startsWith("![",e)){let o=A(n,e+1);if(o!==void 0){i(),r.push({type:"image",alt:o.label,source:{type:"external",url:o.url}}),e=o.end;continue}}if(n[e]==="["){let o=A(n,e);if(o!==void 0){i(),r.push({type:"link",content:[g(o.label)],target:{type:"external",url:o.url}}),e=o.end;continue}}if(n[e]==="`"){let o=n.indexOf("`",e+1);if(o>e+1){i(),r.push({type:"text",text:n.slice(e+1,o),style:S}),e=o+1;continue}}if(n.startsWith("**",e)||n.startsWith("__",e)){let o=n.slice(e,e+2),s=n.indexOf(o,e+2);if(s>e+2){i(),r.push({type:"text",text:n.slice(e+2,s),style:{...R,bold:!0}}),e=s+2;continue}}t+=n[e],e+=1}return i(),r.length>0?r:[g("")]}function A(n,r){if(n[r]!=="[")return;let t=n.indexOf("]",r+1);if(t<0||n[t+1]!=="(")return;let e=n.indexOf(")",t+2);if(e<0)return;return{label:n.slice(r+1,t),url:n.slice(t+2,e),end:e+1}}function b(){return{id:"ipynb",sniff(n,r){if(D(n))return
|
|
10
|
+
`))})}}function I(n){let r=n.trim();return/^(\*[ \t]*){3,}$/.test(r)||/^(-[ \t]*){3,}$/.test(r)||/^(_[ \t]*){3,}$/.test(r)}function N(n){return/^\s*(?:[-*+]|\d+[.)])\s+\S/.test(n)}function J(n){return/^(```+|~~~+)/.test(n)||/^#{1,6}[ \t]+/.test(n)||I(n)||/^>[ \t]?/.test(n)||N(n)}function B(n,r,t){let e=/^\s*\d+[.)]\s+\S/.test(r[t]),i=e?/^\s*\d+[.)]\s+(.*)$/:/^\s*[-*+]\s+(.*)$/,o=[],s=t;while(s<r.length){let u=r[s].match(i);if(u===null)break;o.push({blocks:[{type:"paragraph",inlines:d(u[1])}],checked:void 0,markerLabel:void 0}),s+=1}if(o.length>0)n.blocks.push({type:"list",list:{marker:e?"decimal":"bullet",start:1,items:o}});return s}function d(n){let r=[],t="",e=0,i=()=>{if(t.length===0)return;r.push(g(t)),t=""};while(e<n.length){if(n.startsWith("![",e)){let o=A(n,e+1);if(o!==void 0){i(),r.push({type:"image",alt:o.label,source:{type:"external",url:o.url}}),e=o.end;continue}}if(n[e]==="["){let o=A(n,e);if(o!==void 0){i(),r.push({type:"link",content:[g(o.label)],target:{type:"external",url:o.url}}),e=o.end;continue}}if(n[e]==="`"){let o=n.indexOf("`",e+1);if(o>e+1){i(),r.push({type:"text",text:n.slice(e+1,o),style:S}),e=o+1;continue}}if(n.startsWith("**",e)||n.startsWith("__",e)){let o=n.slice(e,e+2),s=n.indexOf(o,e+2);if(s>e+2){i(),r.push({type:"text",text:n.slice(e+2,s),style:{...R,bold:!0}}),e=s+2;continue}}t+=n[e],e+=1}return i(),r.length>0?r:[g("")]}function A(n,r){if(n[r]!=="[")return;let t=n.indexOf("]",r+1);if(t<0||n[t+1]!=="(")return;let e=n.indexOf(")",t+2);if(e<0)return;return{label:n.slice(r+1,t),url:n.slice(t+2,e),end:e+1}}function b(){return{id:"ipynb",sniff(n,r){if(D(n))return 3;if(r?.path!==void 0&&H(r.path)==="ipynb")return 1;return 0},convert(n){return M(n),{markdown:F(C(n))}}}}function M(n){if(y(n,[37,80,68,70,45]))throw k.unsupported("pdf");if(y(n,[208,207,17,224,161,177,26,225]))throw k.unsupported("ole");if(y(n,[80,75,3,4]))throw k.unsupported("zip")}function y(n,r){if(n.length<r.length)return!1;for(let t=0;t<r.length;t+=1)if(n[t]!==r[t])return!1;return!0}import{create as P}from"@mdgate/core";var q=P([b()]);function z(n,r){return q(n,r)}export{z as toMarkdown,b as ipynb};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdgate/ipynb",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "mdgate Jupyter notebook converter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"prepublishOnly": "bun run build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mdgate/core": "0.5.
|
|
26
|
-
"@mdgate/document": "0.5.
|
|
27
|
-
"@mdgate/utils": "0.5.
|
|
25
|
+
"@mdgate/core": "0.5.3",
|
|
26
|
+
"@mdgate/document": "0.5.3",
|
|
27
|
+
"@mdgate/utils": "0.5.3"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|