@aiquants/html-to-markdown 0.2.4 → 0.2.5
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.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/mcp-server-Bo_mCvzz.cjs +1 -0
- package/dist/{mcp-server-BEggrdWH.js → mcp-server-CueTvF4M.js} +8 -8
- package/dist/{mcp-server-streamable-CuBJeQTj.js → mcp-server-streamable-BC-Qlr-9.js} +8 -8
- package/dist/{mcp-server-streamable-B3R3qi85.cjs → mcp-server-streamable-Cc4QsZQe.cjs} +1 -1
- package/dist/mcp-streamable.cjs +1 -1
- package/dist/mcp-streamable.js +1 -1
- package/dist/mcp.cjs +1 -1
- package/dist/mcp.js +1 -1
- package/mcp.json +2 -2
- package/package.json +1 -1
- package/dist/mcp-server-B5lrAMe3.cjs +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=new(require("happy-dom").Window);Object.assign(global,{document:e.document,window:e,self:e}),Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./core-D2dlEt1l.cjs"),t=require("./mcp-server-
|
|
1
|
+
const e=new(require("happy-dom").Window);Object.assign(global,{document:e.document,window:e,self:e}),Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./core-D2dlEt1l.cjs"),t=require("./mcp-server-Bo_mCvzz.cjs"),c=require("./mcp-server-streamable-Cc4QsZQe.cjs");exports.getMessage=r.getMessage,exports.htmlToMarkdown=r.htmlToMarkdown,exports.createMcpServer=t.createMcpServer,exports.runMcpServer=t.runMcpServer,exports.createStreamableMcpServer=c.createStreamableMcpServer,exports.runStreamableMcpServer=c.runStreamableMcpServer;
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.assign(global, {
|
|
|
6
6
|
self: window
|
|
7
7
|
});
|
|
8
8
|
import { g, h } from "./core-CFnkfU5N.js";
|
|
9
|
-
import { c, r } from "./mcp-server-
|
|
10
|
-
import { c as c2, r as r2 } from "./mcp-server-streamable-
|
|
9
|
+
import { c, r } from "./mcp-server-CueTvF4M.js";
|
|
10
|
+
import { c as c2, r as r2 } from "./mcp-server-streamable-BC-Qlr-9.js";
|
|
11
11
|
export {
|
|
12
12
|
c as createMcpServer,
|
|
13
13
|
c2 as createStreamableMcpServer,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=new(require("happy-dom").Window);Object.assign(global,{document:t.document,window:t,self:t});const e=require("./version-DTaUKNBS.cjs"),r=require("node:process"),n=require("fs"),o=require("path"),s=require("./core-D2dlEt1l.cjs");class a{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;const t=this._buffer.indexOf("\n");if(-1===t)return null;const r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),function(t){return e.JSONRPCMessageSchema.parse(JSON.parse(t))}(r)}clear(){this._buffer=void 0}}class i{constructor(t=r.stdin,e=r.stdout){this._stdin=t,this._stdout=e,this._readBuffer=new a,this._started=!1,this._ondata=t=>{this._readBuffer.append(t),this.processReadBuffer()},this._onerror=t=>{var e;null===(e=this.onerror)||void 0===e||e.call(this,t)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(var t,e;;)try{const e=this._readBuffer.readMessage();if(null===e)break;null===(t=this.onmessage)||void 0===t||t.call(this,e)}catch(r){null===(e=this.onerror)||void 0===e||e.call(this,r)}}async close(){var t;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror);0===this._stdin.listenerCount("data")&&this._stdin.pause(),this._readBuffer.clear(),null===(t=this.onclose)||void 0===t||t.call(this)}send(t){return new Promise(e=>{const r=function(t){return JSON.stringify(t)+"\n"}(t);this._stdout.write(r)?e():this._stdout.once("drain",e)})}}function c(t,e){if(t&&"direct-html-input"!==t)try{let e=new URL(t).pathname.split("/").pop()||"page";return e=e.replace(/\.[^.]*$/,""),e=e.replace(/[<>:"/\\|?*]/g,"_"),e&&!e.match(/^\.+$/)||(e="page"),e}catch{return"page"}return"page"}async function l(t,e,r,s,a){if(!e&&!r)return null;let i;if(e)i=o.resolve(e);else{if(!r)return null;{const t=c(s),e="html"===a?".html":".md";i=o.resolve(r,`${t}${e}`)}}return await n.promises.mkdir(o.dirname(i),{recursive:!0}),await n.promises.writeFile(i,t,"utf-8"),i}class d{constructor(){this.version=e.getPackageVersion(),this.server=new e.Server({name:"@aiquants/html-to-markdown",version:this.version,description:"Convert web pages and HTML to Markdown with JavaScript dynamic content support, table structure preservation, and file saving capabilities."},{capabilities:{tools:{}}}),this.setupToolHandlers()}setupToolHandlers(){this.server.setRequestHandler(e.ListToolsRequestSchema,async()=>({tools:[{name:"html_to_markdown",description:"Convert web pages or HTML strings to Markdown format. Handles JavaScript-rendered dynamic content and preserves table structures with file saving capabilities.",inputSchema:{type:"object",properties:{url:{type:"string",description:"URL of the web page to convert (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively."},html_content:{type:"string",description:"HTML string to convert directly. Use instead of URL for local files or API response HTML content."},locale:{type:"string",description:"Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.",enum:["en-US","ja-JP"],default:"en-US"},output_format:{type:"string",description:"Output format: 'markdown' (Markdown only), 'html' (original HTML only), 'both' (returns both formats).",enum:["markdown","html","both"],default:"markdown"},save_path:{type:"string",description:"Complete file path including filename to save converted content (e.g., '/home/user/output.md'). Cannot be used with save_directory."},save_directory:{type:"string",description:"Directory path to save converted content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path."}},anyOf:[{required:["url"]},{required:["html_content"]}]}}]})),this.server.setRequestHandler(e.CallToolRequestSchema,async t=>{if("html_to_markdown"===t.params.name)return await this.handleHtmlToMarkdown(t.params.arguments);throw new Error(`Unknown tool: ${t.params.name}`)})}async handleHtmlToMarkdown(t){try{const e=function(t){if(!t||"object"!=typeof t)throw new Error("Arguments are required");const{url:e,html_content:r,locale:n="en-US",output_format:o="markdown",save_path:s,save_directory:a}=t;if(!e&&!r)throw new Error("Either 'url' or 'html_content' is required");if(e&&"string"!=typeof e)throw new Error("'url' must be a string");if(r&&"string"!=typeof r)throw new Error("'html_content' must be a string");if(n&&!["en-US","ja-JP"].includes(n))throw new Error("'locale' must be 'en-US' or 'ja-JP'");if(o&&!["markdown","html","both"].includes(o))throw new Error("'output_format' must be 'markdown', 'html', or 'both'");if(s&&"string"!=typeof s)throw new Error("'save_path' must be a string");if(a&&"string"!=typeof a)throw new Error("'save_directory' must be a string");if(s&&a)throw new Error("Cannot specify both 'save_path' and 'save_directory'");return{url:e,html_content:r,locale:n,output_format:o,save_path:s,save_directory:a}}(t),{url:r,html_content:n,locale:a="en-US",output_format:i="markdown",save_path:d,save_directory:h}=e;if(r)try{new URL(r)}catch{throw new Error(`Invalid URL: ${r}`)}const u=await s.htmlToMarkdown(r||"direct-html-input",{locale:a,htmlContent:n}),m=[];if(d||h)switch(i){case"markdown":{const t=await l(u.markdown,d,h,r,"markdown");t&&m.push(t);break}case"html":{const t=await l(u.html,d,h,r,"html");t&&m.push(t);break}case"both":{const t=d?d.endsWith(".md")?d:`${d}.md`:h?o.join(h,`${c(r)}.md`):void 0;if(t){const e=await l(u.markdown,t,void 0,r,"markdown");e&&m.push(e)}const e=d?d.endsWith(".html")?d:`${d}.html`:h?o.join(h,`${c(r)}.html`):void 0;if(e){const t=await l(u.html,e,void 0,r,"html");t&&m.push(t)}break}}let f="";switch(i){case"markdown":f=u.markdown;break;case"html":f=u.html;break;case"both":f=`=== Markdown ===\n${u.markdown}\n\n=== HTML ===\n${u.html}`;break;default:throw new Error(`Invalid output format: ${i}`)}m.length>0&&(f+=`\n\n=== Files Saved ===\n${m.map(t=>`- ${t}`).join("\n")}`);return{content:[{type:"text",text:f}],isError:!1}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}}async start(){const t=new i;await this.server.connect(t)}}const h=()=>new d;exports.createMcpServer=h,exports.runMcpServer=async()=>{const t=h();await t.start()};
|
|
@@ -178,7 +178,7 @@ class HtmlToMarkdownMcpServer {
|
|
|
178
178
|
{
|
|
179
179
|
name: "@aiquants/html-to-markdown",
|
|
180
180
|
version: this.version,
|
|
181
|
-
description: "
|
|
181
|
+
description: "Convert web pages and HTML to Markdown with JavaScript dynamic content support, table structure preservation, and file saving capabilities."
|
|
182
182
|
},
|
|
183
183
|
{
|
|
184
184
|
capabilities: {
|
|
@@ -198,37 +198,37 @@ class HtmlToMarkdownMcpServer {
|
|
|
198
198
|
tools: [
|
|
199
199
|
{
|
|
200
200
|
name: "html_to_markdown",
|
|
201
|
-
description: "Convert
|
|
201
|
+
description: "Convert web pages or HTML strings to Markdown format. Handles JavaScript-rendered dynamic content and preserves table structures with file saving capabilities.",
|
|
202
202
|
inputSchema: {
|
|
203
203
|
type: "object",
|
|
204
204
|
properties: {
|
|
205
205
|
url: {
|
|
206
206
|
type: "string",
|
|
207
|
-
description: "
|
|
207
|
+
description: "URL of the web page to convert (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively."
|
|
208
208
|
},
|
|
209
209
|
html_content: {
|
|
210
210
|
type: "string",
|
|
211
|
-
description: "HTML
|
|
211
|
+
description: "HTML string to convert directly. Use instead of URL for local files or API response HTML content."
|
|
212
212
|
},
|
|
213
213
|
locale: {
|
|
214
214
|
type: "string",
|
|
215
|
-
description: "
|
|
215
|
+
description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.",
|
|
216
216
|
enum: ["en-US", "ja-JP"],
|
|
217
217
|
default: "en-US"
|
|
218
218
|
},
|
|
219
219
|
output_format: {
|
|
220
220
|
type: "string",
|
|
221
|
-
description: "Output format: 'markdown' (
|
|
221
|
+
description: "Output format: 'markdown' (Markdown only), 'html' (original HTML only), 'both' (returns both formats).",
|
|
222
222
|
enum: ["markdown", "html", "both"],
|
|
223
223
|
default: "markdown"
|
|
224
224
|
},
|
|
225
225
|
save_path: {
|
|
226
226
|
type: "string",
|
|
227
|
-
description: "
|
|
227
|
+
description: "Complete file path including filename to save converted content (e.g., '/home/user/output.md'). Cannot be used with save_directory."
|
|
228
228
|
},
|
|
229
229
|
save_directory: {
|
|
230
230
|
type: "string",
|
|
231
|
-
description: "Directory path
|
|
231
|
+
description: "Directory path to save converted content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path."
|
|
232
232
|
}
|
|
233
233
|
},
|
|
234
234
|
anyOf: [{ required: ["url"] }, { required: ["html_content"] }]
|
|
@@ -7201,7 +7201,7 @@ class StreamableHtmlToMarkdownMcpServer {
|
|
|
7201
7201
|
{
|
|
7202
7202
|
name: "@aiquants/html-to-markdown-streamable",
|
|
7203
7203
|
version: this.version,
|
|
7204
|
-
description: "
|
|
7204
|
+
description: "Streamable HTML to Markdown converter with real-time progress updates and JavaScript dynamic content support."
|
|
7205
7205
|
},
|
|
7206
7206
|
{
|
|
7207
7207
|
capabilities: {
|
|
@@ -7218,31 +7218,31 @@ class StreamableHtmlToMarkdownMcpServer {
|
|
|
7218
7218
|
properties: {
|
|
7219
7219
|
url: {
|
|
7220
7220
|
type: "string",
|
|
7221
|
-
description: "
|
|
7221
|
+
description: "URL of the web page to convert (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively."
|
|
7222
7222
|
},
|
|
7223
7223
|
html_content: {
|
|
7224
7224
|
type: "string",
|
|
7225
|
-
description: "HTML
|
|
7225
|
+
description: "HTML string to convert directly. Use instead of URL for local files or API response HTML content."
|
|
7226
7226
|
},
|
|
7227
7227
|
locale: {
|
|
7228
7228
|
type: "string",
|
|
7229
|
-
description: "
|
|
7229
|
+
description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.",
|
|
7230
7230
|
enum: ["en-US", "ja-JP"],
|
|
7231
7231
|
default: "en-US"
|
|
7232
7232
|
},
|
|
7233
7233
|
output_format: {
|
|
7234
7234
|
type: "string",
|
|
7235
|
-
description: "Output format: 'markdown' (
|
|
7235
|
+
description: "Output format: 'markdown' (Markdown only), 'html' (original HTML only), 'both' (returns both formats).",
|
|
7236
7236
|
enum: ["markdown", "html", "both"],
|
|
7237
7237
|
default: "markdown"
|
|
7238
7238
|
},
|
|
7239
7239
|
save_path: {
|
|
7240
7240
|
type: "string",
|
|
7241
|
-
description: "
|
|
7241
|
+
description: "Complete file path including filename to save converted content (e.g., '/home/user/output.md'). Cannot be used with save_directory."
|
|
7242
7242
|
},
|
|
7243
7243
|
save_directory: {
|
|
7244
7244
|
type: "string",
|
|
7245
|
-
description: "Directory path
|
|
7245
|
+
description: "Directory path to save converted content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path."
|
|
7246
7246
|
}
|
|
7247
7247
|
},
|
|
7248
7248
|
anyOf: [{ required: ["url"] }, { required: ["html_content"] }]
|
|
@@ -7250,7 +7250,7 @@ class StreamableHtmlToMarkdownMcpServer {
|
|
|
7250
7250
|
this.tools = [
|
|
7251
7251
|
{
|
|
7252
7252
|
name: "html_to_markdown_streamable",
|
|
7253
|
-
description: "
|
|
7253
|
+
description: "Streamable HTML to Markdown converter with real-time progress updates. Ideal for large pages and time-consuming conversions with JavaScript dynamic content support.",
|
|
7254
7254
|
inputSchema: toolParameters,
|
|
7255
7255
|
handler: (args, context) => this.handleHtmlToMarkdown(args, context)
|
|
7256
7256
|
}
|