@xberg-io/opencode-html-to-markdown 0.2.3 → 3.10.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.
- package/.opencode/plugins/html-to-markdown.js +75 -70
- package/README.md +4 -5
- package/package.json +2 -2
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
// AI-RULEZ :: GENERATED FILE — DO NOT EDIT
|
|
2
|
-
// Content-Hash: blake3:
|
|
3
|
-
// Source-Hash: blake3:
|
|
2
|
+
// Content-Hash: blake3:a6fa2bc34f3c3e8e95bd74acc79163d573b3c7d544c54ad82b5ca81e21f0f39c
|
|
3
|
+
// Source-Hash: blake3:52a9e795318c65309bedf23c4148a244ae457abb074800a546ad13641285c9c3
|
|
4
4
|
// Schema-Version: v1
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import {tool} from "@opencode-ai/plugin";
|
|
7
|
+
import {spawn} from "node:child_process";
|
|
8
8
|
|
|
9
9
|
const schema = tool.schema;
|
|
10
10
|
|
|
11
|
-
const headingStyle = schema
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.describe("Markdown heading style. Default: atx.");
|
|
11
|
+
const headingStyle = schema.enum([ "atx", "underlined", "atx-closed" ])
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Markdown heading style. Default: atx.");
|
|
15
14
|
|
|
16
|
-
const codeBlockStyle =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const codeBlockStyle =
|
|
16
|
+
schema.enum([ "backticks", "indented", "tildes" ])
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Code block fence style. Default: backticks.");
|
|
20
19
|
|
|
21
|
-
const outputFormat = schema.enum(["markdown", "djot"])
|
|
20
|
+
const outputFormat = schema.enum([ "markdown", "djot" ])
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Output markup format. Default: markdown.");
|
|
22
23
|
|
|
23
|
-
const preset =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const preset =
|
|
25
|
+
schema.enum([ "minimal", "standard", "aggressive" ])
|
|
26
|
+
.optional()
|
|
27
|
+
.describe(
|
|
28
|
+
"Preprocessing aggressiveness. Requires `preprocess`. Default: standard.");
|
|
27
29
|
|
|
28
30
|
function hasValue(value) {
|
|
29
31
|
return value !== undefined && value !== null && value !== "";
|
|
@@ -46,10 +48,10 @@ function runCli(args, context, stdin) {
|
|
|
46
48
|
|
|
47
49
|
return new Promise((resolve, reject) => {
|
|
48
50
|
const child = spawn("html-to-markdown", args, {
|
|
49
|
-
cwd: directory,
|
|
50
|
-
env: process.env,
|
|
51
|
-
signal: context?.abort,
|
|
52
|
-
stdio: [stdin === undefined ? "ignore" : "pipe", "pipe", "pipe"],
|
|
51
|
+
cwd : directory,
|
|
52
|
+
env : process.env,
|
|
53
|
+
signal : context?.abort,
|
|
54
|
+
stdio : [ stdin === undefined ? "ignore" : "pipe", "pipe", "pipe" ],
|
|
53
55
|
});
|
|
54
56
|
|
|
55
57
|
const stdout = [];
|
|
@@ -60,10 +62,10 @@ function runCli(args, context, stdin) {
|
|
|
60
62
|
child.on("error", (error) => {
|
|
61
63
|
if (error.code === "ENOENT") {
|
|
62
64
|
resolve({
|
|
63
|
-
title: "html-to-markdown CLI not found",
|
|
64
|
-
output:
|
|
65
|
-
|
|
66
|
-
metadata: {
|
|
65
|
+
title : "html-to-markdown CLI not found",
|
|
66
|
+
output :
|
|
67
|
+
"Install the html-to-markdown CLI with `brew install xberg-io/tap/html-to-markdown`, or run it via `npx -y @xberg-io/html-to-markdown-cli` / `uvx --from html-to-markdown-cli html-to-markdown`.",
|
|
68
|
+
metadata : {exitCode : 127, command : "html-to-markdown"},
|
|
67
69
|
});
|
|
68
70
|
return;
|
|
69
71
|
}
|
|
@@ -72,12 +74,14 @@ function runCli(args, context, stdin) {
|
|
|
72
74
|
child.on("close", (exitCode, signal) => {
|
|
73
75
|
const stdoutText = Buffer.concat(stdout).toString("utf8").trim();
|
|
74
76
|
const stderrText = Buffer.concat(stderr).toString("utf8").trim();
|
|
75
|
-
const output = [
|
|
77
|
+
const output = [
|
|
78
|
+
stdoutText, stderrText && `stderr:\n${stderrText}`
|
|
79
|
+
].filter(Boolean).join("\n\n");
|
|
76
80
|
|
|
77
81
|
resolve({
|
|
78
|
-
title: exitCode === 0 ? "html-to-markdown" : "html-to-markdown failed",
|
|
79
|
-
output: output || "(no output)",
|
|
80
|
-
metadata: {
|
|
82
|
+
title : exitCode === 0 ? "html-to-markdown" : "html-to-markdown failed",
|
|
83
|
+
output : output || "(no output)",
|
|
84
|
+
metadata : {exitCode, signal, command : "html-to-markdown"},
|
|
81
85
|
});
|
|
82
86
|
});
|
|
83
87
|
|
|
@@ -97,17 +101,20 @@ function styleArgs(args, params) {
|
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
export const HtmlToMarkdownPlugin = async () => ({
|
|
100
|
-
tool: {
|
|
101
|
-
html_to_markdown_convert: tool({
|
|
102
|
-
description:
|
|
103
|
-
|
|
104
|
-
args: {
|
|
105
|
-
path: schema.string().min(1).optional().describe(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
tool : {
|
|
105
|
+
html_to_markdown_convert : tool({
|
|
106
|
+
description :
|
|
107
|
+
"Convert an HTML file or HTML string to Markdown (or Djot) with the html-to-markdown CLI. Provide either `path` or `html`.",
|
|
108
|
+
args : {
|
|
109
|
+
path : schema.string().min(1).optional().describe(
|
|
110
|
+
"Path to a local HTML file."),
|
|
111
|
+
html : schema.string().min(1).optional().describe(
|
|
112
|
+
"Inline HTML to convert (used when `path` is omitted)."),
|
|
113
|
+
heading_style : headingStyle,
|
|
114
|
+
code_block_style : codeBlockStyle,
|
|
115
|
+
output_format : outputFormat,
|
|
116
|
+
preprocess : schema.boolean().optional().describe(
|
|
117
|
+
"Strip navigation, ads, and forms before converting."),
|
|
111
118
|
preset,
|
|
112
119
|
},
|
|
113
120
|
async execute(args, context) {
|
|
@@ -124,46 +131,44 @@ export const HtmlToMarkdownPlugin = async () => ({
|
|
|
124
131
|
throw new Error("Provide either `path` or `html`.");
|
|
125
132
|
},
|
|
126
133
|
}),
|
|
127
|
-
html_to_markdown_fetch_url: tool({
|
|
128
|
-
description:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
html_to_markdown_fetch_url : tool({
|
|
135
|
+
description :
|
|
136
|
+
"Fetch a URL and convert its HTML to Markdown (or Djot) with the html-to-markdown CLI.",
|
|
137
|
+
args : {
|
|
138
|
+
url : schema.string().min(1).describe("URL to fetch and convert."),
|
|
139
|
+
heading_style : headingStyle,
|
|
140
|
+
code_block_style : codeBlockStyle,
|
|
141
|
+
output_format : outputFormat,
|
|
142
|
+
preprocess : schema.boolean().optional().describe(
|
|
143
|
+
"Strip navigation, ads, and forms before converting."),
|
|
135
144
|
preset,
|
|
136
|
-
user_agent: schema.string().min(1).optional().describe(
|
|
145
|
+
user_agent : schema.string().min(1).optional().describe(
|
|
146
|
+
"Custom User-Agent header for the fetch."),
|
|
137
147
|
},
|
|
138
148
|
async execute(args, context) {
|
|
139
|
-
const cliArgs = ["--url", args.url];
|
|
149
|
+
const cliArgs = [ "--url", args.url ];
|
|
140
150
|
pushOption(cliArgs, "--user-agent", args.user_agent);
|
|
141
151
|
styleArgs(cliArgs, args);
|
|
142
152
|
return runCli(cliArgs, context);
|
|
143
153
|
},
|
|
144
154
|
}),
|
|
145
|
-
html_to_markdown_extract: tool({
|
|
146
|
-
description:
|
|
147
|
-
|
|
148
|
-
args: {
|
|
149
|
-
path: schema.string().min(1).optional().describe(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
.describe("Include the document structure tree in the JSON output."),
|
|
160
|
-
no_content: schema
|
|
161
|
-
.boolean()
|
|
162
|
-
.optional()
|
|
163
|
-
.describe("Suppress the Markdown content field — return metadata/tables/images only."),
|
|
155
|
+
html_to_markdown_extract : tool({
|
|
156
|
+
description :
|
|
157
|
+
"Extract structured metadata, tables, and (optionally) document structure from HTML as JSON. Returns the full ConversionResult. Provide `path`, `html`, or `url`.",
|
|
158
|
+
args : {
|
|
159
|
+
path : schema.string().min(1).optional().describe(
|
|
160
|
+
"Path to a local HTML file."),
|
|
161
|
+
html : schema.string().min(1).optional().describe(
|
|
162
|
+
"Inline HTML to analyze (used when `path` and `url` are omitted)."),
|
|
163
|
+
url : schema.string().min(1).optional().describe(
|
|
164
|
+
"URL to fetch and analyze."),
|
|
165
|
+
include_structure : schema.boolean().optional().describe(
|
|
166
|
+
"Include the document structure tree in the JSON output."),
|
|
167
|
+
no_content : schema.boolean().optional().describe(
|
|
168
|
+
"Suppress the Markdown content field — return metadata/tables/images only."),
|
|
164
169
|
},
|
|
165
170
|
async execute(args, context) {
|
|
166
|
-
const cliArgs = ["--json"];
|
|
171
|
+
const cliArgs = [ "--json" ];
|
|
167
172
|
pushFlag(cliArgs, "--include-structure", args.include_structure);
|
|
168
173
|
pushFlag(cliArgs, "--no-content", args.no_content);
|
|
169
174
|
|
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ Pending review for official Claude marketplace.
|
|
|
13
13
|
Self-host:
|
|
14
14
|
|
|
15
15
|
```text
|
|
16
|
-
/plugin marketplace add xberg-io/
|
|
17
|
-
/plugin install html-to-markdown@
|
|
16
|
+
/plugin marketplace add xberg-io/html-to-markdown
|
|
17
|
+
/plugin install html-to-markdown@html-to-markdown
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
### Binary requirement
|
|
@@ -162,7 +162,7 @@ html-to-markdown input.html --output-format djot --heading-style underlined
|
|
|
162
162
|
|
|
163
163
|
## Versioning
|
|
164
164
|
|
|
165
|
-
The plugin version tracks the
|
|
165
|
+
The plugin version tracks the html-to-markdown core release (`Cargo.toml`). See [CHANGELOG.md](../CHANGELOG.md) for release notes.
|
|
166
166
|
|
|
167
167
|
## License
|
|
168
168
|
|
|
@@ -170,6 +170,5 @@ MIT. The skill content references the upstream [html-to-markdown](https://github
|
|
|
170
170
|
|
|
171
171
|
## See also
|
|
172
172
|
|
|
173
|
-
- **Marketplace**:
|
|
173
|
+
- **Marketplace**: this repo — `/plugin marketplace add xberg-io/html-to-markdown`
|
|
174
174
|
- **Upstream**: [xberg-io/html-to-markdown](https://github.com/xberg-io/html-to-markdown)
|
|
175
|
-
- **Sibling plugins**: [xberg](../xberg/README.md), [crawlberg](../crawlberg/README.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xberg-io/opencode-html-to-markdown",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.10.1",
|
|
4
4
|
"description": "Fast, lossless HTML→Markdown conversion with structured metadata, tables, and document-structure extraction.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"html-to-markdown",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"homepage": "https://xberg.io",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/xberg-io/
|
|
15
|
+
"url": "https://github.com/xberg-io/html-to-markdown"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"type": "module",
|