@aiquants/html-to-markdown 0.4.0 → 0.5.1

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.
@@ -1,5 +1,5 @@
1
- import { J as JSONRPCMessageSchema, i as isInitializeRequest, e as isJSONRPCRequest, D as DEFAULT_NEGOTIATED_PROTOCOL_VERSION, f as SUPPORTED_PROTOCOL_VERSIONS, h as isJSONRPCResponse, j as isJSONRPCError, g as getPackageVersion, S as Server, I as InitializeRequestSchema, L as ListToolsRequestSchema, C as CallToolRequestSchema, p as parseHtmlToMarkdownArgs, b as parseSaveContentArgs, s as saveContentToFile, d as parseUrlToMarkdownFileArgs } from "./version-BSh9aXhF.js";
2
- import { a as getAugmentedNamespace, c as commonjsGlobal, b as getDefaultExportFromCjs, h as htmlToMarkdown } from "./core-CouDTni-.js";
1
+ import { J as JSONRPCMessageSchema, i as isInitializeRequest, e as isJSONRPCRequest, D as DEFAULT_NEGOTIATED_PROTOCOL_VERSION, f as SUPPORTED_PROTOCOL_VERSIONS, h as isJSONRPCResponse, j as isJSONRPCError, g as getPackageVersion, S as Server, I as InitializeRequestSchema, L as ListToolsRequestSchema, C as CallToolRequestSchema, p as parseHtmlToMarkdownArgs, b as parseSaveContentArgs, s as saveContentToFile, d as parseUrlToMarkdownFileArgs } from "./version-BNwQMbri.js";
2
+ import { a as getAugmentedNamespace, c as commonjsGlobal, b as getDefaultExportFromCjs, h as htmlToMarkdown } from "./core-DhxxOcPm.js";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import cors from "cors";
5
5
  import express from "express";
@@ -7551,7 +7551,7 @@ class StreamableHtmlToMarkdownMcpServer {
7551
7551
  try {
7552
7552
  res.setHeader("Content-Type", "application/json");
7553
7553
  const request = req.body;
7554
- if (!request || !request.method) {
7554
+ if (!(request && request.method)) {
7555
7555
  res.status(400).json({
7556
7556
  jsonrpc: "2.0",
7557
7557
  error: {
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";require("./mcp-server-streamable-BNn6Kd9b.cjs").runStreamableMcpServer().catch(e=>{process.exit(1)});
2
+ "use strict";require("./mcp-server-streamable-DUB_ixZe.cjs").runStreamableMcpServer().catch(e=>{process.exit(1)});
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { r as runStreamableMcpServer } from "./mcp-server-streamable-CcZ7Lsel.js";
2
+ import { r as runStreamableMcpServer } from "./mcp-server-streamable-pcpU_lDl.js";
3
3
  runStreamableMcpServer().catch((error) => {
4
4
  console.error("Failed to start streamable MCP server:", error);
5
5
  process.exit(1);
package/dist/mcp.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const e=new(require("happy-dom").Window);Object.assign(global,{document:e.document,window:e,self:e});require("./mcp-server-Co1kuNGX.cjs").runMcpServer().catch(e=>{process.exit(1)});
2
+ const e=new(require("happy-dom").Window);Object.assign(global,{document:e.document,window:e,self:e});require("./mcp-server-Dn3EHzcf.cjs").runMcpServer().catch(e=>{process.exit(1)});
package/dist/mcp.js CHANGED
@@ -6,7 +6,7 @@ Object.assign(global, {
6
6
  window,
7
7
  self: window
8
8
  });
9
- import { r as runMcpServer } from "./mcp-server-DzB_5cTs.js";
9
+ import { r as runMcpServer } from "./mcp-server-DOe8W9IZ.js";
10
10
  runMcpServer().catch((error) => {
11
11
  console.error("Failed to start MCP server:", error);
12
12
  process.exit(1);
@@ -4,6 +4,6 @@
4
4
  */
5
5
  export { htmlToMarkdown } from './core.ts';
6
6
  export { getMessage } from './i18n.ts';
7
- export type { HtmlToMarkdownOptions } from './types.ts';
8
7
  export { createMcpServer, runMcpServer } from './mcp-server.ts';
9
8
  export { createStreamableMcpServer, runStreamableMcpServer } from './mcp-server-streamable.ts';
9
+ export type { HtmlToMarkdownOptions } from './types.ts';
@@ -1,6 +1,6 @@
1
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
2
  import { HtmlToMarkdownArgs, SaveContentArgs, UrlToMarkdownFileArgs } from './mcp-common.ts';
3
- export { type HtmlToMarkdownArgs, type SaveContentArgs, type UrlToMarkdownFileArgs, parseHtmlToMarkdownArgs, parseSaveContentArgs, parseUrlToMarkdownFileArgs, saveContentToFile, createErrorResult, createSuccessResult, MCP_TOOL_SCHEMAS, } from './mcp-common.ts';
3
+ export { createErrorResult, createSuccessResult, type HtmlToMarkdownArgs, MCP_TOOL_SCHEMAS, parseHtmlToMarkdownArgs, parseSaveContentArgs, parseUrlToMarkdownFileArgs, type SaveContentArgs, saveContentToFile, type UrlToMarkdownFileArgs, } from './mcp-common.ts';
4
4
  /**
5
5
  * MCP Server for HTML to Markdown conversion.
6
6
  * HTML から Markdown への変換を行う MCP サーバー
@@ -3,6 +3,7 @@
3
3
  * Rehype プラグインのインデックス
4
4
  */
5
5
  export { rehypeAbsoluteLinks } from './rehype-absolute-links.ts';
6
+ export { rehypeDecodeEntities, preprocessHtmlEntities } from './rehype-decode-entities.ts';
6
7
  export { rehypeNamedAnchors } from './rehype-named-anchors.ts';
7
8
  export { rehypeParagraphWrapper } from './rehype-paragraph-wrapper.ts';
8
9
  export { rehypeSanitizeHtml } from './rehype-sanitize-html.ts';
@@ -0,0 +1,14 @@
1
+ import { Root } from 'hast';
2
+ /**
3
+ * Decode HTML entities in text nodes and element properties.
4
+ * テキストノードと要素プロパティ内の HTML エンティティをデコードします。
5
+ */
6
+ export declare const rehypeDecodeEntities: () => (tree: Root) => void;
7
+ /**
8
+ * Pre-process HTML string to decode entities before parsing.
9
+ * パース前にHTML文字列内のエンティティを事前デコードします。
10
+ *
11
+ * @param html - HTML string that may contain entities / エンティティを含む可能性のあるHTML文字列
12
+ * @returns Decoded HTML string / デコードされたHTML文字列
13
+ */
14
+ export declare const preprocessHtmlEntities: (html: string) => string;
@@ -20,16 +20,16 @@ export interface HtmlToMarkdownOptions {
20
20
  */
21
21
  htmlContent?: string;
22
22
  }
23
- /**
24
- * Message keys for i18n.
25
- * i18n 用のメッセージキー
26
- */
27
- export type MessageKey = "error_url_required" | "usage" | "example" | "cli_start" | "cli_url" | "cli_locale" | "cli_output" | "success_save" | "success_path" | "error_app" | "playwright_launch" | "playwright_goto" | "playwright_get_content" | "playwright_close" | "playwright_error" | "convert_start" | "convert_success" | "url_parse_error";
28
23
  /**
29
24
  * Supported locales.
30
25
  * サポートされているロケール
31
26
  */
32
- export type SupportedLocale = "ja-JP" | "en-US";
27
+ export type SupportedLocale = "en-US" | "ja-JP";
28
+ /**
29
+ * Message keys for i18n.
30
+ * i18n 用のメッセージキー
31
+ */
32
+ export type MessageKey = "error_url_required" | "error_url_or_html_required" | "usage" | "example" | "cli_start" | "cli_url" | "cli_html_content" | "cli_locale" | "cli_output" | "success_save" | "success_path" | "error_app" | "playwright_launch" | "playwright_goto" | "playwright_get_content" | "playwright_close" | "playwright_error" | "convert_start" | "convert_success" | "url_parse_error";
33
33
  /**
34
34
  * The following types are based on the type definitions of `hast-util-to-mdast`.
35
35
  * `hast-util-to-mdast` の型定義に基づいた型。
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Test for comprehensive HTML entity decoding functionality.
3
+ * 包括的なHTMLエンティティデコード機能のテスト
4
+ */
5
+ export {};
@@ -5,7 +5,7 @@ Object.assign(global, {
5
5
  window,
6
6
  self: window
7
7
  });
8
- import { b as getDefaultExportFromCjs } from "./core-CouDTni-.js";
8
+ import { b as getDefaultExportFromCjs } from "./core-DhxxOcPm.js";
9
9
  import { promises } from "fs";
10
10
  import { resolve, dirname } from "path";
11
11
  import { readFileSync } from "node:fs";
@@ -11297,7 +11297,7 @@ function parseHtmlToMarkdownArgs(args) {
11297
11297
  throw new Error("Arguments are required");
11298
11298
  }
11299
11299
  const { url, html_content, locale = "en-US" } = args;
11300
- if (!url && !html_content) {
11300
+ if (!(url || html_content)) {
11301
11301
  throw new Error("Either 'url' or 'html_content' is required");
11302
11302
  }
11303
11303
  if (url && typeof url !== "string") {
@@ -11323,7 +11323,7 @@ function parseSaveContentArgs(args) {
11323
11323
  if (!content || typeof content !== "string") {
11324
11324
  throw new Error("'content' is required and must be a string");
11325
11325
  }
11326
- if (!save_path && !save_directory) {
11326
+ if (!(save_path || save_directory)) {
11327
11327
  throw new Error("Either 'save_path' or 'save_directory' is required");
11328
11328
  }
11329
11329
  if (save_path && typeof save_path !== "string") {
@@ -11350,7 +11350,7 @@ function parseUrlToMarkdownFileArgs(args) {
11350
11350
  throw new Error("Arguments are required");
11351
11351
  }
11352
11352
  const { url, html_content, locale = "en-US", save_path, save_directory, filename } = args;
11353
- if (!url && !html_content) {
11353
+ if (!(url || html_content)) {
11354
11354
  throw new Error("Either 'url' or 'html_content' is required");
11355
11355
  }
11356
11356
  if (url && typeof url !== "string") {
@@ -11362,7 +11362,7 @@ function parseUrlToMarkdownFileArgs(args) {
11362
11362
  if (locale && !["en-US", "ja-JP"].includes(locale)) {
11363
11363
  throw new Error("'locale' must be 'en-US' or 'ja-JP'");
11364
11364
  }
11365
- if (!save_path && !save_directory) {
11365
+ if (!(save_path || save_directory)) {
11366
11366
  throw new Error("Either 'save_path' or 'save_directory' is required");
11367
11367
  }
11368
11368
  if (save_path && typeof save_path !== "string") {