html-to-markdown 2.5.5-x86_64-linux → 2.29.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,200 +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
63
 
20
64
  ## Installation
21
65
 
22
66
  ```bash
23
- bundle add html-to-markdown
24
- # or
25
67
  gem install html-to-markdown
26
68
  ```
27
69
 
28
- Add the gem to your project and Bundler will compile the native Rust extension on first install.
29
70
 
30
- ### Requirements
31
71
 
32
- - Ruby **3.2+** (Magnus relies on the fiber scheduler APIs added in 3.2)
33
- - Rust toolchain **1.85+** with Cargo available on your `$PATH`
34
- - 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
+
35
75
 
36
- **Windows**: install [RubyInstaller with MSYS2](https://rubyinstaller.org/) (UCRT64). Run once:
37
76
 
38
- ```powershell
39
- ridk exec pacman -S --needed --noconfirm base-devel mingw-w64-ucrt-x86_64-toolchain
40
- ```
41
77
 
42
- This provides the standard headers (including `strings.h`) required for the bindgen step.
43
78
 
44
79
  ## Performance Snapshot
45
80
 
46
- Apple M4 • Real Wikipedia documents • `HtmlToMarkdown.convert` (Ruby)
81
+ Apple M4 • Real Wikipedia documents • `convert()` (Ruby)
47
82
 
48
- | Document | Size | Latency | Throughput | Docs/sec |
49
- | ------------------- | ----- | ------- | ---------- | -------- |
50
- | Lists (Timeline) | 129KB | 0.69ms | 187 MB/s | 1,450 |
51
- | Tables (Countries) | 360KB | 2.19ms | 164 MB/s | 456 |
52
- | Mixed (Python wiki) | 656KB | 4.88ms | 134 MB/s | 205 |
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 |
88
+
89
+
90
+ See [Performance Guide](../../examples/performance/) for detailed benchmarks.
53
91
 
54
- > Same core, same benchmarks: the Ruby extension stays within single-digit % of the Rust CLI and mirrors the Python/Node numbers.
55
92
 
56
93
  ## Quick Start
57
94
 
95
+ Basic conversion:
96
+
58
97
  ```ruby
59
98
  require 'html_to_markdown'
60
99
 
61
- html = <<~HTML
62
- <h1>Welcome</h1>
63
- <p>This is <strong>Rust-fast</strong> conversion!</p>
64
- <ul>
65
- <li>Native extension</li>
66
- <li>Identical output across languages</li>
67
- </ul>
68
- HTML
69
-
100
+ html = "<h1>Hello</h1><p>This is <strong>fast</strong>!</p>"
70
101
  markdown = HtmlToMarkdown.convert(html)
71
- puts markdown
72
- # # Welcome
73
- #
74
- # This is **Rust-fast** conversion!
75
- #
76
- # - Native extension
77
- # - Identical output across languages
78
102
  ```
79
103
 
80
- ## API
81
104
 
82
- ### Conversion Options
83
105
 
84
- 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:
85
107
 
86
108
  ```ruby
87
109
  require 'html_to_markdown'
88
110
 
89
- markdown = HtmlToMarkdown.convert(
90
- '<pre><code class="language-ruby">puts "hi"</code></pre>',
91
- heading_style: :atx,
92
- code_block_style: :fenced,
93
- bullets: '*+-',
94
- list_indent_type: :spaces,
95
- list_indent_width: 2,
96
- whitespace_mode: :normalized,
97
- highlight_style: :double_equal
98
- )
99
-
100
- 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)
101
113
  ```
102
114
 
103
- ### HTML Preprocessing
104
115
 
105
- 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
+
106
185
 
107
186
  ```ruby
108
187
  require 'html_to_markdown'
109
188
 
110
- markdown = HtmlToMarkdown.convert(
111
- html,
112
- preprocessing: {
113
- enabled: true,
114
- preset: :aggressive, # :minimal, :standard, :aggressive
115
- remove_navigation: true,
116
- remove_forms: true
117
- }
118
- )
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."
119
198
  ```
120
199
 
121
- ### Inline Images
122
200
 
123
- 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
+
124
208
 
125
209
  ```ruby
126
210
  require 'html_to_markdown'
127
211
 
128
- result = HtmlToMarkdown.convert_with_inline_images(
129
- '<img src="data:image/png;base64,iVBORw0..." alt="Pixel">',
130
- image_config: {
131
- max_decoded_size_bytes: 1 * 1024 * 1024,
132
- infer_dimensions: true,
133
- filename_prefix: 'img_',
134
- capture_svg: true
135
- }
136
- )
137
-
138
- puts result.markdown
139
- result.inline_images.each do |img|
140
- puts "#{img.filename} -> #{img.format} (#{img.data.bytesize} bytes)"
141
- 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."
142
216
  ```
143
217
 
144
- ## CLI
145
218
 
146
- 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
+
147
238
 
148
239
  ```ruby
149
- require 'html_to_markdown/cli'
240
+ require 'html_to_markdown'
150
241
 
151
- HtmlToMarkdown::CLI.run(%w[--heading-style atx input.html], stdout: $stdout)
152
- # => writes converted Markdown to STDOUT
242
+ html = '<h1>Article</h1><img src="test.jpg" alt="test">'
243
+ markdown, metadata = HtmlToMarkdown.convert_with_metadata(html)
244
+
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
153
250
  ```
154
251
 
155
- 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
+
156
274
 
157
275
  ```ruby
158
- HtmlToMarkdown::CLIProxy.call(['--version'])
159
- # => "html-to-markdown 2.5.5"
160
- ```
276
+ require 'html_to_markdown'
161
277
 
162
- 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
163
292
 
164
- ```bash
165
- bundle exec rake compile # builds the extension
166
- 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)
167
295
  ```
168
296
 
169
- ## Error Handling
170
297
 
171
- Conversion errors raise `HtmlToMarkdown::Error` (wrapping the Rust error context). CLI invocations use specialised subclasses:
172
298
 
173
- - `HtmlToMarkdown::CLIProxy::MissingBinaryError`
174
- - `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/).
175
300
 
176
- Rescue them to provide clearer feedback in your application.
177
301
 
178
- ## Consistent Across Languages
179
302
 
180
- The Ruby gem shares the exact Rust core with:
303
+ ## Examples
181
304
 
182
- - [Python wheels](https://pypi.org/project/html-to-markdown/)
183
- - [Node.js / Bun bindings](https://www.npmjs.com/package/html-to-markdown-node)
184
- - [WebAssembly package](https://www.npmjs.com/package/html-to-markdown-wasm)
185
- - The Rust crate and CLI
305
+ - [Visitor Pattern Guide](../../examples/visitor-pattern/)
306
+ - [Metadata Extraction Guide](../../examples/metadata-extraction/)
307
+ - [Performance Guide](../../examples/performance/)
186
308
 
187
- Use whichever runtime fits your stack while keeping formatting behaviour identical.
309
+ ## Links
188
310
 
189
- ## Development
311
+ - **GitHub:** [github.com/kreuzberg-dev/html-to-markdown](https://github.com/kreuzberg-dev/html-to-markdown)
190
312
 
191
- ```bash
192
- bundle exec rake compile # build the native extension
193
- bundle exec rspec # run test suite
194
- ```
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
195
326
 
196
- 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
197
332
 
198
333
  ## License
199
334
 
200
- 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 CHANGED
@@ -1,13 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/gem_tasks'
4
- require 'rb_sys/extensiontask'
4
+ require 'rake/extensiontask'
5
5
  require 'rspec/core/rake_task'
6
6
 
7
7
  GEMSPEC = Gem::Specification.load(File.expand_path('html-to-markdown-rb.gemspec', __dir__))
8
8
 
9
- RbSys::ExtensionTask.new('html-to-markdown-rb', GEMSPEC) do |ext|
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|
10
17
  ext.lib_dir = 'lib'
18
+ ext.ext_dir = 'ext/html-to-markdown-rb'
11
19
  ext.cross_compile = true
12
20
  ext.cross_platform = %w[
13
21
  x86_64-linux
@@ -19,5 +27,6 @@ end
19
27
 
20
28
  RSpec::Core::RakeTask.new(:spec)
21
29
 
30
+ task compile: :vendor
22
31
  task spec: :compile
23
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