html-to-markdown 2.5.6-x86_64-linux → 2.30.0-x86_64-linux

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.
data/README.md CHANGED
@@ -1,207 +1,345 @@
1
- # html-to-markdown-rb
1
+ # html-to-markdown
2
+
3
+ <div align="center" style="display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px 0;">
4
+ <!-- Language Bindings -->
5
+ <a href="https://crates.io/crates/html-to-markdown-rs">
6
+ <img src="https://img.shields.io/crates/v/html-to-markdown-rs?label=Rust&color=007ec6" alt="Rust">
7
+ </a>
8
+ <a href="https://pypi.org/project/html-to-markdown/">
9
+ <img src="https://img.shields.io/pypi/v/html-to-markdown?label=Python&color=007ec6" alt="Python">
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@kreuzberg/html-to-markdown-node">
12
+ <img src="https://img.shields.io/npm/v/@kreuzberg/html-to-markdown-node?label=Node.js&color=007ec6" alt="Node.js">
13
+ </a>
14
+ <a href="https://www.npmjs.com/package/@kreuzberg/html-to-markdown-wasm">
15
+ <img src="https://img.shields.io/npm/v/@kreuzberg/html-to-markdown-wasm?label=WASM&color=007ec6" alt="WASM">
16
+ </a>
17
+ <a href="https://central.sonatype.com/artifact/dev.kreuzberg/html-to-markdown">
18
+ <img src="https://img.shields.io/maven-central/v/dev.kreuzberg/html-to-markdown?label=Java&color=007ec6" alt="Java">
19
+ </a>
20
+ <a href="https://pkg.go.dev/github.com/kreuzberg-dev/html-to-markdown/packages/go/v2/htmltomarkdown">
21
+ <img src="https://img.shields.io/github/v/tag/kreuzberg-dev/html-to-markdown?label=Go&color=007ec6&filter=v2.29.0" alt="Go">
22
+ </a>
23
+ <a href="https://www.nuget.org/packages/KreuzbergDev.HtmlToMarkdown/">
24
+ <img src="https://img.shields.io/nuget/v/KreuzbergDev.HtmlToMarkdown?label=C%23&color=007ec6" alt="C#">
25
+ </a>
26
+ <a href="https://packagist.org/packages/kreuzberg-dev/html-to-markdown">
27
+ <img src="https://img.shields.io/packagist/v/kreuzberg-dev/html-to-markdown?label=PHP&color=007ec6" alt="PHP">
28
+ </a>
29
+ <a href="https://rubygems.org/gems/html-to-markdown">
30
+ <img src="https://img.shields.io/gem/v/html-to-markdown?label=Ruby&color=007ec6" alt="Ruby">
31
+ </a>
32
+ <a href="https://hex.pm/packages/html_to_markdown">
33
+ <img src="https://img.shields.io/hexpm/v/html_to_markdown?label=Elixir&color=007ec6" alt="Elixir">
34
+ </a>
35
+ <a href="https://kreuzberg-dev.r-universe.dev/htmltomarkdown">
36
+ <img src="https://img.shields.io/cran/v/htmltomarkdown?label=R&color=007ec6" alt="R">
37
+ </a>
38
+ <a href="https://github.com/kreuzberg-dev/html-to-markdown/releases">
39
+ <img src="https://img.shields.io/badge/C-FFI-007ec6" alt="C">
40
+ </a>
41
+
42
+ <!-- Project Info -->
43
+ <a href="https://docs.html-to-markdown.kreuzberg.dev">
44
+ <img src="https://img.shields.io/badge/Docs-kreuzberg.dev-007ec6" alt="Documentation">
45
+ </a>
46
+ <a href="https://github.com/kreuzberg-dev/html-to-markdown/blob/main/LICENSE">
47
+ <img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License">
48
+ </a>
49
+ </div>
50
+
51
+ <img width="1128" height="191" alt="html-to-markdown" src="https://github.com/user-attachments/assets/419fc06c-8313-4324-b159-4b4d3cfce5c0" />
52
+
53
+ <div align="center" style="margin-top: 20px;">
54
+ <a href="https://discord.gg/pXxagNK2zN">
55
+ <img height="22" src="https://img.shields.io/badge/Discord-Join%20our%20community-7289da?logo=discord&logoColor=white" alt="Discord">
56
+ </a>
57
+ </div>
58
+
59
+
60
+ Blazing-fast HTML to Markdown conversion for Ruby, powered by the same Rust engine used by our Python, Node.js, WebAssembly, and PHP packages.
61
+ Ship identical Markdown across every runtime while enjoying native extension performance with Magnus bindings.
2
62
 
3
- Blazing-fast HTML → Markdown conversion for Ruby, powered by the same Rust engine used by our Python, Node.js, and WebAssembly packages. Ship identical Markdown across every runtime while enjoying native extension performance.
4
-
5
- [![Crates.io](https://img.shields.io/crates/v/html-to-markdown-rs.svg)](https://crates.io/crates/html-to-markdown-rs)
6
- [![npm version](https://badge.fury.io/js/html-to-markdown-node.svg)](https://www.npmjs.com/package/html-to-markdown-node)
7
- [![PyPI version](https://badge.fury.io/py/html-to-markdown.svg)](https://pypi.org/project/html-to-markdown/)
8
- [![Gem Version](https://badge.fury.io/rb/html-to-markdown.svg)](https://rubygems.org/gems/html-to-markdown)
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Goldziher/html-to-markdown/blob/main/LICENSE)
10
-
11
- ## Features
12
-
13
- - ⚡ **Rust-fast**: Ruby bindings around a highly optimised Rust core (60‑80× faster than BeautifulSoup-based converters).
14
- - 🔁 **Identical output**: Shares logic with the Python wheels, npm bindings, WASM package, and CLI — consistent Markdown everywhere.
15
- - ⚙️ **Rich configuration**: Control heading styles, list indentation, whitespace handling, HTML preprocessing, and more.
16
- - 🖼️ **Inline image extraction**: Pull out embedded images (PNG/JPEG/SVG/data URIs) alongside Markdown.
17
- - 🧰 **Bundled CLI proxy**: Call the Rust CLI straight from Ruby or shell scripts.
18
- - 🛠️ **First-class Rails support**: Works with `Gem.win_platform?` builds, supports Trusted Publishing, and compiles on install if no native gem matches.
19
-
20
- ## Documentation & Support
21
-
22
- - [GitHub repository](https://github.com/Goldziher/html-to-markdown)
23
- - [Issue tracker](https://github.com/Goldziher/html-to-markdown/issues)
24
- - [Changelog](https://github.com/Goldziher/html-to-markdown/blob/main/CHANGELOG.md)
25
- - [Live demo (WASM)](https://goldziher.github.io/html-to-markdown/)
26
63
 
27
64
  ## Installation
28
65
 
29
66
  ```bash
30
- bundle add html-to-markdown
31
- # or
32
67
  gem install html-to-markdown
33
68
  ```
34
69
 
35
- Add the gem to your project and Bundler will compile the native Rust extension on first install.
36
70
 
37
- ### Requirements
38
71
 
39
- - Ruby **3.2+** (Magnus relies on the fiber scheduler APIs added in 3.2)
40
- - Rust toolchain **1.85+** with Cargo available on your `$PATH`
41
- - Ruby development headers (`ruby-dev`, `ruby-devel`, or the platform equivalent)
72
+ Requires Ruby 3.2+ with Magnus native extension bindings. Published for Linux, macOS.
73
+
74
+
42
75
 
43
- **Windows**: install [RubyInstaller with MSYS2](https://rubyinstaller.org/) (UCRT64). Run once:
44
76
 
45
- ```powershell
46
- ridk exec pacman -S --needed --noconfirm base-devel mingw-w64-ucrt-x86_64-toolchain
47
- ```
48
77
 
49
- This provides the standard headers (including `strings.h`) required for the bindgen step.
50
78
 
51
79
  ## Performance Snapshot
52
80
 
53
- Apple M4 • Real Wikipedia documents • `HtmlToMarkdown.convert` (Ruby)
81
+ Apple M4 • Real Wikipedia documents • `convert()` (Ruby)
82
+
83
+ | Document | Size | Latency | Throughput |
84
+ | -------- | ---- | ------- | ---------- |
85
+ | Lists (Timeline) | 129KB | 0.71ms | 182 MB/s |
86
+ | Tables (Countries) | 360KB | 2.15ms | 167 MB/s |
87
+ | Mixed (Python wiki) | 656KB | 4.89ms | 134 MB/s |
54
88
 
55
- | Document | Size | Latency | Throughput | Docs/sec |
56
- | ------------------- | ----- | ------- | ---------- | -------- |
57
- | Lists (Timeline) | 129KB | 0.69ms | 187 MB/s | 1,450 |
58
- | Tables (Countries) | 360KB | 2.19ms | 164 MB/s | 456 |
59
- | Mixed (Python wiki) | 656KB | 4.88ms | 134 MB/s | 205 |
60
89
 
61
- > Same core, same benchmarks: the Ruby extension stays within single-digit % of the Rust CLI and mirrors the Python/Node numbers.
90
+ See [Performance Guide](../../examples/performance/) for detailed benchmarks.
91
+
62
92
 
63
93
  ## Quick Start
64
94
 
95
+ Basic conversion:
96
+
65
97
  ```ruby
66
98
  require 'html_to_markdown'
67
99
 
68
- html = <<~HTML
69
- <h1>Welcome</h1>
70
- <p>This is <strong>Rust-fast</strong> conversion!</p>
71
- <ul>
72
- <li>Native extension</li>
73
- <li>Identical output across languages</li>
74
- </ul>
75
- HTML
76
-
100
+ html = "<h1>Hello</h1><p>This is <strong>fast</strong>!</p>"
77
101
  markdown = HtmlToMarkdown.convert(html)
78
- puts markdown
79
- # # Welcome
80
- #
81
- # This is **Rust-fast** conversion!
82
- #
83
- # - Native extension
84
- # - Identical output across languages
85
102
  ```
86
103
 
87
- ## API
88
104
 
89
- ### Conversion Options
90
105
 
91
- Pass a Ruby hash (string or symbol keys) to tweak rendering. Every option maps one-for-one with the Rust/Python/Node APIs.
106
+ With conversion options:
92
107
 
93
108
  ```ruby
94
109
  require 'html_to_markdown'
95
110
 
96
- markdown = HtmlToMarkdown.convert(
97
- '<pre><code class="language-ruby">puts "hi"</code></pre>',
98
- heading_style: :atx,
99
- code_block_style: :fenced,
100
- bullets: '*+-',
101
- list_indent_type: :spaces,
102
- list_indent_width: 2,
103
- whitespace_mode: :normalized,
104
- highlight_style: :double_equal
105
- )
106
-
107
- puts markdown
111
+ html = "<h1>Hello</h1><p>This is <strong>fast</strong>!</p>"
112
+ markdown = HtmlToMarkdown.convert(html, heading_style: :atx, code_block_style: :fenced)
108
113
  ```
109
114
 
110
- ### HTML Preprocessing
111
115
 
112
- Clean up scraped HTML (navigation, forms, malformed markup) before conversion:
116
+
117
+
118
+
119
+
120
+ ## API Reference
121
+
122
+ ### Core Functions
123
+
124
+
125
+ **`convert(html, options: nil) -> String`**
126
+
127
+ Basic HTML-to-Markdown conversion. Fast and simple.
128
+
129
+ **`convert_with_metadata(html, options: nil, config: nil) -> [String, Hash]`**
130
+
131
+ Extract Markdown plus metadata (headers, links, images, structured data) in a single pass. See [Metadata Extraction Guide](../../examples/metadata-extraction/).
132
+
133
+ **`convert_with_visitor(html, visitor:, options: nil) -> String`**
134
+
135
+ Customize conversion with visitor callbacks for element interception. See [Visitor Pattern Guide](../../examples/visitor-pattern/).
136
+
137
+ **`convert_with_inline_images(html, config: nil) -> [String, Array, Array]`**
138
+
139
+ Extract base64-encoded inline images with metadata.
140
+
141
+ **`convert_with_tables(html, options: nil, config: nil) -> ConversionWithTables`**
142
+
143
+ Extract structured table data (cells, headers, rendered markdown) alongside conversion.
144
+
145
+
146
+
147
+ ### Options
148
+
149
+ **`ConversionOptions`** – Key configuration fields:
150
+ - `heading_style`: Heading format (`"underlined"` | `"atx"` | `"atx_closed"`) — default: `"underlined"`
151
+ - `list_indent_width`: Spaces per indent level — default: `2`
152
+ - `bullets`: Bullet characters cycle — default: `"*+-"`
153
+ - `wrap`: Enable text wrapping — default: `false`
154
+ - `wrap_width`: Wrap at column — default: `80`
155
+ - `code_language`: Default fenced code block language — default: none
156
+ - `extract_metadata`: Embed metadata as YAML frontmatter — default: `false`
157
+ - `output_format`: Output markup format (`"markdown"` | `"djot"` | `"plain"`) — default: `"markdown"`
158
+
159
+ **`MetadataConfig`** – Selective metadata extraction:
160
+ - `extract_headers`: h1-h6 elements — default: `true`
161
+ - `extract_links`: Hyperlinks — default: `true`
162
+ - `extract_images`: Image elements — default: `true`
163
+ - `extract_structured_data`: JSON-LD, Microdata, RDFa — default: `true`
164
+ - `max_structured_data_size`: Size limit in bytes — default: `100KB`
165
+
166
+
167
+ ## Djot Output Format
168
+
169
+ The library supports converting HTML to [Djot](https://djot.net/), a lightweight markup language similar to Markdown but with a different syntax for some elements. Set `output_format` to `"djot"` to use this format.
170
+
171
+ ### Syntax Differences
172
+
173
+ | Element | Markdown | Djot |
174
+ |---------|----------|------|
175
+ | Strong | `**text**` | `*text*` |
176
+ | Emphasis | `*text*` | `_text_` |
177
+ | Strikethrough | `~~text~~` | `{-text-}` |
178
+ | Inserted/Added | N/A | `{+text+}` |
179
+ | Highlighted | N/A | `{=text=}` |
180
+ | Subscript | N/A | `~text~` |
181
+ | Superscript | N/A | `^text^` |
182
+
183
+ ### Example Usage
184
+
113
185
 
114
186
  ```ruby
115
187
  require 'html_to_markdown'
116
188
 
117
- markdown = HtmlToMarkdown.convert(
118
- html,
119
- preprocessing: {
120
- enabled: true,
121
- preset: :aggressive, # :minimal, :standard, :aggressive
122
- remove_navigation: true,
123
- remove_forms: true
124
- }
125
- )
189
+ html = "<p>This is <strong>bold</strong> and <em>italic</em> text.</p>"
190
+
191
+ # Default Markdown output
192
+ markdown = HtmlToMarkdown.convert(html)
193
+ # Result: "This is **bold** and *italic* text."
194
+
195
+ # Djot output
196
+ djot = HtmlToMarkdown.convert(html, output_format: 'djot')
197
+ # Result: "This is *bold* and _italic_ text."
126
198
  ```
127
199
 
128
- ### Inline Images
129
200
 
130
- Extract inline binary data (data URIs, SVG) together with the converted Markdown.
201
+ Djot's extended syntax allows you to express more semantic meaning in lightweight text, making it useful for documents that require strikethrough, insertion tracking, or mathematical notation.
202
+
203
+
204
+ ## Plain Text Output
205
+
206
+ Set `output_format` to `"plain"` to strip all markup and return only visible text. This bypasses the Markdown conversion pipeline entirely for maximum speed.
207
+
131
208
 
132
209
  ```ruby
133
210
  require 'html_to_markdown'
134
211
 
135
- result = HtmlToMarkdown.convert_with_inline_images(
136
- '<img src="data:image/png;base64,iVBORw0..." alt="Pixel">',
137
- image_config: {
138
- max_decoded_size_bytes: 1 * 1024 * 1024,
139
- infer_dimensions: true,
140
- filename_prefix: 'img_',
141
- capture_svg: true
142
- }
143
- )
144
-
145
- puts result.markdown
146
- result.inline_images.each do |img|
147
- puts "#{img.filename} -> #{img.format} (#{img.data.bytesize} bytes)"
148
- end
212
+ html = "<h1>Title</h1><p>This is <strong>bold</strong> and <em>italic</em> text.</p>"
213
+
214
+ plain = HtmlToMarkdown.convert(html, output_format: 'plain')
215
+ # Result: "Title\n\nThis is bold and italic text."
149
216
  ```
150
217
 
151
- ## CLI
152
218
 
153
- The gem bundles a small proxy for the Rust CLI binary. Use it when you need parity with the standalone `html-to-markdown` executable.
219
+ Plain text mode is useful for search indexing, text extraction, and feeding content to LLMs.
220
+
221
+
222
+
223
+ ## Metadata Extraction
224
+
225
+ The metadata extraction feature enables comprehensive document analysis during conversion. Extract document properties, headers, links, images, and structured data in a single pass.
226
+
227
+ **Use Cases:**
228
+ - **SEO analysis** – Extract title, description, Open Graph tags, Twitter cards
229
+ - **Table of contents generation** – Build structured outlines from heading hierarchy
230
+ - **Content migration** – Document all external links and resources
231
+ - **Accessibility audits** – Check for images without alt text, empty links, invalid heading hierarchy
232
+ - **Link validation** – Classify and validate anchor, internal, external, email, and phone links
233
+
234
+ **Zero Overhead When Disabled:** Metadata extraction adds negligible overhead and happens during the HTML parsing pass. Disable unused metadata types in `MetadataConfig` to optimize further.
235
+
236
+ ### Example: Quick Start
237
+
154
238
 
155
239
  ```ruby
156
- require 'html_to_markdown/cli'
240
+ require 'html_to_markdown'
241
+
242
+ html = '<h1>Article</h1><img src="test.jpg" alt="test">'
243
+ markdown, metadata = HtmlToMarkdown.convert_with_metadata(html)
157
244
 
158
- HtmlToMarkdown::CLI.run(%w[--heading-style atx input.html], stdout: $stdout)
159
- # => writes converted Markdown to STDOUT
245
+ puts metadata[:document][:title] # Document title
246
+ puts metadata[:headers] # All h1-h6 elements
247
+ puts metadata[:links] # All hyperlinks
248
+ puts metadata[:images] # All images with alt text
249
+ puts metadata[:structured_data] # JSON-LD, Microdata, RDFa
160
250
  ```
161
251
 
162
- You can also call the CLI binary directly for scripting:
252
+
253
+
254
+ For detailed examples including SEO extraction, table-of-contents generation, link validation, and accessibility audits, see the [Metadata Extraction Guide](../../examples/metadata-extraction/).
255
+
256
+
257
+
258
+
259
+ ## Visitor Pattern
260
+
261
+ The visitor pattern enables custom HTML→Markdown conversion logic by providing callbacks for specific HTML elements during traversal. Use visitors to transform content, filter elements, validate structure, or collect analytics.
262
+
263
+ **Use Cases:**
264
+ - **Custom Markdown dialects** – Convert to Obsidian, Notion, or other flavors
265
+ - **Content filtering** – Remove tracking pixels, ads, or unwanted elements
266
+ - **URL rewriting** – Rewrite CDN URLs, add query parameters, validate links
267
+ - **Accessibility validation** – Check alt text, heading hierarchy, link text
268
+ - **Analytics** – Track element usage, link destinations, image sources
269
+
270
+ **Supported Visitor Methods:** 40+ callbacks for text, inline elements, links, images, headings, lists, blocks, and tables.
271
+
272
+ ### Example: Quick Start
273
+
163
274
 
164
275
  ```ruby
165
- HtmlToMarkdown::CLIProxy.call(['--version'])
166
- # => "html-to-markdown 2.5.6"
167
- ```
276
+ require 'html_to_markdown'
168
277
 
169
- Rebuild the CLI locally if you see `CLI binary not built` during tests:
278
+ class MyVisitor
279
+ def visit_link(ctx, href, text, title = nil)
280
+ # Rewrite CDN URLs
281
+ if href.start_with?('https://old-cdn.com')
282
+ href = href.sub('https://old-cdn.com', 'https://new-cdn.com')
283
+ end
284
+ { type: :custom, output: "[#{text}](#{href})" }
285
+ end
286
+
287
+ def visit_image(ctx, src, alt = nil, title = nil)
288
+ # Skip tracking pixels
289
+ src.include?('tracking') ? { type: :skip } : { type: :continue }
290
+ end
291
+ end
170
292
 
171
- ```bash
172
- bundle exec rake compile # builds the extension
173
- bundle exec ruby scripts/prepare_ruby_gem.rb # copies the CLI into lib/bin/
293
+ html = '<a href="https://old-cdn.com/file.pdf">Download</a>'
294
+ markdown = HtmlToMarkdown.convert_with_visitor(html, visitor: MyVisitor.new)
174
295
  ```
175
296
 
176
- ## Error Handling
177
297
 
178
- Conversion errors raise `HtmlToMarkdown::Error` (wrapping the Rust error context). CLI invocations use specialised subclasses:
179
298
 
180
- - `HtmlToMarkdown::CLIProxy::MissingBinaryError`
181
- - `HtmlToMarkdown::CLIProxy::CLIExecutionError`
299
+ For comprehensive examples including content filtering, link footnotes, accessibility validation, and asynchronous URL validation, see the [Visitor Pattern Guide](../../examples/visitor-pattern/).
182
300
 
183
- Rescue them to provide clearer feedback in your application.
184
301
 
185
- ## Consistent Across Languages
186
302
 
187
- The Ruby gem shares the exact Rust core with:
303
+ ## Examples
188
304
 
189
- - [Python wheels](https://pypi.org/project/html-to-markdown/)
190
- - [Node.js / Bun bindings](https://www.npmjs.com/package/html-to-markdown-node)
191
- - [WebAssembly package](https://www.npmjs.com/package/html-to-markdown-wasm)
192
- - The Rust crate and CLI
305
+ - [Visitor Pattern Guide](../../examples/visitor-pattern/)
306
+ - [Metadata Extraction Guide](../../examples/metadata-extraction/)
307
+ - [Performance Guide](../../examples/performance/)
193
308
 
194
- Use whichever runtime fits your stack while keeping formatting behaviour identical.
309
+ ## Links
195
310
 
196
- ## Development
311
+ - **GitHub:** [github.com/kreuzberg-dev/html-to-markdown](https://github.com/kreuzberg-dev/html-to-markdown)
197
312
 
198
- ```bash
199
- bundle exec rake compile # build the native extension
200
- bundle exec rspec # run test suite
201
- ```
313
+ - **RubyGems:** [rubygems.org/gems/html-to-markdown](https://rubygems.org/gems/html-to-markdown)
314
+
315
+ - **Kreuzberg Ecosystem:** [kreuzberg.dev](https://kreuzberg.dev)
316
+ - **Discord:** [discord.gg/pXxagNK2zN](https://discord.gg/pXxagNK2zN)
317
+
318
+ ## Contributing
319
+
320
+ We welcome contributions! Please see our [Contributing Guide](https://github.com/kreuzberg-dev/html-to-markdown/blob/main/CONTRIBUTING.md) for details on:
321
+
322
+ - Setting up the development environment
323
+ - Running tests locally
324
+ - Submitting pull requests
325
+ - Reporting issues
202
326
 
203
- The extension uses [Magnus](https://github.com/matsadler/magnus) plus `rb-sys` for bindgen. When editing the Rust code under `src/`, rerun `rake compile`.
327
+ All contributions must follow our code quality standards (enforced via pre-commit hooks):
328
+
329
+ - Proper test coverage (Rust 95%+, language bindings 80%+)
330
+ - Formatting and linting checks
331
+ - Documentation for public APIs
204
332
 
205
333
  ## License
206
334
 
207
- MIT © Na'aman Hirschfeld
335
+ MIT License – see [LICENSE](https://github.com/kreuzberg-dev/html-to-markdown/blob/main/LICENSE).
336
+
337
+ ## Support
338
+
339
+ If you find this library useful, consider [sponsoring the project](https://github.com/sponsors/kreuzberg-dev).
340
+
341
+ Have questions or run into issues? We're here to help:
342
+
343
+ - **GitHub Issues:** [github.com/kreuzberg-dev/html-to-markdown/issues](https://github.com/kreuzberg-dev/html-to-markdown/issues)
344
+ - **Discussions:** [github.com/kreuzberg-dev/html-to-markdown/discussions](https://github.com/kreuzberg-dev/html-to-markdown/discussions)
345
+ - **Discord Community:** [discord.gg/pXxagNK2zN](https://discord.gg/pXxagNK2zN)
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/extensiontask'
5
+ require 'rspec/core/rake_task'
6
+
7
+ GEMSPEC = Gem::Specification.load(File.expand_path('html-to-markdown-rb.gemspec', __dir__))
8
+
9
+ # Vendor html-to-markdown-rs core crate before compilation
10
+ task :vendor do
11
+ vendor_script = File.expand_path('../../scripts/ci/ruby/vendor-core-crate.py', __dir__)
12
+ puts 'Vendoring html-to-markdown-rs core crate...'
13
+ sh "python3 #{vendor_script}"
14
+ end
15
+
16
+ Rake::ExtensionTask.new('html_to_markdown_rb', GEMSPEC) do |ext|
17
+ ext.lib_dir = 'lib'
18
+ ext.ext_dir = 'ext/html-to-markdown-rb'
19
+ ext.cross_compile = true
20
+ ext.cross_platform = %w[
21
+ x86_64-linux
22
+ x86_64-darwin
23
+ arm64-darwin
24
+ x64-mingw32
25
+ ]
26
+ end
27
+
28
+ RSpec::Core::RakeTask.new(:spec)
29
+
30
+ task compile: :vendor
31
+ task spec: :compile
32
+ task default: :spec
data/Steepfile ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Steepfile for type checking html-to-markdown Ruby gem
4
+
5
+ target :lib do
6
+ signature 'sig'
7
+
8
+ check 'lib'
9
+
10
+ # Configure libraries
11
+ library 'pathname'
12
+ library 'open3'
13
+
14
+ # Ignore vendor directory
15
+ ignore 'vendor'
16
+
17
+ # Ignore spec directory
18
+ ignore 'spec'
19
+
20
+ # Ignore bin directory
21
+ ignore 'bin'
22
+
23
+ # Ignore internal implementation modules (not public API)
24
+ ignore 'lib/html_to_markdown/cli.rb'
25
+ ignore 'lib/html_to_markdown/cli_proxy.rb'
26
+ end