@mdgate/html 0.6.7 → 0.6.9
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 +146 -8
- package/dist/index.js +2 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# @mdgate/html
|
|
2
2
|
|
|
3
|
-
Convert HTML
|
|
4
|
-
Edge, and browsers. No native addons.
|
|
3
|
+
**Convert HTML to Markdown in TypeScript.**
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
[`@mdgate/html`](https://github.com/mdgate/converters/tree/main/packages/html) reads `.html`, `.htm`, `.html4`, `.html5`, `.xhtml`, `.mhtml`, and `.mht` files directly in JavaScript and converts them into GitHub-Flavored Markdown, without Python, native addons, WASM, or a browser engine.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Works in **Node.js, Cloudflare Workers, Edge runtimes, and browsers**.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mdgate/html
|
|
11
|
+
```
|
|
9
12
|
|
|
10
13
|
```ts
|
|
11
14
|
import { toMarkdown } from '@mdgate/html';
|
|
@@ -13,14 +16,149 @@ import { toMarkdown } from '@mdgate/html';
|
|
|
13
16
|
const markdown = await toMarkdown(bytes);
|
|
14
17
|
```
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
`bytes` is a `Uint8Array`, so the page can come from a file upload, a crawl, an HTTP response, a browser file picker, or anywhere else your application gets bytes.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Why [`@mdgate/html`](https://github.com/mdgate/converters/tree/main/packages/html)
|
|
24
|
+
|
|
25
|
+
HTML is the interchange format for saved pages, MHTML archives, and a lot of "export as web page" output from office tools.
|
|
26
|
+
|
|
27
|
+
[`@mdgate/html`](https://github.com/mdgate/converters/tree/main/packages/html) is an HTML reader written for the same runtime as your application:
|
|
28
|
+
|
|
29
|
+
* **Pure TypeScript**
|
|
30
|
+
* **HTML → Markdown locally**
|
|
31
|
+
* **No Python runtime**
|
|
32
|
+
* **No native addons**
|
|
33
|
+
* **No WASM runtime**
|
|
34
|
+
* **Zero third-party runtime dependencies**
|
|
35
|
+
* **Works with raw `Uint8Array` input**
|
|
36
|
+
* **Detects HTML and MHTML from their contents, not only the filename**
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## What it extracts
|
|
41
|
+
|
|
42
|
+
[`@mdgate/html`](https://github.com/mdgate/converters/tree/main/packages/html) parses the markup, walks the tree, and rebuilds a shared document model.
|
|
43
|
+
|
|
44
|
+
The converter handles HTML-specific concerns including:
|
|
45
|
+
|
|
46
|
+
* headings, paragraphs, and block quotes
|
|
47
|
+
* bold, italic, strikethrough, and inline code
|
|
48
|
+
* links and relative URLs
|
|
49
|
+
* ordered, unordered, and nested lists
|
|
50
|
+
* tables, including spanning cells
|
|
51
|
+
* code blocks
|
|
52
|
+
* MHTML / MHT archives (MIME-wrapped HTML)
|
|
53
|
+
* XHTML
|
|
54
|
+
|
|
55
|
+
The output is Markdown that can be searched, indexed, chunked, cached, or passed directly to an AI agent.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Node.js
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { readFile } from 'node:fs/promises';
|
|
63
|
+
import { toMarkdown } from '@mdgate/html';
|
|
64
|
+
|
|
65
|
+
const bytes = new Uint8Array(await readFile('page.html'));
|
|
66
|
+
const markdown = await toMarkdown(bytes);
|
|
67
|
+
|
|
68
|
+
console.log(markdown);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Browser
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { toMarkdown } from '@mdgate/html';
|
|
77
|
+
|
|
78
|
+
const file = input.files![0];
|
|
79
|
+
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
80
|
+
|
|
81
|
+
const markdown = await toMarkdown(bytes);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Cloudflare Workers and Edge runtimes
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { toMarkdown } from '@mdgate/html';
|
|
90
|
+
|
|
91
|
+
export default {
|
|
92
|
+
async fetch(request: Request) {
|
|
93
|
+
const bytes = new Uint8Array(await request.arrayBuffer());
|
|
94
|
+
const markdown = await toMarkdown(bytes);
|
|
95
|
+
|
|
96
|
+
return new Response(markdown, {
|
|
97
|
+
headers: {
|
|
98
|
+
'content-type': 'text/markdown; charset=utf-8',
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Format detection
|
|
108
|
+
|
|
109
|
+
You do not need to trust the file extension.
|
|
110
|
+
|
|
111
|
+
[`@mdgate/html`](https://github.com/mdgate/converters/tree/main/packages/html) recognizes HTML and MHTML from their contents.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
const markdown = await toMarkdown(bytes);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
A path can still be supplied as a format hint when [`@mdgate/html`](https://github.com/mdgate/converters/tree/main/packages/html) is used through [`@mdgate/converters`](https://github.com/mdgate/converters/tree/main/packages/converters) or a reader composed with [`@mdgate/core`](https://github.com/mdgate/converters/tree/main/packages/core), but the path is never used to read a file from disk.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Compose it with other file readers
|
|
122
|
+
|
|
123
|
+
[`@mdgate/html`](https://github.com/mdgate/converters/tree/main/packages/html) implements the converter interface from [`@mdgate/core`](https://github.com/mdgate/converters/tree/main/packages/core).
|
|
17
124
|
|
|
18
125
|
```ts
|
|
19
126
|
import { create } from '@mdgate/core';
|
|
20
127
|
import { html } from '@mdgate/html';
|
|
128
|
+
import { email } from '@mdgate/email';
|
|
129
|
+
|
|
130
|
+
const read = create([
|
|
131
|
+
html(),
|
|
132
|
+
email(),
|
|
133
|
+
]);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The application still uses one reading interface while each format remains independently installable.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Need more than HTML?
|
|
141
|
+
|
|
142
|
+
If your application needs to read many different file types, use the complete converter set:
|
|
21
143
|
|
|
22
|
-
|
|
144
|
+
```bash
|
|
145
|
+
npm install @mdgate/converters
|
|
23
146
|
```
|
|
24
147
|
|
|
25
|
-
|
|
26
|
-
|
|
148
|
+
```ts
|
|
149
|
+
import { toMarkdown } from '@mdgate/converters';
|
|
150
|
+
|
|
151
|
+
const markdown = await toMarkdown(bytes, {
|
|
152
|
+
path: filename,
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
[`@mdgate/html`](https://github.com/mdgate/converters/tree/main/packages/html) is one of the single-format packages in the open-source [`mdgate/converters`](https://github.com/mdgate/converters) project.
|
|
157
|
+
|
|
158
|
+
For AI agents, the same converter architecture can be used to extend `read_file` from text files to real-world document formats.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{hasOleMagic as Y0}from"@mdgate/containers";import{ConvertError as O}from"@mdgate/core";import{documentToMarkdown as Wf}from"@mdgate/document";import{fileExtension as _f}from"@mdgate/utils";import{decodeFragment as J0,mimeHeader as Xf,mimeTextHtml as Q0,mimeTextPlain as $0,parseMime as K0,parseXml as F0,walkMimeParts as V0}from"@mdgate/containers";import{ConvertError as Z0}from"@mdgate/core";import{emptyDocument as Mf,plain as G0}from"@mdgate/document";import{AssetSink as Df,mediaTypeFor as j0}from"@mdgate/office-common";import{decode as w0,isAbsoluteUri as Hf,trim as Cf}from"@mdgate/utils";import{Element as m}from"@mdgate/containers";var l=new Set(["area","base","basefont","bgsound","br","col","embed","frame","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Rf=new Set(["script","style","textarea","title","noscript"]),uf=new Set(["address","article","aside","blockquote","div","dl","fieldset","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","nav","ol","p","pre","section","table","ul"]);function t(f){let U=[],z=0;while(z<f.length){if(f.charCodeAt(z)!==60){z+=1;continue}if(f.startsWith("<!--",z)){let Q=f.indexOf("-->",z+4);if(Q<0)return!1;z=Q+3;continue}if(f.startsWith("<![CDATA[",z)){let Q=f.indexOf("]]>",z+9);if(Q<0)return!1;z=Q+3;continue}if(f.startsWith("<?",z)){let Q=f.indexOf("?>",z+2);if(Q<0)return!1;z=Q+2;continue}if(f.startsWith("<!",z)){let Q=s(f,z);if(Q<0)return!1;z=Q;continue}if(f.startsWith("</",z)){z+=2;let Q=B(f,z);if(Q.length===0)return!1;if(z+=Q.length,z=D(f,z),f[z]!==">")return!1;z+=1;let F=U.pop();if(F===void 0||F!==Q)return!1;continue}z+=1;let J=B(f,z);if(J.length===0)return!1;z+=J.length;let $=Tf(f,z);if($===void 0)return!1;if(z=$.next,$.empty)continue;if(l.has(J.toLowerCase()))return!1;U.push(J)}return U.length===0}function R(f){let U=new m(void 0,""),z=[U],J=0;while(J<f.length){if(f.charCodeAt(J)!==60){let K=J,V=f.indexOf("<",J);J=V<0?f.length:V;let G=P(f.slice(K,J));if(G.length>0)L(z[z.length-1],G);continue}if(f.startsWith("<!--",J)){let K=f.indexOf("-->",J+4);J=K<0?f.length:K+3;continue}if(f.startsWith("<![CDATA[",J)){let K=f.indexOf("]]>",J+9),V=K<0?f.slice(J+9):f.slice(J+9,K);if(V.length>0)L(z[z.length-1],V);J=K<0?f.length:K+3;continue}if(f.startsWith("<?",J)){let K=f.indexOf("?>",J+2);J=K<0?f.length:K+2;continue}if(f.startsWith("<!",J)){let K=s(f,J);J=K<0?f.length:K;continue}if(f.startsWith("</",J)){J+=2;let K=A(f,J).toLowerCase();if(K.length===0){L(z[z.length-1],"</");continue}if(J+=K.length,J=D(f,J),f[J]===">")J+=1;vf(z,K);continue}if(!i(f.charCodeAt(J+1))){L(z[z.length-1],"<"),J+=1;continue}J+=1;let $=A(f,J),Q=$.toLowerCase();J+=$.length;let F=xf(f,J);J=F.next,Nf(z,Q);let Z=new m(void 0,Q,F.attrs);if(z[z.length-1].children.push({type:"elem",elem:Z}),F.empty||l.has(Q))continue;if(Rf.has(Q)){let K=hf(f,J,Q),V=K<0?f.slice(J):f.slice(J,K);if(V.length>0)Z.children.push({type:"text",text:V});if(K<0)J=f.length;else J=f.indexOf(">",K),J=J<0?f.length:J+1;continue}z.push(Z)}return U}function Nf(f,U){let z=f[f.length-1];if(z===void 0||f.length<2)return;let J=z.local;if(U==="li"&&J==="li"){f.pop();return}if((U==="dt"||U==="dd")&&(J==="dt"||J==="dd")){f.pop();return}if((U==="td"||U==="th")&&(J==="td"||J==="th")){f.pop();return}if(U==="tr"){if(J==="td"||J==="th")f.pop();if(f.length>=2&&f[f.length-1].local==="tr")f.pop();return}if(uf.has(U)&&J==="p")f.pop()}function vf(f,U){for(let z=f.length-1;z>=1;z-=1)if(f[z].local===U){f.length=z;return}}function L(f,U){let z=f.children,J=z[z.length-1];if(J?.type==="text")J.text+=U;else z.push({type:"text",text:U})}function B(f,U){let z=U;while(U<f.length&&a(f.charCodeAt(U)))U+=1;return f.slice(z,U)}function A(f,U){let z=U;while(U<f.length&&Ef(f.charCodeAt(U)))U+=1;return f.slice(z,U)}function i(f){return f>=65&&f<=90||f>=97&&f<=122||f===58||f===95}function a(f){return i(f)||f>=48&&f<=57||f===45||f===46}function Ef(f){return a(f)}function Tf(f,U){for(;;){U=D(f,U);let z=f[U];if(z===void 0)return;if(z===">")return{next:U+1,empty:!1};if(z==="/"&&f[U+1]===">")return{next:U+2,empty:!0};let J=B(f,U);if(J.length===0)return;if(U+=J.length,U=D(f,U),f[U]!=="=")return;U+=1,U=D(f,U);let $=f.charCodeAt(U);if($!==34&&$!==39)return;U+=1;let Q=f.indexOf(String.fromCharCode($),U);if(Q<0)return;U=Q+1}}function xf(f,U){let z=[];for(;;){U=D(f,U);let J=f[U];if(J===void 0)return{next:U,empty:!1,attrs:z};if(J===">")return{next:U+1,empty:!1,attrs:z};if(J==="/"&&f[U+1]===">")return{next:U+2,empty:!0,attrs:z};let $=A(f,U);if($.length===0){U+=1;continue}U+=$.length,U=D(f,U);let Q="";if(f[U]==="="){U+=1,U=D(f,U);let F=f.charCodeAt(U);if(F===34||F===39){U+=1;let Z=f.indexOf(String.fromCharCode(F),U),K=Z<0?f.slice(U):f.slice(U,Z);U=Z<0?f.length:Z+1,Q=P(K)}else{let Z=U;while(U<f.length){let K=f.charCodeAt(U);if(K===62||K===47||K===32||K===9||K===10||K===13)break;U+=1}Q=P(f.slice(Z,U))}}z.push({ns:void 0,local:$.toLowerCase(),value:Q})}}function hf(f,U,z){let J=`</${z}`,$=U;while($<f.length){let Q=kf(f,J,$);if(Q<0)return-1;let F=Q+J.length,Z=f.charCodeAt(F);if(Z===62||Z===32||Z===9||Z===10||Z===13||Number.isNaN(Z))return Q;$=Q+1}return-1}function kf(f,U,z){let J=U.length,$=f.length-J;for(let Q=z;Q<=$;Q+=1){let F=!0;for(let Z=0;Z<J;Z+=1){let K=f.charCodeAt(Q+Z),V=U.charCodeAt(Z);if(K===V)continue;let G=K>=65&&K<=90?K+32:K,q=V>=65&&V<=90?V+32:V;if(G!==q){F=!1;break}}if(F)return Q}return-1}function s(f,U){U+=2;let z=0;while(U<f.length){let J=f[U];if(J==='"'||J==="'"){let $=J;U+=1;while(U<f.length&&f[U]!==$)U+=1;if(U<f.length)U+=1;continue}if(J==="<")z+=1;else if(J===">"){if(z===0)return U+1;z-=1}U+=1}return-1}function D(f,U){while(U<f.length){let z=f.charCodeAt(U);if(z!==32&&z!==9&&z!==10&&z!==13)break;U+=1}return U}function P(f){let U="",z=0;while(z<f.length){let J=f.indexOf("&",z);if(J<0){U+=f.slice(z);break}U+=f.slice(z,J);let $=f.indexOf(";",J+1);if($<0||$-J>32){U+="&",z=J+1;continue}let Q=of(f.slice(J+1,$));if(Q!==void 0)U+=Q,z=$+1;else U+="&",z=J+1}return U}function of(f){if(f.startsWith("#")){let z=f.slice(1),J=z.startsWith("x")||z.startsWith("X"),$=J?z.slice(1):z,Q=Number.parseInt($,J?16:10);if(!Number.isFinite(Q))return;try{return String.fromCodePoint(Q)}catch{return}}return{amp:"&",lt:"<",gt:">",apos:"'",quot:'"',nbsp:" ",shy:"",mdash:"—",ndash:"–",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",hellip:"…",copy:"©",reg:"®",trade:"™",deg:"°",middot:"·",bull:"•",sect:"§",para:"¶",laquo:"«",raquo:"»",times:"×",divide:"÷",plusmn:"±",frac12:"½",frac14:"¼",eacute:"é",egrave:"è",agrave:"à",ccedil:"ç",uuml:"ü",ouml:"ö",auml:"ä",szlig:"ß",aring:"å",oslash:"ø",aelig:"æ",euro:"€",pound:"£",yen:"¥",cent:"¢"}[f]}import{cellSpanning as df,GridBuilder as yf,inlinesAreEmpty as x,inlinesToPlainText as e,plain as pf,resolveHeaderRows as rf}from"@mdgate/document";import{deltasEqual as nf,emptyDelta as Vf,mergeDelta as Zf,rebaseEmphasis as cf,resolveDelta as ff}from"@mdgate/office-common";import{cleanText as Uf,collapseWs as zf,trim as Jf}from"@mdgate/utils";function h(f,U,z){let J=new k(U,z,!0);return J.walkChildren(f,Vf()),J.finish()}var Gf={bold:void 0,italic:void 0,strike:void 0,code:void 0},u={delta:Gf,hidden:void 0};function v(){return{delta:Vf(),hidden:void 0}}function Qf(f,U){return{delta:Zf(f.delta,U.delta),hidden:U.hidden??f.hidden}}function Y(f){return nf(f.delta,Gf)&&f.hidden===void 0}var $f=1e5,jf=1e6,bf=[],mf=[];class I{rules=[];get isEmpty(){return this.rules.length===0}addFrom(f){let U=f.rules;for(let z=0;z<U.length;z+=1)this.rules.push(U[z])}add(f){if(f.length===0)return;let U=tf(f);if(U.length===0)return;for(let z of U.split("}")){let J=z.indexOf("{");if(J<0)continue;let $=z.slice(J+1);if(!lf($))continue;let Q=wf($);if(Y(Q.normal)&&Y(Q.important))continue;let F=z.slice(0,J);for(let Z of F.split(",")){let K=Z.trim();if(K.length===0||K.includes(" ")||K.includes(":")||K.includes("["))continue;let V=K.indexOf("."),G,q;if(V>=0){let X=K.slice(0,V);G=X.length===0?void 0:X.toLowerCase(),q=K.slice(V+1)}else G=K.toLowerCase();let H=(q!==void 0?10:0)+(G!==void 0?1:0);if(!Y(Q.normal))this.rules.push({tag:G,className:q,priority:H,props:Q.normal});if(!Y(Q.important))this.rules.push({tag:G,className:q,priority:jf+H,props:Q.important})}}}matchingRules(f,U){let z=this.rules;if(z.length===0)return bf;let J=[];for(let $=0;$<z.length;$+=1){let Q=z[$];if(Q.tag!==void 0&&Q.tag!==f)continue;if(Q.className!==void 0&&!U.includes(Q.className))continue;J.push([Q.priority,Q.props])}return J}}function lf(f){return f.includes("display")||f.includes("font-weight")||f.includes("font-style")||f.includes("text-decoration")}function tf(f){let U=f.indexOf("/*");if(U<0)return f;let z=[],J=0,$=U;while($>=0){if($>J)z.push(f.slice(J,$));let Q=f.indexOf("*/",$+2);if(Q<0)return z.join("");J=Q+2,$=f.indexOf("/*",J)}if(J<f.length)z.push(f.slice(J));return z.join("")}function wf(f){let U={normal:v(),important:v()};for(let z of f.split(";")){let J=z.indexOf(":");if(J<0)continue;let $=z.slice(0,J).trim().toLowerCase(),Q=z.slice(J+1).trim().toLowerCase(),F=!1,Z=Q.indexOf("!");if(Z>=0){if(Q.slice(Z+1).trim()==="important")F=!0;Q=Q.slice(0,Z).trimEnd()}let K=F?U.important:U.normal;switch($){case"font-weight":{let V=E(Q);K.delta.bold=Q==="bold"||Q==="bolder"||V!==void 0&&V>=600;break}case"font-style":K.delta.italic=Q==="italic"||Q==="oblique";break;case"text-decoration":case"text-decoration-line":if(Q.includes("line-through"))K.delta.strike=!0;else if(Q==="none")K.delta.strike=!1;break;case"display":K.hidden=Q==="none";break;default:break}}return U}function E(f){if(!/^\d+$/.test(f))return;let U=Number(f);if(!Number.isSafeInteger(U)||U<0||U>4294967295)return;return U}class k{blocks=[];inlines=[];css;ctx;startBoundary;constructor(f,U,z){this.css=f,this.ctx=U,this.startBoundary=z}finish(){return this.flushParagraph(),this.blocks}subBlocks(f,U){return this.subBlocksAt(f,U,!0)}subBlocksAt(f,U,z){let J=new k(this.css,this.ctx,z);return J.walkChildren(f,U),J.finish()}elementProps(f){let U=f.attrAny("style");if(this.css.isEmpty&&U===void 0)return u;let z=f.attrAny("class"),J=z!==void 0&&z.length>0?z.split(/\s+/).filter((F)=>F.length>0):mf,$=this.css.matchingRules(f.local,J);if(U!==void 0){let F=wf(U);$.push([$f,F.normal]),$.push([jf+$f,F.important])}if($.length===0)return u;if($.length===1)return Qf(u,$[0][1]);$.sort((F,Z)=>F[0]-Z[0]);let Q=v();for(let F=0;F<$.length;F+=1)Q=Qf(Q,$[F][1]);return Q}pushAnchor(f){let U=f.attrAny("id");if(U!==void 0&&U.length>0)this.inlines.push({type:"anchor",id:this.ctx.anchorId(U)});if(f.local==="a"){let z=f.attrAny("name");if(z!==void 0&&z.length>0)this.inlines.push({type:"anchor",id:this.ctx.anchorId(z)})}}walkChildren(f,U){for(let z of f.children)if(z.type==="text")this.pushText(z.text,U);else this.walkElem(z.elem,U)}pushText(f,U){let z=zf(Uf(f));if(z.length===0)return;let J=z;if(T(this.inlines,this.startBoundary))J=z0(z," ");if(J.length===0)return;this.inlines.push({type:"text",text:J,style:ff(U)})}walkElem(f,U){let z=this.elementProps(f);if(z.hidden===!0)return;U=Zf(af(f,U),z.delta);let J=f.local;if(J==="h1"||J==="h2"||J==="h3"||J==="h4"||J==="h5"||J==="h6"){this.flushParagraph();let $=Number.parseInt(J.slice(1),10)||1,Q=this.inlineChildren(f,U);cf(Q,ff(U));let F=f.attrAny("id"),Z=F!==void 0?this.ctx.anchorId(F):void 0;if(!x(Q))this.blocks.push({type:"heading",level:$,anchor:Z,content:Q});else{let K=[];if(Z!==void 0)K.push({type:"anchor",id:Z});for(let V of Q)if(V.type==="anchor")K.push(V);if(K.length>0)this.blocks.push({type:"paragraph",inlines:K})}return}if(J==="p"){this.flushParagraph(),this.pushAnchor(f);let $=this.inlines.splice(0,this.inlines.length);if($.push(...this.inlineChildren(f,U)),N($))this.blocks.push({type:"paragraph",inlines:$});return}if(J==="ul"||J==="ol"){this.flushParagraph(),this.blocks.push(...this.parseList(f,U));return}if(J==="table"){this.flushParagraph();let $=f.childElems().find((F)=>F.local==="caption");if($!==void 0){let F=this.inlineChildren($,U);if(N(F))this.blocks.push({type:"paragraph",inlines:F})}let Q=this.parseTable(f,U);if(Q!==void 0)this.blocks.push(Q);return}if(J==="blockquote"){this.flushParagraph();let $=this.subBlocks(f,U);if($.length>0)this.blocks.push({type:"blockQuote",blocks:$});return}if(J==="pre"){this.flushParagraph();let $=f.text();if(Jf($).length>0)this.blocks.push({type:"codeBlock",lang:void 0,text:$});return}if(J==="hr"){this.flushParagraph(),this.blocks.push({type:"rule"});return}if(qf(J)){if(this.pushAnchor(f),ef(f))this.flushParagraph(),this.walkChildren(f,U),this.flushParagraph();else this.walkChildren(f,U);return}if(J==="script"||J==="style"||J==="head"||J==="template"||J==="noscript")return;this.walkInline(f,U)}walkInline(f,U){this.pushAnchor(f);let z=f.local;if(z==="br"){this.inlines.push({type:"lineBreak"});return}if(z==="img"||z==="image"){let J=Uf(f.attrAny("alt")??""),$=f.attrAny("src")??f.attrAny("href")??"",Q=this.ctx.imageSource($);if(Q!==void 0||Jf(J).length>0)this.inlines.push({type:"image",alt:J,source:Q??{type:"unavailable"}});return}if(z==="a"){let J=f.attrAny("href"),$=J!==void 0?this.ctx.linkTarget(J):void 0,Q=this.inlineChildrenAt(f,U,T(this.inlines,this.startBoundary));if($!==void 0)this.inlines.push({type:"link",content:Q,target:$});else this.inlines.push(...Q);return}this.walkChildren(f,U)}inlineChildren(f,U){return this.inlineChildrenAt(f,U,!0)}inlineChildrenAt(f,U,z){let J=this.subBlocksAt(f,U,z);if(J.length===1&&J[0].type==="paragraph")return J[0].inlines;let $=[];for(let Q=0;Q<J.length;Q+=1){if(Q>0)$.push({type:"lineBreak"});let F=J[Q];if(F.type==="paragraph")$.push(...F.inlines);else if(F.type==="heading")$.push(...F.content);else $.push(pf(zf(g(F))))}return $}parseList(f,U){let z=f.local==="ol",J=f.childElems().filter((w)=>w.local==="li");if(J.length===0)return[];if(!z)return[{type:"list",list:{marker:"bullet",start:1,items:J.map((j)=>({blocks:this.subBlocks(j,U),checked:void 0,markerLabel:void 0}))}}];let $=f.attrAny("type"),Q="decimal";if($==="a")Q="lowerAlpha";else if($==="A")Q="upperAlpha";else if($==="i")Q="lowerRoman";else if($==="I")Q="upperRoman";let F=f.attrAny("reversed")!==void 0,Z=f.attrAny("start"),V=(Z!==void 0?Kf(Z):void 0)??(F?J.length:1),G=[];for(let w of J){let j=w.attrAny("value"),M=j!==void 0?Kf(j):void 0;if(M!==void 0)V=M;G.push(V),V=F?V-1:V+1}if(G.some((w)=>w<1)){let w=J.map((j,M)=>({blocks:this.subBlocks(j,U),checked:void 0,markerLabel:`${G[M]}.`}));return[{type:"list",list:{marker:Q,start:1,items:w}}]}let q=[],H,X=0;for(let w=0;w<J.length;w+=1){let j=G[w],M={blocks:this.subBlocks(J[w],U),checked:void 0,markerLabel:void 0};if(!(H!==void 0&&X+1===j)){if(H!==void 0)q.push({type:"list",list:H});H={marker:Q,start:j,items:[]}}H.items.push(M),X=j}if(H!==void 0)q.push({type:"list",list:H});return q}parseTable(f,U){let z=[],J=0,$=!1;for(let V of f.childElems())if(V.local==="thead"||V.local==="tbody"||V.local==="tfoot"){if($)$=!1,J+=1;let G=V.local==="thead";for(let q of V.childElems())if(q.local==="tr")z.push([q,G,J]);J+=1}else if(V.local==="tr")$=!0,z.push([V,!1,J]);if(z.length===0)return;let Q=new Map;for(let V=0;V<z.length;V+=1)Q.set(z[V][2],V);let F=new yf,Z=0;for(let V=0;V<z.length;V+=1){let[G,q,H]=z[V];F.nextRow();let X=!0,w=!1;for(let j of G.childElems()){if(j.local!=="td"&&j.local!=="th")continue;if(w=!0,j.local!=="th")X=!1;let M=Ff(E(j.attrAny("colspan")??"")??1,1,1000),C,b=j.attrAny("rowspan"),S=b!==void 0?E(b):void 0;if(S===0)C=(Q.get(H)??V)-V+1;else if(S!==void 0)C=Ff(S,1,65534);else C=1;F.place(df(this.subBlocks(j,U),M,C))}if(V===Z&&(q||X&&w))Z+=1}let K=F.finish("data");if(K.grid.length===0)return;return K.headerRows=rf(K,Z),{type:"table",table:K}}flushParagraph(){if(this.inlines.length>0){let f=this.inlines.splice(0,this.inlines.length);if(N(f))this.blocks.push({type:"paragraph",inlines:f})}this.startBoundary=!0}}function af(f,U){let z={...U};switch(f.local){case"b":case"strong":z.bold=!0;break;case"i":case"em":case"cite":case"dfn":case"var":z.italic=!0;break;case"s":case"del":case"strike":z.strike=!0;break;case"code":case"kbd":case"samp":case"tt":z.code=!0;break;default:break}return z}function g(f){switch(f.type){case"paragraph":return e(f.inlines);case"heading":return e(f.content);case"list":return f.list.items.flatMap((U)=>U.blocks.map(g)).join(" ");case"blockQuote":return f.blocks.map(g).join(" ");case"codeBlock":return f.text;case"table":return f.table.grid.flatMap((U)=>U.flatMap((z)=>z.type==="origin"?[z.cell.blocks.map(g).join(" ")]:[])).join(" ");case"rule":return""}}function qf(f){return f==="div"||f==="section"||f==="article"||f==="aside"||f==="main"||f==="nav"||f==="header"||f==="footer"||f==="figure"||f==="figcaption"||f==="center"||f==="details"||f==="summary"||f==="li"||f==="dl"||f==="dt"||f==="dd"||f==="body"}function sf(f){return qf(f)||f==="p"||f==="ul"||f==="ol"||f==="table"||f==="blockquote"||f==="pre"||f==="hr"||f==="h1"||f==="h2"||f==="h3"||f==="h4"||f==="h5"||f==="h6"}function ef(f){return f.childElems().some((U)=>sf(U.local))}function N(f){return!x(f)||f.some((U)=>U.type==="anchor")}function T(f,U){for(let z=f.length-1;z>=0;z-=1){let J=f[z];if(J.type==="anchor")continue;if(J.type==="text"){if(J.text.length===0)continue;return U0(f0(J.text))}if(J.type==="lineBreak")return!0;if(J.type==="link"){if(x(J.content))continue;return T(J.content,!1)}return!1}return U}function f0(f){let U=f.length;if(U===0)return 0;let z=f.charCodeAt(U-1);if(z>=56320&&z<=57343&&U>=2){let J=f.charCodeAt(U-2);if(J>=55296&&J<=56319)return(J-55296<<10)+(z-56320)+65536}return z}function U0(f){return f>=9&&f<=13||f===32||f===133||f===160||f===5760||f>=8192&&f<=8202||f===8232||f===8233||f===8239||f===8287||f===12288}function z0(f,U){let z=0;while(z<f.length&&f[z]===U)z+=1;return f.slice(z)}function Kf(f){let U=f.trim();if(!/^-?\d+$/.test(U))return;let z=Number(U);return Number.isFinite(z)?z:void 0}function Ff(f,U,z){return Math.min(z,Math.max(U,f))}function Lf(f){let U=q0(f),z=new Df;return If(U,new d(void 0,z),z)}function Yf(f){let U=K0(f),z=Q0(U)??$0(U);if(z===void 0)throw Z0.malformed("no text/html or text/plain part");let J=new Df,$=M0(U),Q=C0(z);if(z.contentType==="text/plain"){let Z=Mf(),K=Cf(Q);if(K.length>0)Z.blocks.push({type:"paragraph",inlines:[G0(K)]});return Z.assets=J.assets,Z}let F=gf(Q,new TextEncoder().encode(Q));return If(F,new d($,J),J)}function q0(f){return gf(L0(f),f)}function gf(f,U){if(t(f))try{return F0(U)}catch{}return R(f)}function If(f,U,z){Of(f);let J=H0(f),$=X0(f),Q=Mf();return Q.blocks.push(...h($,J,U)),Q.assets=z.assets,Q}function H0(f){let U=new I;for(let z of f.descendantElems())if(z.local==="style")U.add(z.text());return U}function X0(f){if(f.local==="body")return f;let U=f.local==="html"?f:o(f,"html");if(U!==void 0){let J=o(U,"body");if(J!==void 0)return J;return U}return o(f,"body")??f}function o(f,U){return f.childElems().find((z)=>z.local===U)}function Of(f){f.local=f.local.toLowerCase();let U=f.attrs;for(let z=0;z<U.length;z+=1)U[z].local=U[z].local.toLowerCase();for(let z of f.childElems())Of(z)}class d{cids;assets;constructor(f,U){this.cids=f;this.assets=U}linkTarget(f){if(f.length===0)return;if(f.startsWith("#")){let U=J0(f.slice(1));return U.length>0?{type:"anchor",id:U}:void 0}if(Hf(f))return{type:"external",url:f};return{type:"relative",url:f}}imageSource(f){if(f.length===0)return;let U=this.resolveCid(f);if(U!==void 0)return U;if(Hf(f))return{type:"external",url:f};return}anchorId(f){return f}resolveCid(f){if(this.cids===void 0)return;if(f.length<4||f.slice(0,4).toLowerCase()!=="cid:")return;let U=f.slice(4);try{U=decodeURIComponent(U)}catch{}if(U.startsWith("<")&&U.endsWith(">")&&U.length>=2)U=U.slice(1,-1);let z=this.cids.get(U.toLowerCase());if(z===void 0)return;let J=z.filename??U,$=z.contentType.length>0?z.contentType:j0(J);return{type:"asset",id:this.assets.add($,J,z.bytes)}}}function M0(f){let U=new Map;for(let z of V0(f)){let J=Xf(z,"content-id");if(J===void 0)continue;let $=D0(J);if($.length>0)U.set($.toLowerCase(),z)}return U}function D0(f){let U=Cf(f);if(U.startsWith("<")&&U.endsWith(">")&&U.length>=2)U=U.slice(1,-1);return U}function C0(f){let U=Xf(f,"content-type"),z="utf-8";if(U!==void 0){let J=/charset\s*=\s*("?)([^";\s]+)\1/i.exec(U);if(J!==null)z=J[2]}try{return w0(f.bytes,z)}catch{return new TextDecoder("utf-8",{fatal:!1}).decode(f.bytes)}}function L0(f){if(f.length>=2&&f[0]===255&&f[1]===254)return new TextDecoder("utf-16le").decode(f);if(f.length>=2&&f[0]===254&&f[1]===255)return new TextDecoder("utf-16be").decode(f);if(f.length>=3&&f[0]===239&&f[1]===187&&f[2]===191)return new TextDecoder("utf-8").decode(f.subarray(3));return new TextDecoder("utf-8").decode(f)}var g0=new Set(["htm","html","html4","html5","xhtml","mhtml","mht"]),Sf=new Set(["mhtml","mht"]);function n(){return{id:"html",sniff(f,U){if(Af(f))return 0;let z=U?.path!==void 0?_f(U.path):void 0;if(Bf(f)||z!==void 0&&Sf.has(z))return 3;if(_0(f))return 0;if(Pf(f)&&!y(f))return 3;if(W0(f)&&!y(f))return 2;if(z!==void 0&&g0.has(z))return 1;return 0},convert(f,U){I0(f);let z=U?.path!==void 0?_f(U.path):void 0;if(z!==void 0&&Sf.has(z)||Bf(f))return{markdown:Wf(Yf(f))};if(y(f))throw O.unsupported("OpenDocument");return{markdown:Wf(Lf(f))}}}}function I0(f){if(O0(f))throw O.unsupported("pdf");if(Y0(f))throw O.unsupported("ole");if(Af(f))throw O.unsupported("zip")}function Af(f){return f.length>=4&&f[0]===80&&f[1]===75&&f[2]===3&&f[3]===4}function O0(f){let U=c(f);return S0(f,"%PDF-",U)}function W0(f){if(Pf(f))return!0;return _(f.subarray(0,Math.min(f.length,4096))).includes("http://www.w3.org/1999/xhtml")}function Pf(f){let U=c(f);if(W(f,"<!doctype html",U)&&!r(f[U+14]))return!0;return W(f,"<html",U)&&!r(f[U+5])}function _0(f){let U=c(f);if(W(f,"<svg",U)&&!r(f[U+4]))return!0;if(!W(f,"<?xml",U))return!1;let z=_(f.subarray(0,Math.min(f.length,8192)));return/<svg\b/i.test(z)}function Bf(f){return _(f.subarray(0,Math.min(f.length,4096))).toLowerCase().includes("content-location:")}function y(f){let U=_(f.subarray(0,Math.min(f.length,8192))),z=p(U,0);if(U.startsWith("<?xml",z)){let $=U.indexOf("?>",z);if($<0)return!1;z=p(U,$+2)}while(U.startsWith("<!--",z)){let $=U.indexOf("-->",z+4);if($<0)return!1;z=p(U,$+3)}let J=U.slice(z,z+2048);return/<office:document\b/.test(J)}function c(f){let U=0;if(f.length>=3&&f[0]===239&&f[1]===187&&f[2]===191)U=3;while(U<f.length){let z=f[U];if(z!==9&&z!==10&&z!==13&&z!==32)break;U+=1}return U}function p(f,U){while(U<f.length){let z=f.charCodeAt(U);if(z!==9&&z!==10&&z!==13&&z!==32)break;U+=1}return U}function S0(f,U,z){if(z+U.length>f.length)return!1;for(let J=0;J<U.length;J+=1)if(f[z+J]!==U.charCodeAt(J))return!1;return!0}function W(f,U,z){if(z+U.length>f.length)return!1;for(let J=0;J<U.length;J+=1){let $=f[z+J],Q=U.charCodeAt(J);if($===Q)continue;let F=$>=65&&$<=90?$+32:$,Z=Q>=65&&Q<=90?Q+32:Q;if(F!==Z)return!1}return!0}function r(f){if(f===void 0)return!1;return f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||f===45||f===95||f===58}function _(f){return new TextDecoder("utf-8",{fatal:!1}).decode(f)}import{create as B0}from"@mdgate/core";var A0=B0([n()]);function P0(f,U){return A0(f,U)}export{P0 as toMarkdown,h as toBlocks,R as parseHtml,n as html,I as Stylesheet};
|
|
1
|
+
import{hasOleMagic as A0}from"@mdgate/containers";import{ConvertError as O}from"@mdgate/core";import{documentToMarkdown as gf}from"@mdgate/document";import{fileExtension as Af}from"@mdgate/utils";import{decodeFragment as K0,mimeHeader as Mf,mimeTextHtml as V0,mimeTextPlain as Z0,parseMime as j0,parseXml as G0,walkMimeParts as C0}from"@mdgate/containers";import{ConvertError as D0}from"@mdgate/core";import{emptyDocument as wf,plain as H0}from"@mdgate/document";import{AssetSink as Lf,mediaTypeFor as q0}from"@mdgate/office-common";import{decode as X0,isAbsoluteUri as Xf,trim as Yf}from"@mdgate/utils";import{Element as m}from"@mdgate/containers";var t=new Set(["area","base","basefont","bgsound","br","col","embed","frame","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Tf=new Set(["script","style","textarea","title","noscript"]),hf=new Set(["address","article","aside","blockquote","div","dl","fieldset","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","nav","ol","p","pre","section","table","ul"]);function i(f){let u=[],U=0;while(U<f.length){if(f.charCodeAt(U)!==60){U+=1;continue}if(f.startsWith("<!--",U)){let J=f.indexOf("-->",U+4);if(J<0)return!1;U=J+3;continue}if(f.startsWith("<![CDATA[",U)){let J=f.indexOf("]]>",U+9);if(J<0)return!1;U=J+3;continue}if(f.startsWith("<?",U)){let J=f.indexOf("?>",U+2);if(J<0)return!1;U=J+2;continue}if(f.startsWith("<!",U)){let J=s(f,U);if(J<0)return!1;U=J;continue}if(f.startsWith("</",U)){U+=2;let J=g(f,U);if(J.length===0)return!1;if(U+=J.length,U=F(f,U),f[U]!==">")return!1;U+=1;let K=u.pop();if(K===void 0||K!==J)return!1;continue}U+=1;let z=g(f,U);if(z.length===0)return!1;U+=z.length;let Q=of(f,U);if(Q===void 0)return!1;if(U=Q.next,Q.empty)continue;if(t.has(z.toLowerCase()))return!1;u.push(z)}return u.length===0}function P(f){let u=new m(void 0,""),U=[u],z=0;while(z<f.length){if(f.charCodeAt(z)!==60){let $=z,Z=f.indexOf("<",z);z=Z<0?f.length:Z;let j=B(f.slice($,z));if(j.length>0)w(U[U.length-1],j);continue}if(f.startsWith("<!--",z)){let $=f.indexOf("-->",z+4);z=$<0?f.length:$+3;continue}if(f.startsWith("<![CDATA[",z)){let $=f.indexOf("]]>",z+9),Z=$<0?f.slice(z+9):f.slice(z+9,$);if(Z.length>0)w(U[U.length-1],Z);z=$<0?f.length:$+3;continue}if(f.startsWith("<?",z)){let $=f.indexOf("?>",z+2);z=$<0?f.length:$+2;continue}if(f.startsWith("<!",z)){let $=s(f,z);z=$<0?f.length:$;continue}if(f.startsWith("</",z)){z+=2;let $=A(f,z).toLowerCase();if($.length===0){w(U[U.length-1],"</");continue}if(z+=$.length,z=F(f,z),f[z]===">")z+=1;Ef(U,$);continue}if(!l(f.charCodeAt(z+1))){w(U[U.length-1],"<"),z+=1;continue}z+=1;let Q=A(f,z),J=Q.toLowerCase();z+=Q.length;let K=df(f,z);z=K.next,Nf(U,J);let V=new m(void 0,J,K.attrs);if(U[U.length-1].children.push({type:"elem",elem:V}),K.empty||t.has(J))continue;if(Tf.has(J)){let $=rf(f,z,J),Z=$<0?f.slice(z):f.slice(z,$);if(Z.length>0)V.children.push({type:"text",text:Z});if($<0)z=f.length;else z=f.indexOf(">",$),z=z<0?f.length:z+1;continue}U.push(V)}return u}function Nf(f,u){let U=f[f.length-1];if(U===void 0||f.length<2)return;let z=U.local;if(u==="li"&&z==="li"){f.pop();return}if((u==="dt"||u==="dd")&&(z==="dt"||z==="dd")){f.pop();return}if((u==="td"||u==="th")&&(z==="td"||z==="th")){f.pop();return}if(u==="tr"){if(z==="td"||z==="th")f.pop();if(f.length>=2&&f[f.length-1].local==="tr")f.pop();return}if(hf.has(u)&&z==="p")f.pop()}function Ef(f,u){for(let U=f.length-1;U>=1;U-=1)if(f[U].local===u){f.length=U;return}}function w(f,u){let U=f.children,z=U[U.length-1];if(z?.type==="text")z.text+=u;else U.push({type:"text",text:u})}function g(f,u){let U=u;while(u<f.length&&a(f.charCodeAt(u)))u+=1;return f.slice(U,u)}function A(f,u){let U=u;while(u<f.length&&xf(f.charCodeAt(u)))u+=1;return f.slice(U,u)}function l(f){return f>=65&&f<=90||f>=97&&f<=122||f===58||f===95}function a(f){return l(f)||f>=48&&f<=57||f===45||f===46}function xf(f){return a(f)}function of(f,u){for(;;){u=F(f,u);let U=f[u];if(U===void 0)return;if(U===">")return{next:u+1,empty:!1};if(U==="/"&&f[u+1]===">")return{next:u+2,empty:!0};let z=g(f,u);if(z.length===0)return;if(u+=z.length,u=F(f,u),f[u]!=="=")return;u+=1,u=F(f,u);let Q=f.charCodeAt(u);if(Q!==34&&Q!==39)return;u+=1;let J=f.indexOf(String.fromCharCode(Q),u);if(J<0)return;u=J+1}}function df(f,u){let U=[];for(;;){u=F(f,u);let z=f[u];if(z===void 0)return{next:u,empty:!1,attrs:U};if(z===">")return{next:u+1,empty:!1,attrs:U};if(z==="/"&&f[u+1]===">")return{next:u+2,empty:!0,attrs:U};let Q=A(f,u);if(Q.length===0){u+=1;continue}u+=Q.length,u=F(f,u);let J="";if(f[u]==="="){u+=1,u=F(f,u);let K=f.charCodeAt(u);if(K===34||K===39){u+=1;let V=f.indexOf(String.fromCharCode(K),u),$=V<0?f.slice(u):f.slice(u,V);u=V<0?f.length:V+1,J=B($)}else{let V=u;while(u<f.length){let $=f.charCodeAt(u);if($===62||$===47||$===32||$===9||$===10||$===13)break;u+=1}J=B(f.slice(V,u))}}U.push({ns:void 0,local:Q.toLowerCase(),value:J})}}function rf(f,u,U){let z=`</${U}`,Q=u;while(Q<f.length){let J=nf(f,z,Q);if(J<0)return-1;let K=J+z.length,V=f.charCodeAt(K);if(V===62||V===32||V===9||V===10||V===13||Number.isNaN(V))return J;Q=J+1}return-1}function nf(f,u,U){let z=u.length,Q=f.length-z;for(let J=U;J<=Q;J+=1){let K=!0;for(let V=0;V<z;V+=1){let $=f.charCodeAt(J+V),Z=u.charCodeAt(V);if($===Z)continue;let j=$>=65&&$<=90?$+32:$,D=Z>=65&&Z<=90?Z+32:Z;if(j!==D){K=!1;break}}if(K)return J}return-1}function s(f,u){u+=2;let U=0;while(u<f.length){let z=f[u];if(z==='"'||z==="'"){let Q=z;u+=1;while(u<f.length&&f[u]!==Q)u+=1;if(u<f.length)u+=1;continue}if(z==="<")U+=1;else if(z===">"){if(U===0)return u+1;U-=1}u+=1}return-1}function F(f,u){while(u<f.length){let U=f.charCodeAt(u);if(U!==32&&U!==9&&U!==10&&U!==13)break;u+=1}return u}function B(f){let u="",U=0;while(U<f.length){let z=f.indexOf("&",U);if(z<0){u+=f.slice(U);break}u+=f.slice(U,z);let Q=f.indexOf(";",z+1);if(Q<0||Q-z>32){u+="&",U=z+1;continue}let J=kf(f.slice(z+1,Q));if(J!==void 0)u+=J,U=Q+1;else u+="&",U=z+1}return u}function kf(f){if(f.startsWith("#")){let U=f.slice(1),z=U.startsWith("x")||U.startsWith("X"),Q=z?U.slice(1):U,J=Number.parseInt(Q,z?16:10);if(!Number.isFinite(J))return;try{return String.fromCodePoint(J)}catch{return}}return{amp:"&",lt:"<",gt:">",apos:"'",quot:'"',nbsp:" ",shy:"",mdash:"—",ndash:"–",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",hellip:"…",copy:"©",reg:"®",trade:"™",deg:"°",middot:"·",bull:"•",sect:"§",para:"¶",laquo:"«",raquo:"»",times:"×",divide:"÷",plusmn:"±",frac12:"½",frac14:"¼",eacute:"é",egrave:"è",agrave:"à",ccedil:"ç",uuml:"ü",ouml:"ö",auml:"ä",szlig:"ß",aring:"å",oslash:"ø",aelig:"æ",euro:"€",pound:"£",yen:"¥",cent:"¢"}[f]}import{cellSpanning as yf,GridBuilder as pf,inlinesAreEmpty as E,inlinesToPlainText as e,plain as cf,resolveHeaderRows as bf}from"@mdgate/document";import{deltasEqual as mf,emptyDelta as jf,mergeDelta as Gf,rebaseEmphasis as tf,resolveDelta as ff}from"@mdgate/office-common";import{cleanText as uf,collapseWs as Uf,trim as zf}from"@mdgate/utils";function x(f,u,U){let z=new o(u,U,!0);return z.walkChildren(f,jf()),z.finish()}var Cf={bold:void 0,italic:void 0,strike:void 0,code:void 0},R={delta:Cf,hidden:void 0};function T(){return{delta:jf(),hidden:void 0}}function Jf(f,u){return{delta:Gf(f.delta,u.delta),hidden:u.hidden??f.hidden}}function L(f){return mf(f.delta,Cf)&&f.hidden===void 0}var Qf=1e5,Df=1e6,lf=[],af=[];class I{rules=[];get isEmpty(){return this.rules.length===0}addFrom(f){let u=f.rules;for(let U=0;U<u.length;U+=1)this.rules.push(u[U])}add(f){if(f.length===0)return;let u=ef(f);if(u.length===0)return;for(let U of u.split("}")){let z=U.indexOf("{");if(z<0)continue;let Q=U.slice(z+1);if(!sf(Q))continue;let J=Hf(Q);if(L(J.normal)&&L(J.important))continue;let K=U.slice(0,z);for(let V of K.split(",")){let $=V.trim();if($.length===0||$.includes(" ")||$.includes(":")||$.includes("["))continue;let Z=$.indexOf("."),j,D;if(Z>=0){let q=$.slice(0,Z);j=q.length===0?void 0:q.toLowerCase(),D=$.slice(Z+1)}else j=$.toLowerCase();let H=(D!==void 0?10:0)+(j!==void 0?1:0);if(!L(J.normal))this.rules.push({tag:j,className:D,priority:H,props:J.normal});if(!L(J.important))this.rules.push({tag:j,className:D,priority:Df+H,props:J.important})}}}matchingRules(f,u){let U=this.rules;if(U.length===0)return lf;let z=[];for(let Q=0;Q<U.length;Q+=1){let J=U[Q];if(J.tag!==void 0&&J.tag!==f)continue;if(J.className!==void 0&&!u.includes(J.className))continue;z.push([J.priority,J.props])}return z}}function sf(f){return f.includes("display")||f.includes("font-weight")||f.includes("font-style")||f.includes("text-decoration")}function ef(f){let u=f.indexOf("/*");if(u<0)return f;let U=[],z=0,Q=u;while(Q>=0){if(Q>z)U.push(f.slice(z,Q));let J=f.indexOf("*/",Q+2);if(J<0)return U.join("");z=J+2,Q=f.indexOf("/*",z)}if(z<f.length)U.push(f.slice(z));return U.join("")}function Hf(f){let u={normal:T(),important:T()};for(let U of f.split(";")){let z=U.indexOf(":");if(z<0)continue;let Q=U.slice(0,z).trim().toLowerCase(),J=U.slice(z+1).trim().toLowerCase(),K=!1,V=J.indexOf("!");if(V>=0){if(J.slice(V+1).trim()==="important")K=!0;J=J.slice(0,V).trimEnd()}let $=K?u.important:u.normal;switch(Q){case"font-weight":{let Z=h(J);$.delta.bold=J==="bold"||J==="bolder"||Z!==void 0&&Z>=600;break}case"font-style":$.delta.italic=J==="italic"||J==="oblique";break;case"text-decoration":case"text-decoration-line":if(J.includes("line-through"))$.delta.strike=!0;else if(J==="none")$.delta.strike=!1;break;case"display":$.hidden=J==="none";break;default:break}}return u}function h(f){if(!/^\d+$/.test(f))return;let u=Number(f);if(!Number.isSafeInteger(u)||u<0||u>4294967295)return;return u}class o{blocks=[];inlines=[];css;ctx;startBoundary;constructor(f,u,U){this.css=f,this.ctx=u,this.startBoundary=U}finish(){return this.flushParagraph(),this.blocks}subBlocks(f,u){return this.subBlocksAt(f,u,!0)}subBlocksAt(f,u,U){let z=new o(this.css,this.ctx,U);return z.walkChildren(f,u),z.finish()}elementProps(f){let u=f.attrAny("style");if(this.css.isEmpty&&u===void 0)return R;let U=f.attrAny("class"),z=U!==void 0&&U.length>0?U.split(/\s+/).filter((K)=>K.length>0):af,Q=this.css.matchingRules(f.local,z);if(u!==void 0){let K=Hf(u);Q.push([Qf,K.normal]),Q.push([Df+Qf,K.important])}if(Q.length===0)return R;if(Q.length===1)return Jf(R,Q[0][1]);Q.sort((K,V)=>K[0]-V[0]);let J=T();for(let K=0;K<Q.length;K+=1)J=Jf(J,Q[K][1]);return J}pushAnchor(f){let u=f.attrAny("id");if(u!==void 0&&u.length>0)this.inlines.push({type:"anchor",id:this.ctx.anchorId(u)});if(f.local==="a"){let U=f.attrAny("name");if(U!==void 0&&U.length>0)this.inlines.push({type:"anchor",id:this.ctx.anchorId(U)})}}walkChildren(f,u){for(let U of f.children)if(U.type==="text")this.pushText(U.text,u);else this.walkElem(U.elem,u)}pushText(f,u){let U=Uf(uf(f));if(U.length===0)return;let z=U;if(N(this.inlines,this.startBoundary))z=Q0(U," ");if(z.length===0)return;this.inlines.push({type:"text",text:z,style:ff(u)})}walkElem(f,u){let U=this.elementProps(f);if(U.hidden===!0)return;u=Gf(f0(f,u),U.delta);let z=f.local;if(z==="h1"||z==="h2"||z==="h3"||z==="h4"||z==="h5"||z==="h6"){this.flushParagraph();let Q=Number.parseInt(z.slice(1),10)||1,J=this.inlineChildren(f,u);tf(J,ff(u));let K=f.attrAny("id"),V=K!==void 0?this.ctx.anchorId(K):void 0;if(!E(J))this.blocks.push({type:"heading",level:Q,anchor:V,content:J});else{let $=[];if(V!==void 0)$.push({type:"anchor",id:V});for(let Z of J)if(Z.type==="anchor")$.push(Z);if($.length>0)this.blocks.push({type:"paragraph",inlines:$})}return}if(z==="p"){this.flushParagraph(),this.pushAnchor(f);let Q=this.inlines.splice(0,this.inlines.length);if(Q.push(...this.inlineChildren(f,u)),v(Q))this.blocks.push({type:"paragraph",inlines:Q});return}if(z==="ul"||z==="ol"){this.flushParagraph(),this.blocks.push(...this.parseList(f,u));return}if(z==="table"){this.flushParagraph();let Q=f.childElems().find((K)=>K.local==="caption");if(Q!==void 0){let K=this.inlineChildren(Q,u);if(v(K))this.blocks.push({type:"paragraph",inlines:K})}let J=this.parseTable(f,u);if(J!==void 0)this.blocks.push(J);return}if(z==="blockquote"){this.flushParagraph();let Q=this.subBlocks(f,u);if(Q.length>0)this.blocks.push({type:"blockQuote",blocks:Q});return}if(z==="pre"){this.flushParagraph();let Q=f.text();if(zf(Q).length>0)this.blocks.push({type:"codeBlock",lang:$0(f),text:Q});return}if(z==="hr"){this.flushParagraph(),this.blocks.push({type:"rule"});return}if(qf(z)){if(this.pushAnchor(f),U0(f))this.flushParagraph(),this.walkChildren(f,u),this.flushParagraph();else this.walkChildren(f,u);return}if(z==="script"||z==="style"||z==="head"||z==="template"||z==="noscript")return;this.walkInline(f,u)}walkInline(f,u){this.pushAnchor(f);let U=f.local;if(U==="br"){this.inlines.push({type:"lineBreak"});return}if(U==="img"||U==="image"){let z=uf(f.attrAny("alt")??""),Q=f.attrAny("src")??f.attrAny("href")??"",J=this.ctx.imageSource(Q);if(J!==void 0||zf(z).length>0)this.inlines.push({type:"image",alt:z,source:J??{type:"unavailable"}});return}if(U==="a"){let z=f.attrAny("href"),Q=z!==void 0?this.ctx.linkTarget(z):void 0,J=this.inlineChildrenAt(f,u,N(this.inlines,this.startBoundary));if(Q!==void 0)this.inlines.push({type:"link",content:J,target:Q});else this.inlines.push(...J);return}this.walkChildren(f,u)}inlineChildren(f,u){return this.inlineChildrenAt(f,u,!0)}inlineChildrenAt(f,u,U){let z=this.subBlocksAt(f,u,U);if(z.length===1&&z[0].type==="paragraph")return z[0].inlines;let Q=[];for(let J=0;J<z.length;J+=1){if(J>0)Q.push({type:"lineBreak"});let K=z[J];if(K.type==="paragraph")Q.push(...K.inlines);else if(K.type==="heading")Q.push(...K.content);else Q.push(cf(Uf(Y(K))))}return Q}parseList(f,u){let U=f.local==="ol",z=f.childElems().filter((C)=>C.local==="li");if(z.length===0)return[];if(!U)return[{type:"list",list:{marker:"bullet",start:1,items:z.map((G)=>({blocks:this.subBlocks(G,u),checked:void 0,markerLabel:void 0}))}}];let Q=f.attrAny("type"),J="decimal";if(Q==="a")J="lowerAlpha";else if(Q==="A")J="upperAlpha";else if(Q==="i")J="lowerRoman";else if(Q==="I")J="upperRoman";let K=f.attrAny("reversed")!==void 0,V=f.attrAny("start"),Z=(V!==void 0?$f(V):void 0)??(K?z.length:1),j=[];for(let C of z){let G=C.attrAny("value"),X=G!==void 0?$f(G):void 0;if(X!==void 0)Z=X;j.push(Z),Z=K?Z-1:Z+1}if(j.some((C)=>C<1)){let C=z.map((G,X)=>({blocks:this.subBlocks(G,u),checked:void 0,markerLabel:`${j[X]}.`}));return[{type:"list",list:{marker:J,start:1,items:C}}]}let D=[],H,q=0;for(let C=0;C<z.length;C+=1){let G=j[C],X={blocks:this.subBlocks(z[C],u),checked:void 0,markerLabel:void 0};if(!(H!==void 0&&q+1===G)){if(H!==void 0)D.push({type:"list",list:H});H={marker:J,start:G,items:[]}}H.items.push(X),q=G}if(H!==void 0)D.push({type:"list",list:H});return D}parseTable(f,u){let U=[],z=0,Q=!1;for(let Z of f.childElems())if(Z.local==="thead"||Z.local==="tbody"||Z.local==="tfoot"){if(Q)Q=!1,z+=1;let j=Z.local==="thead";for(let D of Z.childElems())if(D.local==="tr")U.push([D,j,z]);z+=1}else if(Z.local==="tr")Q=!0,U.push([Z,!1,z]);if(U.length===0)return;let J=new Map;for(let Z=0;Z<U.length;Z+=1)J.set(U[Z][2],Z);let K=new pf,V=0;for(let Z=0;Z<U.length;Z+=1){let[j,D,H]=U[Z];K.nextRow();let q=!0,C=!1;for(let G of j.childElems()){if(G.local!=="td"&&G.local!=="th")continue;if(C=!0,G.local!=="th")q=!1;let X=Kf(h(G.attrAny("colspan")??"")??1,1,1000),M,b=G.attrAny("rowspan"),S=b!==void 0?h(b):void 0;if(S===0)M=(J.get(H)??Z)-Z+1;else if(S!==void 0)M=Kf(S,1,65534);else M=1;K.place(yf(this.subBlocks(G,u),X,M))}if(Z===V&&(D||q&&C))V+=1}let $=K.finish("data");if($.grid.length===0)return;return $.headerRows=bf($,V),{type:"table",table:$}}flushParagraph(){if(this.inlines.length>0){let f=this.inlines.splice(0,this.inlines.length);if(v(f))this.blocks.push({type:"paragraph",inlines:f})}this.startBoundary=!0}}function f0(f,u){let U={...u};switch(f.local){case"b":case"strong":U.bold=!0;break;case"i":case"em":case"cite":case"dfn":case"var":U.italic=!0;break;case"s":case"del":case"strike":U.strike=!0;break;case"code":case"kbd":case"samp":case"tt":U.code=!0;break;default:break}return U}function Y(f){switch(f.type){case"paragraph":return e(f.inlines);case"heading":return e(f.content);case"list":return f.list.items.flatMap((u)=>u.blocks.map(Y)).join(" ");case"blockQuote":return f.blocks.map(Y).join(" ");case"codeBlock":return f.text;case"table":return f.table.grid.flatMap((u)=>u.flatMap((U)=>U.type==="origin"?[U.cell.blocks.map(Y).join(" ")]:[])).join(" ");case"rule":return""}}function qf(f){return f==="div"||f==="section"||f==="article"||f==="aside"||f==="main"||f==="nav"||f==="header"||f==="footer"||f==="figure"||f==="figcaption"||f==="center"||f==="details"||f==="summary"||f==="li"||f==="dl"||f==="dt"||f==="dd"||f==="body"}function u0(f){return qf(f)||f==="p"||f==="ul"||f==="ol"||f==="table"||f==="blockquote"||f==="pre"||f==="hr"||f==="h1"||f==="h2"||f==="h3"||f==="h4"||f==="h5"||f==="h6"}function U0(f){return f.childElems().some((u)=>u0(u.local))}function v(f){return!E(f)||f.some((u)=>u.type==="anchor")}function N(f,u){for(let U=f.length-1;U>=0;U-=1){let z=f[U];if(z.type==="anchor")continue;if(z.type==="text"){if(z.text.length===0)continue;return J0(z0(z.text))}if(z.type==="lineBreak")return!0;if(z.type==="link"){if(E(z.content))continue;return N(z.content,!1)}return!1}return u}function z0(f){let u=f.length;if(u===0)return 0;let U=f.charCodeAt(u-1);if(U>=56320&&U<=57343&&u>=2){let z=f.charCodeAt(u-2);if(z>=55296&&z<=56319)return(z-55296<<10)+(U-56320)+65536}return U}function J0(f){return f>=9&&f<=13||f===32||f===133||f===160||f===5760||f>=8192&&f<=8202||f===8232||f===8233||f===8239||f===8287||f===12288}function Q0(f,u){let U=0;while(U<f.length&&f[U]===u)U+=1;return f.slice(U)}function $f(f){let u=f.trim();if(!/^-?\d+$/.test(u))return;let U=Number(u);return Number.isFinite(U)?U:void 0}function Kf(f,u,U){return Math.min(U,Math.max(u,f))}function $0(f){let u=Vf(f.attrAny("class"));if(u!==void 0)return u;for(let U of f.childElems()){if(U.local!=="code")continue;let z=Vf(U.attrAny("class"));if(z!==void 0)return z}return}function Vf(f){if(f===void 0||f.length===0)return;let u;for(let U of f.split(/\s+/))if(U.startsWith("language-")){let z=U.slice(9);if(Zf(z))return z}else if(u===void 0&&U.startsWith("lang-")){let z=U.slice(5);if(Zf(z))u=z}return u}function Zf(f){return f.length>0&&!f.includes("`")&&!f.includes(`
|
|
2
|
+
`)&&!f.includes("\r")}function If(f){let u=F0(f),U=new Lf;return _f(u,new r(void 0,U),U)}function Of(f){let u=j0(f),U=V0(u)??Z0(u);if(U===void 0)throw D0.malformed("no text/html or text/plain part");let z=new Lf,Q=L0(u),J=I0(U);if(U.contentType==="text/plain"){let V=wf(),$=Yf(J);if($.length>0)V.blocks.push({type:"paragraph",inlines:[H0($)]});return V.assets=z.assets,V}let K=Wf(J,new TextEncoder().encode(J));return _f(K,new r(Q,z),z)}function F0(f){return Wf(O0(f),f)}function Wf(f,u){if(i(f))try{return G0(u)}catch{}return P(f)}function _f(f,u,U){Sf(f);let z=M0(f),Q=w0(f),J=wf();return J.blocks.push(...x(Q,z,u)),J.assets=U.assets,J}function M0(f){let u=new I;for(let U of f.descendantElems())if(U.local==="style")u.add(U.text());return u}function w0(f){if(f.local==="body")return f;let u=f.local==="html"?f:d(f,"html");if(u!==void 0){let z=d(u,"body");if(z!==void 0)return z;return u}return d(f,"body")??f}function d(f,u){return f.childElems().find((U)=>U.local===u)}function Sf(f){f.local=f.local.toLowerCase();let u=f.attrs;for(let U=0;U<u.length;U+=1)u[U].local=u[U].local.toLowerCase();for(let U of f.childElems())Sf(U)}class r{cids;assets;constructor(f,u){this.cids=f;this.assets=u}linkTarget(f){if(f.length===0)return;if(f.startsWith("#")){let u=K0(f.slice(1));return u.length>0?{type:"anchor",id:u}:void 0}if(Xf(f))return{type:"external",url:f};return{type:"relative",url:f}}imageSource(f){if(f.length===0)return;if(W0(f))return this.resolveDataUri(f);let u=this.resolveCid(f);if(u!==void 0)return u;if(Xf(f))return{type:"external",url:f};return{type:"relative",url:f}}anchorId(f){return f}resolveDataUri(f){let u=_0(f);if(u===void 0)return;return{type:"asset",id:this.assets.add(u.mediaType,f,u.bytes)}}resolveCid(f){if(this.cids===void 0)return;if(f.length<4||f.slice(0,4).toLowerCase()!=="cid:")return;let u=f.slice(4);try{u=decodeURIComponent(u)}catch{}if(u.startsWith("<")&&u.endsWith(">")&&u.length>=2)u=u.slice(1,-1);let U=this.cids.get(u.toLowerCase());if(U===void 0)return;let z=U.filename??u,Q=U.contentType.length>0?U.contentType:q0(z);return{type:"asset",id:this.assets.add(Q,z,U.bytes)}}}function L0(f){let u=new Map;for(let U of C0(f)){let z=Mf(U,"content-id");if(z===void 0)continue;let Q=Y0(z);if(Q.length>0)u.set(Q.toLowerCase(),U)}return u}function Y0(f){let u=Yf(f);if(u.startsWith("<")&&u.endsWith(">")&&u.length>=2)u=u.slice(1,-1);return u}function I0(f){let u=Mf(f,"content-type"),U="utf-8";if(u!==void 0){let z=/charset\s*=\s*("?)([^";\s]+)\1/i.exec(u);if(z!==null)U=z[2]}try{return X0(f.bytes,U)}catch{return new TextDecoder("utf-8",{fatal:!1}).decode(f.bytes)}}function O0(f){if(f.length>=2&&f[0]===255&&f[1]===254)return new TextDecoder("utf-16le").decode(f);if(f.length>=2&&f[0]===254&&f[1]===255)return new TextDecoder("utf-16be").decode(f);if(f.length>=3&&f[0]===239&&f[1]===187&&f[2]===191)return new TextDecoder("utf-8").decode(f.subarray(3));return new TextDecoder("utf-8").decode(f)}function W0(f){return f.length>=5&&f.slice(0,5).toLowerCase()==="data:"}function _0(f){let u=f.slice(5),U=u.indexOf(",");if(U<0)return;let z=u.slice(0,U).split(";"),Q=z[0].trim();if(Q.length===0)Q="application/octet-stream";let J=!1;for(let $=1;$<z.length;$+=1)if(z[$].trim().toLowerCase()==="base64")J=!0;let K=u.slice(U+1),V=J?S0(K):g0(K);if(V===void 0||V.length===0)return;return{mediaType:Q.toLowerCase(),bytes:V}}function S0(f){let u="";for(let U=0;U<f.length;U+=1){let z=f.charCodeAt(U);if(z===9||z===10||z===13||z===32)continue;u+=f[U]}if(u.length===0)return;try{let U=atob(u),z=new Uint8Array(U.length);for(let Q=0;Q<U.length;Q+=1)z[Q]=U.charCodeAt(Q);return z}catch{return}}function g0(f){let u=[];for(let U=0;U<f.length;U+=1){let z=f.charCodeAt(U);if(z===37){if(U+2>=f.length)return;let J=Ff(f.charCodeAt(U+1)),K=Ff(f.charCodeAt(U+2));if(J===void 0||K===void 0)return;u.push(J<<4|K),U+=2;continue}if(z<128){u.push(z);continue}let Q=new TextEncoder().encode(f[U]);for(let J=0;J<Q.length;J+=1)u.push(Q[J])}return u.length===0?void 0:new Uint8Array(u)}function Ff(f){if(f>=48&&f<=57)return f-48;if(f>=65&&f<=70)return f-55;if(f>=97&&f<=102)return f-87;return}var B0=new Set(["htm","html","html4","html5","xhtml","mhtml","mht"]),Bf=new Set(["mhtml","mht"]);function p(){return{id:"html",sniff(f,u){if(Rf(f))return 0;let U=u?.path!==void 0?Af(u.path):void 0;if(Pf(f)||U!==void 0&&Bf.has(U))return 3;if(T0(f))return 0;if(vf(f)&&!n(f))return 3;if(v0(f)&&!n(f))return 2;if(U!==void 0&&B0.has(U))return 1;return 0},convert(f,u){P0(f);let U=u?.path!==void 0?Af(u.path):void 0;if(U!==void 0&&Bf.has(U)||Pf(f))return{markdown:gf(Of(f))};if(n(f))throw O.unsupported("OpenDocument");return{markdown:gf(If(f))}}}}function P0(f){if(R0(f))throw O.unsupported("pdf");if(A0(f))throw O.unsupported("ole");if(Rf(f))throw O.unsupported("zip")}function Rf(f){return f.length>=4&&f[0]===80&&f[1]===75&&f[2]===3&&f[3]===4}function R0(f){let u=c(f);return h0(f,"%PDF-",u)}function v0(f){if(vf(f))return!0;return _(f.subarray(0,Math.min(f.length,4096))).includes("http://www.w3.org/1999/xhtml")}function vf(f){let u=c(f);if(W(f,"<!doctype html",u)&&!y(f[u+14]))return!0;return W(f,"<html",u)&&!y(f[u+5])}function T0(f){let u=c(f);if(W(f,"<svg",u)&&!y(f[u+4]))return!0;if(!W(f,"<?xml",u))return!1;let U=_(f.subarray(0,Math.min(f.length,8192)));return/<svg\b/i.test(U)}function Pf(f){return _(f.subarray(0,Math.min(f.length,4096))).toLowerCase().includes("content-location:")}function n(f){let u=_(f.subarray(0,Math.min(f.length,8192))),U=k(u,0);if(u.startsWith("<?xml",U)){let Q=u.indexOf("?>",U);if(Q<0)return!1;U=k(u,Q+2)}while(u.startsWith("<!--",U)){let Q=u.indexOf("-->",U+4);if(Q<0)return!1;U=k(u,Q+3)}let z=u.slice(U,U+2048);return/<office:document\b/.test(z)}function c(f){let u=0;if(f.length>=3&&f[0]===239&&f[1]===187&&f[2]===191)u=3;while(u<f.length){let U=f[u];if(U!==9&&U!==10&&U!==13&&U!==32)break;u+=1}return u}function k(f,u){while(u<f.length){let U=f.charCodeAt(u);if(U!==9&&U!==10&&U!==13&&U!==32)break;u+=1}return u}function h0(f,u,U){if(U+u.length>f.length)return!1;for(let z=0;z<u.length;z+=1)if(f[U+z]!==u.charCodeAt(z))return!1;return!0}function W(f,u,U){if(U+u.length>f.length)return!1;for(let z=0;z<u.length;z+=1){let Q=f[U+z],J=u.charCodeAt(z);if(Q===J)continue;let K=Q>=65&&Q<=90?Q+32:Q,V=J>=65&&J<=90?J+32:J;if(K!==V)return!1}return!0}function y(f){if(f===void 0)return!1;return f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||f===45||f===95||f===58}function _(f){return new TextDecoder("utf-8",{fatal:!1}).decode(f)}import{create as N0}from"@mdgate/core";var E0=N0([p()]);function x0(f,u){return E0(f,u)}export{x0 as toMarkdown,x as toBlocks,P as parseHtml,p as html,I as Stylesheet};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdgate/html",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"description": "mdgate HTML, XHTML, and MHTML converter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://convert.mdgate.dev",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/mdgate/converters.git",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"prepublishOnly": "bun run build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@mdgate/containers": "0.6.
|
|
32
|
-
"@mdgate/core": "0.6.
|
|
33
|
-
"@mdgate/document": "0.6.
|
|
34
|
-
"@mdgate/office-common": "0.6.
|
|
35
|
-
"@mdgate/utils": "0.6.
|
|
31
|
+
"@mdgate/containers": "0.6.9",
|
|
32
|
+
"@mdgate/core": "0.6.9",
|
|
33
|
+
"@mdgate/document": "0.6.9",
|
|
34
|
+
"@mdgate/office-common": "0.6.9",
|
|
35
|
+
"@mdgate/utils": "0.6.9"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|