@aiquants/html-to-markdown 1.3.1 → 1.3.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/README.md +21 -21
- package/dist/index.d.ts +2 -2
- package/dist/main.d.ts +0 -5
- package/dist/mcp-streamable.d.ts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/src/browser.d.ts +0 -10
- package/dist/src/cli.d.ts +0 -8
- package/dist/src/converter.d.ts +0 -13
- package/dist/src/core.d.ts +1 -9
- package/dist/src/i18n.d.ts +1 -9
- package/dist/src/index.d.ts +5 -9
- package/dist/src/mcp-common.d.ts +62 -67
- package/dist/src/mcp-server-streamable.d.ts +3 -51
- package/dist/src/mcp-server.d.ts +3 -39
- package/dist/src/mcp-streamable.d.ts +0 -4
- package/dist/src/mcp.d.ts +0 -4
- package/dist/src/plugins/index.d.ts +6 -10
- package/dist/src/plugins/rehype-absolute-links.d.ts +1 -6
- package/dist/src/plugins/rehype-decode-entities.d.ts +1 -12
- package/dist/src/plugins/rehype-named-anchors.d.ts +1 -1
- package/dist/src/plugins/rehype-paragraph-wrapper.d.ts +1 -5
- package/dist/src/plugins/rehype-sanitize-html.d.ts +1 -6
- package/dist/src/plugins/rehype-wikipedia-footnotes.d.ts +1 -5
- package/dist/src/simple-logger.d.ts +0 -62
- package/dist/src/types.d.ts +2 -32
- package/dist/src/version.d.ts +0 -8
- package/package.json +6 -6
- package/dist/tests/core-unified.test.d.ts +0 -5
- package/dist/tests/coverage-complete.test.d.ts +0 -5
- package/dist/tests/entity-decoding.test.d.ts +0 -5
- package/dist/tests/entry-points-error.test.d.ts +0 -1
- package/dist/tests/mcp-unified.test.d.ts +0 -5
- package/dist/tests/plugins-unified.test.d.ts +0 -5
- package/dist/tests/test-client.d.ts +0 -4
- package/dist/vite.config.d.ts +0 -2
- package/dist/vitest.config.d.ts +0 -2
package/README.md
CHANGED
|
@@ -60,8 +60,8 @@ npx @aiquants/html-to-markdown https://ja.wikipedia.org/wiki/Node.js --locale ja
|
|
|
60
60
|
# Convert HTML content directly
|
|
61
61
|
npx @aiquants/html-to-markdown --html-content '<html><body><h1>Sample Title</h1><p>This is a sample paragraph.</p></body></html>' --output ./sample.md
|
|
62
62
|
|
|
63
|
-
# Convert HTML content with
|
|
64
|
-
npx @aiquants/html-to-markdown --html-content '<html><body><h1
|
|
63
|
+
# Convert HTML content with locale setting
|
|
64
|
+
npx @aiquants/html-to-markdown --html-content '<html><body><h1>Sample Title</h1><p>This is a localized sample paragraph.</p></body></html>' --locale en-US -o ./sample-en.md
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
### As a Library
|
|
@@ -340,25 +340,25 @@ This tool follows these steps for conversion:
|
|
|
340
340
|
|
|
341
341
|
This project is built upon the following open-source software. We are grateful to the developers of these libraries.
|
|
342
342
|
|
|
343
|
-
| Package
|
|
344
|
-
|
|
|
345
|
-
| @modelcontextprotocol/sdk
|
|
346
|
-
| cors
|
|
347
|
-
| express
|
|
348
|
-
| github-slugger
|
|
349
|
-
| happy-dom
|
|
350
|
-
| hast
|
|
351
|
-
| hast-util-to-html
|
|
352
|
-
| playwright
|
|
353
|
-
| rehype-parse
|
|
354
|
-
| rehype-raw
|
|
355
|
-
| rehype-remark
|
|
356
|
-
| rehype-slug
|
|
357
|
-
| remark-gfm
|
|
358
|
-
| remark-stringify
|
|
359
|
-
| unified
|
|
360
|
-
| unist-util-visit
|
|
361
|
-
| yargs-parser
|
|
343
|
+
| Package | License |
|
|
344
|
+
| --- | --- |
|
|
345
|
+
| @modelcontextprotocol/sdk | MIT |
|
|
346
|
+
| cors | MIT |
|
|
347
|
+
| express | MIT |
|
|
348
|
+
| github-slugger | ISC |
|
|
349
|
+
| happy-dom | MIT |
|
|
350
|
+
| hast | MIT |
|
|
351
|
+
| hast-util-to-html | MIT |
|
|
352
|
+
| playwright | Apache-2.0 |
|
|
353
|
+
| rehype-parse | MIT |
|
|
354
|
+
| rehype-raw | MIT |
|
|
355
|
+
| rehype-remark | MIT |
|
|
356
|
+
| rehype-slug | MIT |
|
|
357
|
+
| remark-gfm | MIT |
|
|
358
|
+
| remark-stringify | MIT |
|
|
359
|
+
| unified | MIT |
|
|
360
|
+
| unist-util-visit | MIT |
|
|
361
|
+
| yargs-parser | ISC |
|
|
362
362
|
|
|
363
363
|
*This list is generated based on the `dependencies` in `package.json`. For the most accurate and up-to-date license information, please refer to the individual packages.*
|
|
364
364
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export {}
|
|
1
|
+
export * from "./src/index";
|
|
2
|
+
export {};
|
package/dist/main.d.ts
CHANGED
package/dist/mcp-streamable.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|
package/dist/src/browser.d.ts
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser automation module using Playwright.
|
|
3
|
-
* Playwright を使用したブラウザ自動化モジュール
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Playwrightを使用してURLから動的にレンダリングされたHTMLを取得する
|
|
7
|
-
* @param url 取得対象のURL
|
|
8
|
-
* @param locale ブラウザのロケール
|
|
9
|
-
* @returns HTMLコンテンツ
|
|
10
|
-
*/
|
|
11
1
|
export declare const getHtmlWithPlaywright: (url: string, locale: string) => Promise<string>;
|
package/dist/src/cli.d.ts
CHANGED
package/dist/src/converter.d.ts
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML to Markdown conversion module.
|
|
3
|
-
* HTML から Markdown への変換モジュール
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Convert HTML string to Markdown format.
|
|
7
|
-
* HTML 文字列を Markdown 形式に変換する。
|
|
8
|
-
*
|
|
9
|
-
* @param html - The HTML content to convert / 変換する HTML コンテンツ
|
|
10
|
-
* @param baseUrl - Base URL for converting links to absolute paths / リンクを絶対パスに変換するためのベース URL
|
|
11
|
-
* @param locale - Locale setting for internationalization / 国際化のためのロケール設定
|
|
12
|
-
* @returns Promise resolving to Markdown text / Markdown テキストを返す Promise
|
|
13
|
-
*/
|
|
14
1
|
export declare const convertHtmlToMarkdown: (html: string, baseUrl: string, locale: string) => Promise<string>;
|
package/dist/src/core.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import { HtmlToMarkdownOptions } from
|
|
2
|
-
/**
|
|
3
|
-
* Converts the HTML content of a given URL or HTML string to Markdown.
|
|
4
|
-
* 指定されたURLまたはHTML文字列のHTMLコンテンツをMarkdownに変換します。
|
|
5
|
-
*
|
|
6
|
-
* @param urlOrHtml The URL of the web page to convert or HTML string when using htmlContent option. / 変換対象のWebページのURLまたはhtmlContentオプション使用時のHTML文字列。
|
|
7
|
-
* @param options Options for the conversion process. / 変換プロセスのオプション。
|
|
8
|
-
* @returns A promise that resolves to an object containing the HTML and Markdown strings. / HTMLとMarkdown文字列を含むオブジェクトを解決するPromise。
|
|
9
|
-
*/
|
|
1
|
+
import { HtmlToMarkdownOptions } from "./types.ts";
|
|
10
2
|
export declare const htmlToMarkdown: (urlOrHtml: string, options?: HtmlToMarkdownOptions) => Promise<{
|
|
11
3
|
html: string;
|
|
12
4
|
markdown: string;
|
package/dist/src/i18n.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import { MessageKey } from
|
|
2
|
-
/**
|
|
3
|
-
* Gets a localized message.
|
|
4
|
-
* ローカライズされたメッセージを取得します。
|
|
5
|
-
* @param locale The locale to use.
|
|
6
|
-
* @param key The message key.
|
|
7
|
-
* @param replacements Optional replacements for placeholders.
|
|
8
|
-
* @returns The localized message string.
|
|
9
|
-
*/
|
|
1
|
+
import { MessageKey } from "./types.ts";
|
|
10
2
|
export declare const getMessage: (locale: string, key: MessageKey, replacements?: {
|
|
11
3
|
[key: string]: string;
|
|
12
4
|
}) => string;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
export { getMessage } from './i18n.ts';
|
|
7
|
-
export { createMcpServer, runMcpServer } from './mcp-server.ts';
|
|
8
|
-
export { createStreamableMcpServer, runStreamableMcpServer } from './mcp-server-streamable.ts';
|
|
9
|
-
export type { HtmlToMarkdownOptions } from './types.ts';
|
|
1
|
+
export { htmlToMarkdown } from "./core.ts";
|
|
2
|
+
export { getMessage } from "./i18n.ts";
|
|
3
|
+
export { createMcpServer, runMcpServer } from "./mcp-server.ts";
|
|
4
|
+
export { createStreamableMcpServer, runStreamableMcpServer } from "./mcp-server-streamable.ts";
|
|
5
|
+
export type { HtmlToMarkdownOptions } from "./types.ts";
|
package/dist/src/mcp-common.d.ts
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import { CallToolResult } from
|
|
2
|
-
/**
|
|
3
|
-
* Arguments for HTML to Markdown conversion tool.
|
|
4
|
-
* HTML から Markdown への変換ツールの引数
|
|
5
|
-
*/
|
|
1
|
+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
6
2
|
export interface HtmlToMarkdownArgs {
|
|
7
3
|
url?: string;
|
|
8
4
|
html_content?: string;
|
|
9
5
|
locale?: "en-US" | "ja-JP";
|
|
10
6
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Arguments for file saving tool.
|
|
13
|
-
* ファイル保存ツールの引数
|
|
14
|
-
*/
|
|
15
7
|
export interface SaveContentArgs {
|
|
16
8
|
content: string;
|
|
17
9
|
save_path?: string;
|
|
18
10
|
save_directory?: string;
|
|
19
11
|
filename?: string;
|
|
20
12
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Arguments for URL to Markdown file conversion tool.
|
|
23
|
-
* URL から Markdown ファイルへの変換ツールの引数
|
|
24
|
-
*/
|
|
25
13
|
export interface UrlToMarkdownFileArgs {
|
|
26
14
|
url?: string;
|
|
27
15
|
html_content?: string;
|
|
@@ -30,35 +18,11 @@ export interface UrlToMarkdownFileArgs {
|
|
|
30
18
|
save_directory?: string;
|
|
31
19
|
filename?: string;
|
|
32
20
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Validate and parse arguments for HTML to Markdown conversion.
|
|
35
|
-
* HTML から Markdown への変換の引数を検証・解析
|
|
36
|
-
*/
|
|
37
21
|
export declare function parseHtmlToMarkdownArgs(args: HtmlToMarkdownArgs | undefined): HtmlToMarkdownArgs;
|
|
38
|
-
/**
|
|
39
|
-
* Validate and parse arguments for content saving.
|
|
40
|
-
* コンテンツ保存の引数を検証・解析
|
|
41
|
-
*/
|
|
42
22
|
export declare function parseSaveContentArgs(args: SaveContentArgs | undefined): SaveContentArgs;
|
|
43
|
-
/**
|
|
44
|
-
* Validate and parse arguments for URL to Markdown file conversion.
|
|
45
|
-
* URL から Markdown ファイルへの変換の引数を検証・解析
|
|
46
|
-
*/
|
|
47
23
|
export declare function parseUrlToMarkdownFileArgs(args: UrlToMarkdownFileArgs | undefined): UrlToMarkdownFileArgs;
|
|
48
|
-
/**
|
|
49
|
-
* Generate filename from URL or use default.
|
|
50
|
-
* URL からファイル名を生成または既定値を使用
|
|
51
|
-
*/
|
|
52
24
|
export declare function generateFilename(url?: string): string;
|
|
53
|
-
/**
|
|
54
|
-
* Save content to file and return the saved path.
|
|
55
|
-
* コンテンツをファイルに保存し、保存したパスを返す
|
|
56
|
-
*/
|
|
57
25
|
export declare function saveContentToFile(content: string, savePath?: string, saveDirectory?: string, filename?: string): Promise<string>;
|
|
58
|
-
/**
|
|
59
|
-
* Tool schema definitions for MCP servers.
|
|
60
|
-
* MCP サーバー用のツールスキーマ定義
|
|
61
|
-
*/
|
|
62
26
|
export declare const MCP_TOOL_SCHEMAS: {
|
|
63
27
|
htmlToMarkdown: {
|
|
64
28
|
readonly type: "object";
|
|
@@ -74,15 +38,25 @@ export declare const MCP_TOOL_SCHEMAS: {
|
|
|
74
38
|
readonly locale: {
|
|
75
39
|
readonly type: "string";
|
|
76
40
|
readonly description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.";
|
|
77
|
-
readonly enum: readonly [
|
|
41
|
+
readonly enum: readonly [
|
|
42
|
+
"en-US",
|
|
43
|
+
"ja-JP"
|
|
44
|
+
];
|
|
78
45
|
readonly default: "en-US";
|
|
79
46
|
};
|
|
80
47
|
};
|
|
81
|
-
readonly anyOf: readonly [
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
48
|
+
readonly anyOf: readonly [
|
|
49
|
+
{
|
|
50
|
+
readonly required: readonly [
|
|
51
|
+
"url"
|
|
52
|
+
];
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
readonly required: readonly [
|
|
56
|
+
"html_content"
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
];
|
|
86
60
|
};
|
|
87
61
|
saveContentToFile: {
|
|
88
62
|
readonly type: "object";
|
|
@@ -104,12 +78,21 @@ export declare const MCP_TOOL_SCHEMAS: {
|
|
|
104
78
|
readonly description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically.";
|
|
105
79
|
};
|
|
106
80
|
};
|
|
107
|
-
readonly required: readonly [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
81
|
+
readonly required: readonly [
|
|
82
|
+
"content"
|
|
83
|
+
];
|
|
84
|
+
readonly anyOf: readonly [
|
|
85
|
+
{
|
|
86
|
+
readonly required: readonly [
|
|
87
|
+
"save_path"
|
|
88
|
+
];
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
readonly required: readonly [
|
|
92
|
+
"save_directory"
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
];
|
|
113
96
|
};
|
|
114
97
|
urlToMarkdownFile: {
|
|
115
98
|
readonly type: "object";
|
|
@@ -125,7 +108,10 @@ export declare const MCP_TOOL_SCHEMAS: {
|
|
|
125
108
|
readonly locale: {
|
|
126
109
|
readonly type: "string";
|
|
127
110
|
readonly description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.";
|
|
128
|
-
readonly enum: readonly [
|
|
111
|
+
readonly enum: readonly [
|
|
112
|
+
"en-US",
|
|
113
|
+
"ja-JP"
|
|
114
|
+
];
|
|
129
115
|
readonly default: "en-US";
|
|
130
116
|
};
|
|
131
117
|
readonly save_path: {
|
|
@@ -141,24 +127,33 @@ export declare const MCP_TOOL_SCHEMAS: {
|
|
|
141
127
|
readonly description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically.";
|
|
142
128
|
};
|
|
143
129
|
};
|
|
144
|
-
readonly anyOf: readonly [
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
130
|
+
readonly anyOf: readonly [
|
|
131
|
+
{
|
|
132
|
+
readonly required: readonly [
|
|
133
|
+
"url",
|
|
134
|
+
"save_path"
|
|
135
|
+
];
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
readonly required: readonly [
|
|
139
|
+
"url",
|
|
140
|
+
"save_directory"
|
|
141
|
+
];
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
readonly required: readonly [
|
|
145
|
+
"html_content",
|
|
146
|
+
"save_path"
|
|
147
|
+
];
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
readonly required: readonly [
|
|
151
|
+
"html_content",
|
|
152
|
+
"save_directory"
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
];
|
|
153
156
|
};
|
|
154
157
|
};
|
|
155
|
-
/**
|
|
156
|
-
* Common error handling utility for MCP tools.
|
|
157
|
-
* MCP ツール用の共通エラーハンドリングユーティリティ
|
|
158
|
-
*/
|
|
159
158
|
export declare function createErrorResult(error: unknown): CallToolResult;
|
|
160
|
-
/**
|
|
161
|
-
* Common success result utility for MCP tools.
|
|
162
|
-
* MCP ツール用の共通成功結果ユーティリティ
|
|
163
|
-
*/
|
|
164
159
|
export declare function createSuccessResult(text: string): CallToolResult;
|
|
@@ -1,89 +1,41 @@
|
|
|
1
|
-
import { Server } from
|
|
2
|
-
import { CallToolResult, Progress, Tool } from
|
|
3
|
-
import { HtmlToMarkdownArgs, SaveContentArgs, UrlToMarkdownFileArgs } from
|
|
4
|
-
/**
|
|
5
|
-
* The context for a tool call.
|
|
6
|
-
* ツール呼び出しのコンテキスト
|
|
7
|
-
*/
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { CallToolResult, Progress, Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { HtmlToMarkdownArgs, SaveContentArgs, UrlToMarkdownFileArgs } from "./mcp-common.ts";
|
|
8
4
|
export type ToolContext<T = unknown> = {
|
|
9
5
|
[toolName: string]: T;
|
|
10
6
|
};
|
|
11
7
|
export type StreamableProgress = Progress & {
|
|
12
8
|
type: "progress";
|
|
13
9
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Extended Tool interface with handler function.
|
|
16
|
-
* ハンドラー関数を含む拡張 Tool インターフェース
|
|
17
|
-
*/
|
|
18
10
|
interface ExtendedTool extends Tool {
|
|
19
11
|
handler: (args: HtmlToMarkdownArgs | SaveContentArgs | UrlToMarkdownFileArgs, context: ToolContext<HtmlToMarkdownArgs | SaveContentArgs | UrlToMarkdownFileArgs>) => AsyncGenerator<StreamableProgress | {
|
|
20
12
|
type: "result";
|
|
21
13
|
result: CallToolResult;
|
|
22
14
|
}>;
|
|
23
15
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Streamable MCP Server for HTML to Markdown conversion.
|
|
26
|
-
* HTML から Markdown への変換を行う streamable MCP サーバー
|
|
27
|
-
*/
|
|
28
16
|
export declare class StreamableHtmlToMarkdownMcpServer {
|
|
29
17
|
private server;
|
|
30
18
|
private transport;
|
|
31
19
|
readonly tools: ExtendedTool[];
|
|
32
20
|
private readonly version;
|
|
33
21
|
constructor();
|
|
34
|
-
/**
|
|
35
|
-
* Get the underlying MCP server instance.
|
|
36
|
-
* 内部の MCP サーバーインスタンスを取得します。
|
|
37
|
-
*/
|
|
38
22
|
getServer(): Server;
|
|
39
|
-
/**
|
|
40
|
-
* Setup request handlers for the streamable MCP server.
|
|
41
|
-
* streamable MCP サーバーのリクエストハンドラーを設定
|
|
42
|
-
*/
|
|
43
23
|
setupRequestHandlers(): void;
|
|
44
|
-
/**
|
|
45
|
-
* Handle HTML to Markdown conversion tool call with streamable support.
|
|
46
|
-
* streamable サポート付きの HTML から Markdown への変換ツール呼び出しを処理
|
|
47
|
-
*/
|
|
48
24
|
handleHtmlToMarkdown(args: HtmlToMarkdownArgs, _context: ToolContext<HtmlToMarkdownArgs>): AsyncGenerator<StreamableProgress | {
|
|
49
25
|
type: "result";
|
|
50
26
|
result: CallToolResult;
|
|
51
27
|
}>;
|
|
52
|
-
/**
|
|
53
|
-
* Handle save content to file tool call with streamable support.
|
|
54
|
-
* streamable サポート付きのファイル保存ツール呼び出しを処理
|
|
55
|
-
*/
|
|
56
28
|
handleSaveContentToFile(args: SaveContentArgs, _context: ToolContext<SaveContentArgs>): AsyncGenerator<StreamableProgress | {
|
|
57
29
|
type: "result";
|
|
58
30
|
result: CallToolResult;
|
|
59
31
|
}>;
|
|
60
|
-
/**
|
|
61
|
-
* Handle URL to Markdown file conversion tool call with streamable support.
|
|
62
|
-
* streamable サポート付きの URL から Markdown ファイルへの変換ツール呼び出しを処理
|
|
63
|
-
*/
|
|
64
32
|
handleUrlToMarkdownFile(args: UrlToMarkdownFileArgs, _context: ToolContext<UrlToMarkdownFileArgs>): AsyncGenerator<StreamableProgress | {
|
|
65
33
|
type: "result";
|
|
66
34
|
result: CallToolResult;
|
|
67
35
|
}>;
|
|
68
|
-
/**
|
|
69
|
-
* Generate filename from URL.
|
|
70
|
-
* URL からファイル名を生成
|
|
71
|
-
*/
|
|
72
36
|
private generateFilenameFromUrl;
|
|
73
|
-
/**
|
|
74
|
-
* Start the streamable MCP server.
|
|
75
|
-
* streamable MCP サーバーを開始
|
|
76
|
-
*/
|
|
77
37
|
start(host?: string, port?: number): Promise<void>;
|
|
78
38
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Create and start streamable MCP server instance.
|
|
81
|
-
* streamable MCP サーバーインスタンスを作成して開始
|
|
82
|
-
*/
|
|
83
39
|
export declare const createStreamableMcpServer: () => StreamableHtmlToMarkdownMcpServer;
|
|
84
|
-
/**
|
|
85
|
-
* Main function to run streamable MCP server.
|
|
86
|
-
* streamable MCP サーバーを実行するメイン関数
|
|
87
|
-
*/
|
|
88
40
|
export declare const runStreamableMcpServer: () => Promise<void>;
|
|
89
41
|
export {};
|
package/dist/src/mcp-server.d.ts
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import { Server } from
|
|
2
|
-
import { HtmlToMarkdownArgs, SaveContentArgs, UrlToMarkdownFileArgs } from
|
|
3
|
-
export { createErrorResult, createSuccessResult, type HtmlToMarkdownArgs, MCP_TOOL_SCHEMAS, parseHtmlToMarkdownArgs, parseSaveContentArgs, parseUrlToMarkdownFileArgs, type SaveContentArgs, saveContentToFile, type UrlToMarkdownFileArgs, } from
|
|
4
|
-
/**
|
|
5
|
-
* MCP Server for HTML to Markdown conversion.
|
|
6
|
-
* HTML から Markdown への変換を行う MCP サーバー
|
|
7
|
-
*/
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { HtmlToMarkdownArgs, SaveContentArgs, UrlToMarkdownFileArgs } 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";
|
|
8
4
|
export declare class HtmlToMarkdownMcpServer {
|
|
9
5
|
server: Server;
|
|
10
6
|
private readonly version;
|
|
11
7
|
constructor();
|
|
12
|
-
/**
|
|
13
|
-
* Setup tool handlers for the MCP server.
|
|
14
|
-
* MCP サーバーのツールハンドラーを設定
|
|
15
|
-
*/
|
|
16
8
|
setupToolHandlers(): void;
|
|
17
|
-
/**
|
|
18
|
-
* Handle HTML to Markdown conversion tool call.
|
|
19
|
-
* HTML から Markdown への変換ツール呼び出しを処理
|
|
20
|
-
*/
|
|
21
9
|
handleHtmlToMarkdown(args: HtmlToMarkdownArgs | undefined): Promise<{
|
|
22
10
|
[x: string]: unknown;
|
|
23
11
|
content: ({
|
|
@@ -115,10 +103,6 @@ export declare class HtmlToMarkdownMcpServer {
|
|
|
115
103
|
} | undefined;
|
|
116
104
|
isError?: boolean | undefined;
|
|
117
105
|
}>;
|
|
118
|
-
/**
|
|
119
|
-
* Handle save content to file tool call.
|
|
120
|
-
* ファイル保存ツール呼び出しを処理
|
|
121
|
-
*/
|
|
122
106
|
handleSaveContentToFile(args: SaveContentArgs | undefined): Promise<{
|
|
123
107
|
[x: string]: unknown;
|
|
124
108
|
content: ({
|
|
@@ -216,10 +200,6 @@ export declare class HtmlToMarkdownMcpServer {
|
|
|
216
200
|
} | undefined;
|
|
217
201
|
isError?: boolean | undefined;
|
|
218
202
|
}>;
|
|
219
|
-
/**
|
|
220
|
-
* Handle URL to Markdown file conversion tool call.
|
|
221
|
-
* URL から Markdown ファイルへの変換ツール呼び出しを処理
|
|
222
|
-
*/
|
|
223
203
|
handleUrlToMarkdownFile(args: UrlToMarkdownFileArgs | undefined): Promise<{
|
|
224
204
|
[x: string]: unknown;
|
|
225
205
|
content: ({
|
|
@@ -317,24 +297,8 @@ export declare class HtmlToMarkdownMcpServer {
|
|
|
317
297
|
} | undefined;
|
|
318
298
|
isError?: boolean | undefined;
|
|
319
299
|
}>;
|
|
320
|
-
/**
|
|
321
|
-
* Generate filename from URL.
|
|
322
|
-
* URL からファイル名を生成
|
|
323
|
-
*/
|
|
324
300
|
private generateFilenameFromUrl;
|
|
325
|
-
/**
|
|
326
|
-
* Start the MCP server.
|
|
327
|
-
* MCP サーバーを開始
|
|
328
|
-
*/
|
|
329
301
|
start(): Promise<void>;
|
|
330
302
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Create and start MCP server instance.
|
|
333
|
-
* MCP サーバーインスタンスを作成して開始
|
|
334
|
-
*/
|
|
335
303
|
export declare const createMcpServer: () => HtmlToMarkdownMcpServer;
|
|
336
|
-
/**
|
|
337
|
-
* Main function to run MCP server.
|
|
338
|
-
* MCP サーバーを実行するメイン関数
|
|
339
|
-
*/
|
|
340
304
|
export declare const runMcpServer: () => Promise<void>;
|
package/dist/src/mcp.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export { rehypeNamedAnchors } from './rehype-named-anchors.ts';
|
|
8
|
-
export { rehypeParagraphWrapper } from './rehype-paragraph-wrapper.ts';
|
|
9
|
-
export { rehypeSanitizeHtml } from './rehype-sanitize-html.ts';
|
|
10
|
-
export { rehypeWikipediaFootnotes } from './rehype-wikipedia-footnotes.ts';
|
|
1
|
+
export { rehypeAbsoluteLinks } from "./rehype-absolute-links.ts";
|
|
2
|
+
export { preprocessHtmlEntities, rehypeDecodeEntities } from "./rehype-decode-entities.ts";
|
|
3
|
+
export { rehypeNamedAnchors } from "./rehype-named-anchors.ts";
|
|
4
|
+
export { rehypeParagraphWrapper } from "./rehype-paragraph-wrapper.ts";
|
|
5
|
+
export { rehypeSanitizeHtml } from "./rehype-sanitize-html.ts";
|
|
6
|
+
export { rehypeWikipediaFootnotes } from "./rehype-wikipedia-footnotes.ts";
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { Root } from
|
|
2
|
-
/**
|
|
3
|
-
* A custom rehype plugin to make relative links absolute for various tags.
|
|
4
|
-
* @param options - The base URL to prepend to relative links.
|
|
5
|
-
* @returns A unified transformer function.
|
|
6
|
-
*/
|
|
1
|
+
import { Root } from "hast";
|
|
7
2
|
export declare const rehypeAbsoluteLinks: (options: {
|
|
8
3
|
baseUrl: string;
|
|
9
4
|
}) => (tree: Root) => void;
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import { Root } from
|
|
2
|
-
/**
|
|
3
|
-
* Decode HTML entities in text nodes and element properties.
|
|
4
|
-
* テキストノードと要素プロパティ内の HTML エンティティをデコードします。
|
|
5
|
-
*/
|
|
1
|
+
import { Root } from "hast";
|
|
6
2
|
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
3
|
export declare const preprocessHtmlEntities: (html: string) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Root } from
|
|
1
|
+
import { Root } from "hast";
|
|
2
2
|
export declare const rehypeNamedAnchors: () => (tree: Root) => void;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Root } from
|
|
2
|
-
/**
|
|
3
|
-
* A rehype plugin to wrap an element and its adjacent anchor span with a paragraph.
|
|
4
|
-
* 要素とそれに隣接するアンカースパンを段落でラップする rehype プラグイン。
|
|
5
|
-
*/
|
|
1
|
+
import { Root } from "hast";
|
|
6
2
|
export declare const rehypeParagraphWrapper: () => (tree: Root) => void;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import { Root } from
|
|
2
|
-
/**
|
|
3
|
-
* A custom rehype plugin to remove empty comments and clean up whitespace.
|
|
4
|
-
* - 空のコメントノードを削除します (`<!-- -->`)
|
|
5
|
-
* - 隣接するテキストノードを結合し、連続する空白を単一のスペースに正規化します。
|
|
6
|
-
*/
|
|
1
|
+
import { Root } from "hast";
|
|
7
2
|
export declare const rehypeSanitizeHtml: () => (tree: Root) => void;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { Element } from
|
|
2
|
-
/**
|
|
3
|
-
* A custom rehype plugin to transform Wikipedia-style footnotes into standard Markdown footnotes.
|
|
4
|
-
* @returns A unified transformer function.
|
|
5
|
-
*/
|
|
1
|
+
import { Element } from "hast";
|
|
6
2
|
export declare const rehypeWikipediaFootnotes: () => (tree: Element) => void;
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module utils/logger
|
|
3
|
-
* @description Logger utility for consistent log management across the library.
|
|
4
|
-
* @description ライブラリ全体で一貫したログ管理を行うためのロガーユーティリティ。
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @enum LogLevel
|
|
8
|
-
* @description Log levels for filtering output.
|
|
9
|
-
* @description 出力をフィルタリングするためのログレベル。
|
|
10
|
-
*/
|
|
11
1
|
export declare enum LogLevel {
|
|
12
2
|
DEBUG = 0,
|
|
13
3
|
INFO = 1,
|
|
@@ -15,75 +5,23 @@ export declare enum LogLevel {
|
|
|
15
5
|
ERROR = 3,
|
|
16
6
|
NONE = 4
|
|
17
7
|
}
|
|
18
|
-
/**
|
|
19
|
-
* @interface ILogger
|
|
20
|
-
* @description Interface for a logger object compatible with Console.
|
|
21
|
-
* @description Console と互換性のあるロガーオブジェクトのインターフェース。
|
|
22
|
-
*/
|
|
23
8
|
export interface ILogger {
|
|
24
9
|
debug(message?: unknown, ...optionalParams: unknown[]): void;
|
|
25
10
|
info(message?: unknown, ...optionalParams: unknown[]): void;
|
|
26
11
|
warn(message?: unknown, ...optionalParams: unknown[]): void;
|
|
27
12
|
error(message?: unknown, ...optionalParams: unknown[]): void;
|
|
28
13
|
}
|
|
29
|
-
/**
|
|
30
|
-
* @class Logger
|
|
31
|
-
* @description A wrapper class for handling logging with levels and prefixes.
|
|
32
|
-
* @description レベルとプレフィックスを使用したログ記録を処理するためのラッパークラス。
|
|
33
|
-
*/
|
|
34
14
|
export declare class Logger implements ILogger {
|
|
35
15
|
private level;
|
|
36
16
|
private prefix;
|
|
37
17
|
private impl;
|
|
38
|
-
/**
|
|
39
|
-
* @constructor
|
|
40
|
-
* @param {LogLevel} [level=LogLevel.WARN] - The minimum log level to output.
|
|
41
|
-
* @param {string} [prefix="[html-to-markdown]"] - The prefix to add to all log messages.
|
|
42
|
-
* @param {ILogger} [impl=console] - The implementation to use for logging.
|
|
43
|
-
*/
|
|
44
18
|
constructor(level?: LogLevel, prefix?: string, impl?: ILogger);
|
|
45
19
|
private static instance;
|
|
46
|
-
/**
|
|
47
|
-
* @method setLevel
|
|
48
|
-
* @description Updates the current log level for the static instance.
|
|
49
|
-
* @description 静的インスタンスの現在のログレベルを更新します。
|
|
50
|
-
* @param {LogLevel} level - The new log level.
|
|
51
|
-
*/
|
|
52
20
|
static setLevel(level: LogLevel): void;
|
|
53
|
-
/**
|
|
54
|
-
* @method setLevel
|
|
55
|
-
* @description Updates the current log level.
|
|
56
|
-
* @description 現在のログレベルを更新します。
|
|
57
|
-
* @param {LogLevel} level - The new log level.
|
|
58
|
-
*/
|
|
59
21
|
setLevel(level: LogLevel): void;
|
|
60
|
-
/**
|
|
61
|
-
* @method setImplementation
|
|
62
|
-
* @description Updates the logger implementation for the static instance.
|
|
63
|
-
* @description 静的インスタンスのロガーの実装を更新します。
|
|
64
|
-
* @param {ILogger} impl - The new logger implementation.
|
|
65
|
-
*/
|
|
66
22
|
static setImplementation(impl: ILogger): void;
|
|
67
|
-
/**
|
|
68
|
-
* @method setImplementation
|
|
69
|
-
* @description Updates the logger implementation.
|
|
70
|
-
* @description ロガーの実装を更新します。
|
|
71
|
-
* @param {ILogger} impl - The new logger implementation.
|
|
72
|
-
*/
|
|
73
23
|
setImplementation(impl: ILogger): void;
|
|
74
|
-
/**
|
|
75
|
-
* @method setPrefix
|
|
76
|
-
* @description Updates the log prefix for the static instance.
|
|
77
|
-
* @description 静的インスタンスのログのプレフィックスを更新します。
|
|
78
|
-
* @param {string} prefix - The new prefix.
|
|
79
|
-
*/
|
|
80
24
|
static setPrefix(prefix: string): void;
|
|
81
|
-
/**
|
|
82
|
-
* @method setPrefix
|
|
83
|
-
* @description Updates the log prefix.
|
|
84
|
-
* @description ログのプレフィックスを更新します。
|
|
85
|
-
* @param {string} prefix - The new prefix.
|
|
86
|
-
*/
|
|
87
25
|
setPrefix(prefix: string): void;
|
|
88
26
|
private formatMessage;
|
|
89
27
|
static debug(message?: unknown, ...optionalParams: unknown[]): void;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,41 +1,11 @@
|
|
|
1
|
-
import { Element, Nodes, Parents } from
|
|
2
|
-
import { BlockContent as MdastBlockContent, DefinitionContent as MdastDefinitionContent, Nodes as MdastNodes, Parents as MdastParents, RootContent as MdastRootContent } from
|
|
3
|
-
/**
|
|
4
|
-
* Type definitions for htmlToMarkdown module.
|
|
5
|
-
* htmlToMarkdown モジュールの型定義
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Options for the htmlToMarkdown function.
|
|
9
|
-
* htmlToMarkdown 関数のオプション
|
|
10
|
-
*/
|
|
1
|
+
import { Element, Nodes, Parents } from "hast";
|
|
2
|
+
import { BlockContent as MdastBlockContent, DefinitionContent as MdastDefinitionContent, Nodes as MdastNodes, Parents as MdastParents, RootContent as MdastRootContent } from "mdast";
|
|
11
3
|
export interface HtmlToMarkdownOptions {
|
|
12
|
-
/**
|
|
13
|
-
* The locale to use for the browser context. Defaults to 'en-US'.
|
|
14
|
-
* ブラウザコンテキストで使用するロケール。デフォルトは 'en-US' です。
|
|
15
|
-
*/
|
|
16
4
|
locale?: string;
|
|
17
|
-
/**
|
|
18
|
-
* HTML content as a string instead of fetching from URL.
|
|
19
|
-
* URL から取得する代わりに HTML コンテンツを文字列として直接指定します。
|
|
20
|
-
*/
|
|
21
5
|
htmlContent?: string;
|
|
22
6
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Supported locales.
|
|
25
|
-
* サポートされているロケール
|
|
26
|
-
*/
|
|
27
7
|
export type SupportedLocale = "en-US" | "ja-JP";
|
|
28
|
-
/**
|
|
29
|
-
* Message keys for i18n.
|
|
30
|
-
* i18n 用のメッセージキー
|
|
31
|
-
*/
|
|
32
8
|
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
|
-
/**
|
|
34
|
-
* The following types are based on the type definitions of `hast-util-to-mdast`.
|
|
35
|
-
* `hast-util-to-mdast` の型定義に基づいた型。
|
|
36
|
-
*
|
|
37
|
-
* @see https://github.com/syntax-tree/hast-util-to-mdast/blob/main/lib/state.js
|
|
38
|
-
*/
|
|
39
9
|
export type State = {
|
|
40
10
|
all: All;
|
|
41
11
|
baseFound: boolean;
|
package/dist/src/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/html-to-markdown",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "HTML to Markdown converter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
|
-
"postinstall": "node -e \"if(process.env.SKIP_PLAYWRIGHT_INSTALL!=='1'){require('child_process').execSync('npx playwright install --with-deps chromium',{stdio:'inherit'})}\"",
|
|
83
|
+
"postinstall": "node -e \"if(process.env.SKIP_PLAYWRIGHT_INSTALL!=='1'){const env={...(process.platform==='linux'?{PLAYWRIGHT_HOST_PLATFORM_OVERRIDE:'ubuntu24.04-x64'}:{}),...process.env};require('child_process').execSync('npx playwright install --with-deps chromium',{stdio:'inherit',env})}\"",
|
|
84
84
|
"dev": "NODE_OPTIONS='--enable-source-maps' vite-node --inspect=9229 --watch src/mcp-streamable.ts --",
|
|
85
85
|
"watch": "vite build --watch",
|
|
86
86
|
"debug": "NODE_OPTIONS='--enable-source-maps' vite-node --inspect-brk=9229 main.ts --",
|
|
87
87
|
"start": "vite-node main.ts",
|
|
88
|
-
"build": "vite build",
|
|
88
|
+
"build": "vite build && node ../../.config/scripts/strip-dts-comments.mjs dist",
|
|
89
89
|
"typecheck": "tsc --noEmit",
|
|
90
90
|
"clean": "rimraf dist",
|
|
91
|
-
"publish:patch": "
|
|
92
|
-
"publish:minor": "
|
|
93
|
-
"publish:major": "
|
|
91
|
+
"publish:patch": "pnpm run typecheck && pnpm run --if-present test && pnpm version patch --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
|
|
92
|
+
"publish:minor": "pnpm run typecheck && pnpm run --if-present test && pnpm version minor --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
|
|
93
|
+
"publish:major": "pnpm run typecheck && pnpm run --if-present test && pnpm version major --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
|
|
94
94
|
"lint": "biome lint app/",
|
|
95
95
|
"format": "biome format --write",
|
|
96
96
|
"check": "biome check --fix src/",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/vite.config.d.ts
DELETED
package/dist/vitest.config.d.ts
DELETED