html-to-markdown-hermes-plugin 3.10.0__py3-none-any.whl

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.
@@ -0,0 +1,12 @@
1
+ # AI-RULEZ :: GENERATED FILE — DO NOT EDIT
2
+ # Content-Hash: blake3:ad14c165535bf034edc8842cb3a3fbe47dfa5eaa449857fb1081e0a16e49a57f
3
+ # Source-Hash: blake3:1479d0c7507cad8660b86e38c91535d1f1e62aae4e74cf75f1d7ad237f287e1b
4
+ # Schema-Version: v1
5
+
6
+ """Hermes Agent plugin package."""
7
+
8
+ from . import hermes
9
+ from .hermes import register
10
+
11
+ __version__ = "3.10.0"
12
+ __all__ = ["hermes", "register"]
@@ -0,0 +1,22 @@
1
+ # AI-RULEZ :: GENERATED FILE — DO NOT EDIT
2
+ # Content-Hash: blake3:37afa818c3d0b98819c2cbb5a6b3bc7aecb66c6e37a8a1ffa2c410efee24b057
3
+ # Source-Hash: blake3:1479d0c7507cad8660b86e38c91535d1f1e62aae4e74cf75f1d7ad237f287e1b
4
+ # Schema-Version: v1
5
+
6
+ """Hermes adapter for html-to-markdown.
7
+
8
+ This generated no-op keeps the plugin loadable without inventing runtime behavior.
9
+ To add Hermes tools, hooks, commands, or other registrations:
10
+
11
+ 1. Create .ai-rulez/hermes/index.py.
12
+ 2. Implement register(ctx) in that user-owned source file.
13
+ 3. Run ai-rulez generate --plugin.
14
+
15
+ Project-local Hermes plugins are trusted code. Enable them explicitly with
16
+ HERMES_ENABLE_PROJECT_PLUGINS=true and validate all external input.
17
+ """
18
+
19
+
20
+ def register(ctx):
21
+ """Register this plugin with Hermes Agent."""
22
+ del ctx
@@ -0,0 +1,5 @@
1
+ name: "html-to-markdown"
2
+ version: "3.10.0"
3
+ description: "Fast, lossless HTML→Markdown conversion with structured metadata, tables, and document-structure extraction."
4
+ author: "Kreuzberg, Inc."
5
+ kind: "standalone"
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: converting-html
3
+ description: Use when converting HTML to Markdown, Djot, or plain text. Covers output formats, heading and code-block styles, lists, escaping, wrapping, and HTML preprocessing.
4
+ ---
5
+
6
+ <!--
7
+ AI-RULEZ :: GENERATED FILE — DO NOT EDIT
8
+ Content-Hash: blake3:f1b6e5eedc9f268752e34b2c9ad6ecab9ae40c23a8373b1a97838f95a96945d1
9
+ Source-Hash: blake3:1479d0c7507cad8660b86e38c91535d1f1e62aae4e74cf75f1d7ad237f287e1b
10
+ Schema-Version: v1
11
+ -->
12
+
13
+ # Converting HTML
14
+
15
+ Use this when the user wants to turn HTML into clean Markdown (or Djot) — a
16
+ saved page, an HTML email body, a fragment, or a string. Conversion is driven by
17
+ **flags** with a positional `FILE` (stdin is the default input when no file is
18
+ given); the only subcommand is `mcp` (run-as-server, see the
19
+ `using-the-mcp-server` skill).
20
+
21
+ ## Basic conversion
22
+
23
+ ```bash
24
+ # File to stdout
25
+ html-to-markdown input.html
26
+
27
+ # File to a file
28
+ html-to-markdown input.html -o output.md
29
+
30
+ # From stdin
31
+ cat page.html | html-to-markdown
32
+ echo '<h1>Title</h1><p>Body</p>' | html-to-markdown
33
+ ```
34
+
35
+ The default (no `--json`) prints plain Markdown text. Use `--json` only when you
36
+ need structured metadata/tables (see the `extracting-metadata` and
37
+ `extracting-tables` skills).
38
+
39
+ ## Output format
40
+
41
+ ```bash
42
+ html-to-markdown input.html --output-format markdown # default
43
+ html-to-markdown input.html --output-format djot # Djot markup
44
+ html-to-markdown input.html -f djot # short form
45
+ ```
46
+
47
+ To get *plain text* (no Markdown syntax), strip tags and treat blocks inline:
48
+
49
+ ```bash
50
+ html-to-markdown input.html --convert-as-inline --strip-tags "script,style"
51
+ ```
52
+
53
+ ## Heading and code-block styles
54
+
55
+ | Flag | Values | Default | Effect |
56
+ | ---- | ------ | ------- | ------ |
57
+ | `--heading-style` | `atx`, `underlined`, `atx-closed` | `atx` | `# h1` vs `h1\n===` vs `# h1 #` |
58
+ | `--code-block-style` | `backticks`, `indented`, `tildes` | `backticks` | Fence style for code blocks |
59
+ | `--code-language` / `-l` | string | `""` | Default language for fenced blocks |
60
+
61
+ ```bash
62
+ html-to-markdown input.html --heading-style underlined --code-block-style tildes
63
+ ```
64
+
65
+ ## Lists and text formatting
66
+
67
+ ```bash
68
+ # Bullet characters cycle by nesting depth; indent width 1–8
69
+ html-to-markdown input.html --bullets '*+-' --list-indent-width 2
70
+
71
+ # Indent with tabs instead of spaces
72
+ html-to-markdown input.html --list-indent-type tabs
73
+
74
+ # Emphasis symbol and escaping
75
+ html-to-markdown input.html --strong-em-symbol _ --escape-misc
76
+ ```
77
+
78
+ Escaping flags (`--escape-asterisks`, `--escape-underscores`, `--escape-misc`,
79
+ `--escape-ascii`) trade readability for strict CommonMark safety. Use
80
+ `--escape-ascii` only when the output must round-trip through a strict parser.
81
+
82
+ ## Wrapping
83
+
84
+ ```bash
85
+ html-to-markdown input.html --wrap --wrap-width 100 # off by default; 80 if --wrap with no width
86
+ ```
87
+
88
+ ## Preprocessing (clean noisy pages)
89
+
90
+ Strip navigation, ads, and forms before converting — essential for scraped web
91
+ pages:
92
+
93
+ ```bash
94
+ html-to-markdown input.html --preprocess # standard preset
95
+ html-to-markdown input.html --preprocess --preset aggressive # strip more
96
+ html-to-markdown input.html --preprocess --keep-navigation # keep <nav>
97
+ html-to-markdown input.html --preprocess --keep-forms # keep <form>
98
+ ```
99
+
100
+ Presets: `minimal`, `standard` (default), `aggressive`. `--preset`,
101
+ `--keep-navigation`, and `--keep-forms` all require `--preprocess`.
102
+
103
+ ## Programmatic equivalents
104
+
105
+ ```python
106
+ from html_to_markdown import convert, ConversionOptions, PreprocessingOptions
107
+
108
+ result = convert(
109
+ html,
110
+ ConversionOptions(
111
+ heading_style="atx",
112
+ code_block_style="backticks",
113
+ wrap=True,
114
+ wrap_width=100,
115
+ preprocessing=PreprocessingOptions(enabled=True, preset="aggressive"),
116
+ ),
117
+ )
118
+ print(result.content)
119
+ ```
120
+
121
+ ```rust
122
+ use html_to_markdown_rs::{convert, ConversionOptions, HeadingStyle};
123
+
124
+ let options = ConversionOptions::builder().heading_style(HeadingStyle::Atx).wrap(true).build();
125
+ let result = convert(html, Some(options))?;
126
+ ```
127
+
128
+ See `../html-to-markdown/references/cli-reference.md` for the full flag set and
129
+ `../html-to-markdown/references/configuration.md` for every option default.
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: extracting-metadata
3
+ description: Use when extracting metadata from HTML — title, description, language, Open Graph, JSON-LD / Microdata / RDFa, headers, links, and images. Covers the --json output shape and the --extract-metadata flag.
4
+ ---
5
+
6
+ <!--
7
+ AI-RULEZ :: GENERATED FILE — DO NOT EDIT
8
+ Content-Hash: blake3:92b8609da6942758954515f37da247e2b944e4fa7b5c88f878cfbc58ae3e94cc
9
+ Source-Hash: blake3:1479d0c7507cad8660b86e38c91535d1f1e62aae4e74cf75f1d7ad237f287e1b
10
+ Schema-Version: v1
11
+ -->
12
+
13
+ # Extracting metadata
14
+
15
+ Use this when the user wants structured metadata out of HTML rather than (or in
16
+ addition to) the Markdown body — page title, description, language, Open Graph
17
+ tags, structured data, the heading outline, links, or image references.
18
+
19
+ Metadata lives in `result.metadata` and is surfaced on the CLI through
20
+ `--json`. On the CLI, metadata extraction is **opt-in**: pass
21
+ `--extract-metadata` alongside `--json`, otherwise `result.metadata` comes back
22
+ empty (`document.title` is null, `headers`/`links`/`images`/`structured_data`
23
+ are `[]`). The library `convert()` call extracts metadata by default
24
+ (`extract_metadata=True`) — that default is a property of the API, not the CLI.
25
+ There are no per-field extraction flags: `--extract-metadata` populates all
26
+ sub-fields below at once.
27
+
28
+ ## Get all metadata
29
+
30
+ ```bash
31
+ html-to-markdown --json --extract-metadata input.html | jq '.metadata'
32
+
33
+ # Extraction-only (skip the Markdown body)
34
+ html-to-markdown --json --extract-metadata --no-content input.html | jq '.metadata'
35
+ ```
36
+
37
+ ## Metadata sub-fields
38
+
39
+ ```json
40
+ {
41
+ "metadata": {
42
+ "document": { "title": "...", "description": "...", "language": "en", "open_graph": {"title": "..."} },
43
+ "headers": [ { "level": 1, "text": "Main Heading" } ],
44
+ "links": [ { "href": "https://example.com", "link_type": "external" } ],
45
+ "images": [ { "src": "photo.jpg", "alt": "A photo", "image_type": "external" } ],
46
+ "structured_data": [ /* JSON-LD, Microdata, RDFa blocks */ ]
47
+ }
48
+ }
49
+ ```
50
+
51
+ ## Metadata flag
52
+
53
+ There is one metadata flag: `--extract-metadata`. With `--json` set it populates
54
+ all sub-fields above (`document`, `headers`, `links`, `images`,
55
+ `structured_data`) under `result.metadata` — select what you need with `jq`.
56
+
57
+ | Flag | Effect |
58
+ | ---- | ------ |
59
+ | `--extract-metadata` | With `--json`: populate `result.metadata`. In plain-text mode (no `--json`): prepend title + meta tags as a YAML frontmatter block (`---`-delimited) at the top of the Markdown output |
60
+
61
+ ```bash
62
+ # Pull just the document-level metadata and the heading outline
63
+ html-to-markdown --json --extract-metadata --no-content input.html \
64
+ | jq '{title: .metadata.document.title, lang: .metadata.document.language, outline: [.metadata.headers[].text]}'
65
+ ```
66
+
67
+ ## Common queries
68
+
69
+ ```bash
70
+ # Title + canonical language
71
+ html-to-markdown --json --extract-metadata input.html | jq '{title: .metadata.document.title, lang: .metadata.document.language}'
72
+
73
+ # External links only
74
+ html-to-markdown --json --extract-metadata input.html | jq '[.metadata.links[] | select(.link_type == "external") | .href]'
75
+
76
+ # Open Graph card
77
+ html-to-markdown --json --extract-metadata input.html | jq '.metadata.document.open_graph'
78
+
79
+ # JSON-LD blocks
80
+ html-to-markdown --json --extract-metadata input.html | jq '.metadata.structured_data'
81
+ ```
82
+
83
+ ## Programmatic access
84
+
85
+ ```python
86
+ from html_to_markdown import convert
87
+
88
+ result = convert(html)
89
+ meta = result.metadata
90
+ print(meta.document.title) # "My Article"
91
+ print(meta.document.language) # "en"
92
+ print(meta.headers[0].text) # "Main Heading"
93
+ print(meta.links[0].link_type) # "external"
94
+ print(meta.images[0].alt) # "A photo"
95
+ ```
96
+
97
+ Metadata is available from the single `convert()` call in Python, Rust, Go,
98
+ Ruby, and Elixir; in TypeScript read it off the returned result object. In Rust
99
+ it requires the `metadata` feature (on by default).
100
+
101
+ See `../html-to-markdown/references/cli-reference.md` (Metadata section) and
102
+ `../html-to-markdown/references/configuration.md` for field details.
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: extracting-tables
3
+ description: Use when extracting tabular data from HTML. Covers GFM Markdown tables, the structured tables array (grid cells plus pre-rendered markdown), and HTML line breaks in table cells.
4
+ ---
5
+
6
+ <!--
7
+ AI-RULEZ :: GENERATED FILE — DO NOT EDIT
8
+ Content-Hash: blake3:5597559a9133a3ac5068186a37ec61e7dcdac7881ee4a8077c8efd446e382be1
9
+ Source-Hash: blake3:1479d0c7507cad8660b86e38c91535d1f1e62aae4e74cf75f1d7ad237f287e1b
10
+ Schema-Version: v1
11
+ -->
12
+
13
+ # Extracting tables
14
+
15
+ Use this when the user wants tabular data out of HTML — pricing tables, data
16
+ grids, spec sheets. html-to-markdown parses `<table>` elements into two
17
+ surfaces at once: inline GFM Markdown tables in the `content` stream, and a
18
+ structured `tables` array in the JSON output.
19
+
20
+ ## Two surfaces
21
+
22
+ ```bash
23
+ # Inline GFM tables appear in the Markdown body
24
+ html-to-markdown input.html
25
+
26
+ # Structured table data appears under result.tables (JSON)
27
+ html-to-markdown --json input.html | jq '.tables'
28
+ ```
29
+
30
+ - **Markdown tables in `content`** — `| col | col |` blocks, good for LLM
31
+ ingestion and human reading.
32
+ - **Structured `tables` array** — each entry has a `markdown` field
33
+ (pre-rendered) and a `grid` of structured cells (rows × cols). Use this when
34
+ downstream code needs exact cell access.
35
+
36
+ Both are populated from the same parse; you do not need a flag to enable table
37
+ parsing.
38
+
39
+ ## Extraction-only
40
+
41
+ When you only care about tables (not the Markdown body):
42
+
43
+ ```bash
44
+ html-to-markdown --json --no-content input.html | jq '.tables'
45
+ ```
46
+
47
+ ## Inspecting tables
48
+
49
+ ```bash
50
+ # How many tables, and the row count of each
51
+ html-to-markdown --json input.html \
52
+ | jq '.tables | to_entries | map({index: .key, rows: .value.grid.rows, cols: .value.grid.cols})'
53
+
54
+ # Just the rendered markdown of the first table
55
+ html-to-markdown --json input.html | jq -r '.tables[0].markdown'
56
+ ```
57
+
58
+ ## Line breaks in cells
59
+
60
+ By default `<br>` inside a cell is converted to a space. Keep hard breaks:
61
+
62
+ ```bash
63
+ html-to-markdown input.html --br-in-tables
64
+ ```
65
+
66
+ ## Programmatic access
67
+
68
+ ```python
69
+ from html_to_markdown import convert
70
+
71
+ result = convert(html)
72
+ for table in result.tables:
73
+ print(table.markdown) # rendered GFM markdown
74
+ print(table.grid.cells[0].content) # first cell (grid is a TableGrid)
75
+ ```
76
+
77
+ ```typescript
78
+ import { convert } from "@xberg-io/html-to-markdown";
79
+
80
+ // Node's convert() returns a ConversionResult object directly.
81
+ const result = convert(html);
82
+ for (const table of result.tables ?? []) {
83
+ console.log(table.markdown); // rendered table
84
+ // table.grid is a TableGrid: { rows, cols, cells: GridCell[] }
85
+ }
86
+ ```
87
+
88
+ ## Notes and limits
89
+
90
+ - **Nested tables** are flattened — the inner table is rendered inline within
91
+ the parent cell.
92
+ - **Merged / spanning cells** are reconstructed positionally; the span itself
93
+ is not preserved as separate metadata.
94
+ - **Malformed tables** still parse on a best-effort basis; check `result.warnings`
95
+ (or `--show-warnings`) for non-fatal issues.
96
+
97
+ See `../html-to-markdown/references/cli-reference.md` (Tables section) for the
98
+ full flag set.
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: fetching-and-converting-urls
3
+ description: Use when fetching a live URL and converting it to Markdown. Covers --url, custom user agents, preprocessing for noisy pages, and the --json ConversionResult shape.
4
+ ---
5
+
6
+ <!--
7
+ AI-RULEZ :: GENERATED FILE — DO NOT EDIT
8
+ Content-Hash: blake3:0ec0d1cfab92165c75146dc9c2cd55f3885f8b8e94c2ef4adf24d251263e8697
9
+ Source-Hash: blake3:1479d0c7507cad8660b86e38c91535d1f1e62aae4e74cf75f1d7ad237f287e1b
10
+ Schema-Version: v1
11
+ -->
12
+
13
+ # Fetching and converting URLs
14
+
15
+ Use this when the user gives a URL instead of HTML and wants the page as
16
+ Markdown (or its metadata/tables). The CLI fetches the page over HTTP and
17
+ converts it in one step via `--url`. `--url` conflicts with a positional `FILE`.
18
+
19
+ For crawling *many* pages or following links, use `crawlberg` instead — this
20
+ skill is for a single URL.
21
+
22
+ ## Fetch and convert
23
+
24
+ ```bash
25
+ # Fetch a URL, print Markdown to stdout
26
+ html-to-markdown --url https://example.com
27
+
28
+ # Save to a file
29
+ html-to-markdown --url https://example.com -o page.md
30
+
31
+ # Custom User-Agent (default mimics a real browser)
32
+ html-to-markdown --url https://example.com --user-agent "MyBot/1.0"
33
+ ```
34
+
35
+ `--user-agent` requires `--url`.
36
+
37
+ ## Clean noisy pages
38
+
39
+ Real web pages carry navigation, ads, cookie banners, and forms. Preprocess
40
+ before converting:
41
+
42
+ ```bash
43
+ html-to-markdown --url https://example.com/article --preprocess --preset aggressive
44
+
45
+ # Keep the nav or forms if the page content lives there
46
+ html-to-markdown --url https://example.com --preprocess --keep-navigation
47
+ ```
48
+
49
+ Presets: `minimal`, `standard` (default), `aggressive`. `--preset` and the
50
+ `--keep-*` flags require `--preprocess`.
51
+
52
+ ## JSON output (ConversionResult)
53
+
54
+ Add `--json` to get the full structured result instead of plain Markdown:
55
+
56
+ ```bash
57
+ html-to-markdown --url https://example.com --json
58
+ ```
59
+
60
+ ```json
61
+ {
62
+ "content": "# Title\n\nContent\n",
63
+ "metadata": {
64
+ "document": { "title": "...", "language": "en" },
65
+ "headers": [],
66
+ "links": [],
67
+ "images": [],
68
+ "structured_data": []
69
+ },
70
+ "tables": [],
71
+ "images": [],
72
+ "warnings": []
73
+ }
74
+ ```
75
+
76
+ Useful combinations (all require `--json`):
77
+
78
+ ```bash
79
+ # Page title + outline, no Markdown body
80
+ html-to-markdown --url https://example.com --json --no-content \
81
+ | jq '{title: .metadata.document.title, headings: [.metadata.headers[].text]}'
82
+
83
+ # Include the document-structure tree
84
+ html-to-markdown --url https://example.com --json --include-structure | jq '.document'
85
+
86
+ # Extract inline image data
87
+ html-to-markdown --url https://example.com --json --extract-inline-images | jq '.images | length'
88
+ ```
89
+
90
+ ## Surface warnings
91
+
92
+ ```bash
93
+ html-to-markdown --url https://example.com --show-warnings > page.md
94
+ # non-fatal warnings (truncation, malformed markup) go to stderr
95
+ ```
96
+
97
+ ## Exit codes
98
+
99
+ | Code | Meaning |
100
+ | ---- | ------- |
101
+ | 0 | Success |
102
+ | 1 | Conversion or I/O error (including a failed fetch) |
103
+ | 2 | Invalid arguments |
104
+
105
+ See `../html-to-markdown/references/cli-reference.md` for the full flag set and
106
+ JSON shape.