@xberg-io/opencode-html-to-markdown 3.10.4 → 3.11.2

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