html-to-markdown 2.29.0-arm64-darwin
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.
- checksums.yaml +7 -0
- data/.bundle/config +2 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +29 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +223 -0
- data/README.md +345 -0
- data/Rakefile +32 -0
- data/Steepfile +26 -0
- data/bin/benchmark.rb +232 -0
- data/exe/html-to-markdown +6 -0
- data/html-to-markdown-rb.gemspec +99 -0
- data/lib/html_to_markdown/cli.rb +21 -0
- data/lib/html_to_markdown/cli_proxy.rb +74 -0
- data/lib/html_to_markdown/version.rb +5 -0
- data/lib/html_to_markdown.rb +211 -0
- data/lib/html_to_markdown_rb.bundle +0 -0
- data/sig/html_to_markdown/cli.rbs +24 -0
- data/sig/html_to_markdown/cli_proxy.rbs +48 -0
- data/sig/html_to_markdown.rbs +498 -0
- data/sig/open3.rbs +12 -0
- data/spec/cli_proxy_spec.rb +42 -0
- data/spec/convert_spec.rb +77 -0
- data/spec/convert_with_tables_spec.rb +194 -0
- data/spec/metadata_extraction_spec.rb +437 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/visitor_issue_187_spec.rb +605 -0
- data/spec/visitor_spec.rb +1149 -0
- metadata +80 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: af0702a101a9f57b353c47f29feff488c4586f2b8e73a945888de96b370d2f83
|
|
4
|
+
data.tar.gz: 65e746754f6a8224c1f4b42450bc54660037b1a455a93e4da7def013a293ff3e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 38d9592c0ae63185e8da604fcf9e23e00d33c07c24192d6bfc1cbe874683bd0ab66e7b6b11a7b1a2d095a2b9dc0e7c5a0320f2cfd00a4a671a5ec50a65ddef15
|
|
7
|
+
data.tar.gz: 884a3c4a7386b7106ceb63ee6e39089e28bd915c0063b8c8b0ecf33d66237dbcfef2621c17b0e4eb52917245cfbf373ef294618762906e7b6064ff881ed1e2b8
|
data/.bundle/config
ADDED
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-rspec
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
NewCops: enable
|
|
6
|
+
TargetRubyVersion: 3.2
|
|
7
|
+
Exclude:
|
|
8
|
+
- "tmp/**/*"
|
|
9
|
+
- "vendor/**/*"
|
|
10
|
+
|
|
11
|
+
Style/Documentation:
|
|
12
|
+
Enabled: false
|
|
13
|
+
|
|
14
|
+
Metrics/BlockLength:
|
|
15
|
+
Exclude:
|
|
16
|
+
- "spec/**/*"
|
|
17
|
+
- "*.gemspec"
|
|
18
|
+
|
|
19
|
+
Metrics/MethodLength:
|
|
20
|
+
Max: 15
|
|
21
|
+
|
|
22
|
+
RSpec/MultipleExpectations:
|
|
23
|
+
Enabled: false
|
|
24
|
+
|
|
25
|
+
RSpec/ExampleLength:
|
|
26
|
+
Enabled: false
|
|
27
|
+
|
|
28
|
+
RSpec/SpecFilePathFormat:
|
|
29
|
+
Enabled: false
|
data/Gemfile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
|
+
|
|
5
|
+
ruby '>= 3.2'
|
|
6
|
+
|
|
7
|
+
gemspec
|
|
8
|
+
|
|
9
|
+
group :development, :test do
|
|
10
|
+
gem 'rake-compiler'
|
|
11
|
+
gem 'rbs', require: false
|
|
12
|
+
gem 'rb_sys' # provides build tooling when developing locally
|
|
13
|
+
gem 'rspec'
|
|
14
|
+
gem 'rubocop', require: false
|
|
15
|
+
gem 'rubocop-rspec', require: false
|
|
16
|
+
gem 'steep', require: false
|
|
17
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
html-to-markdown (2.29.0)
|
|
5
|
+
rb_sys (>= 0.9, < 1.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activesupport (8.1.2)
|
|
11
|
+
base64
|
|
12
|
+
bigdecimal
|
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
14
|
+
connection_pool (>= 2.2.5)
|
|
15
|
+
drb
|
|
16
|
+
i18n (>= 1.6, < 2)
|
|
17
|
+
json
|
|
18
|
+
logger (>= 1.4.2)
|
|
19
|
+
minitest (>= 5.1)
|
|
20
|
+
securerandom (>= 0.3)
|
|
21
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
22
|
+
uri (>= 0.13.1)
|
|
23
|
+
addressable (2.8.9)
|
|
24
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
25
|
+
ast (2.4.3)
|
|
26
|
+
base64 (0.3.0)
|
|
27
|
+
bigdecimal (4.0.1)
|
|
28
|
+
concurrent-ruby (1.3.6)
|
|
29
|
+
connection_pool (3.0.2)
|
|
30
|
+
csv (3.3.5)
|
|
31
|
+
diff-lcs (1.6.2)
|
|
32
|
+
drb (2.2.3)
|
|
33
|
+
ffi (1.17.3-aarch64-linux-gnu)
|
|
34
|
+
ffi (1.17.3-arm64-darwin)
|
|
35
|
+
ffi (1.17.3-x64-mingw-ucrt)
|
|
36
|
+
ffi (1.17.3-x86_64-darwin)
|
|
37
|
+
ffi (1.17.3-x86_64-linux-gnu)
|
|
38
|
+
fileutils (1.8.0)
|
|
39
|
+
i18n (1.14.8)
|
|
40
|
+
concurrent-ruby (~> 1.0)
|
|
41
|
+
json (2.19.2)
|
|
42
|
+
json-schema (6.2.0)
|
|
43
|
+
addressable (~> 2.8)
|
|
44
|
+
bigdecimal (>= 3.1, < 5)
|
|
45
|
+
language_server-protocol (3.17.0.5)
|
|
46
|
+
lint_roller (1.1.0)
|
|
47
|
+
listen (3.10.0)
|
|
48
|
+
logger
|
|
49
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
50
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
51
|
+
logger (1.7.0)
|
|
52
|
+
mcp (0.9.0)
|
|
53
|
+
json-schema (>= 4.1)
|
|
54
|
+
minitest (6.0.2)
|
|
55
|
+
drb (~> 2.0)
|
|
56
|
+
prism (~> 1.5)
|
|
57
|
+
mutex_m (0.3.0)
|
|
58
|
+
parallel (1.27.0)
|
|
59
|
+
parser (3.3.10.2)
|
|
60
|
+
ast (~> 2.4.1)
|
|
61
|
+
racc
|
|
62
|
+
prism (1.9.0)
|
|
63
|
+
public_suffix (7.0.5)
|
|
64
|
+
racc (1.8.1)
|
|
65
|
+
rainbow (3.1.1)
|
|
66
|
+
rake (13.3.1)
|
|
67
|
+
rake-compiler (1.3.1)
|
|
68
|
+
rake
|
|
69
|
+
rake-compiler-dock (1.11.0)
|
|
70
|
+
rb-fsevent (0.11.2)
|
|
71
|
+
rb-inotify (0.11.1)
|
|
72
|
+
ffi (~> 1.0)
|
|
73
|
+
rb_sys (0.9.124)
|
|
74
|
+
rake-compiler-dock (= 1.11.0)
|
|
75
|
+
rbs (3.10.3)
|
|
76
|
+
logger
|
|
77
|
+
tsort
|
|
78
|
+
regexp_parser (2.11.3)
|
|
79
|
+
rspec (3.13.2)
|
|
80
|
+
rspec-core (~> 3.13.0)
|
|
81
|
+
rspec-expectations (~> 3.13.0)
|
|
82
|
+
rspec-mocks (~> 3.13.0)
|
|
83
|
+
rspec-core (3.13.6)
|
|
84
|
+
rspec-support (~> 3.13.0)
|
|
85
|
+
rspec-expectations (3.13.5)
|
|
86
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
87
|
+
rspec-support (~> 3.13.0)
|
|
88
|
+
rspec-mocks (3.13.8)
|
|
89
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
90
|
+
rspec-support (~> 3.13.0)
|
|
91
|
+
rspec-support (3.13.7)
|
|
92
|
+
rubocop (1.85.1)
|
|
93
|
+
json (~> 2.3)
|
|
94
|
+
language_server-protocol (~> 3.17.0.2)
|
|
95
|
+
lint_roller (~> 1.1.0)
|
|
96
|
+
mcp (~> 0.6)
|
|
97
|
+
parallel (~> 1.10)
|
|
98
|
+
parser (>= 3.3.0.2)
|
|
99
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
100
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
101
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
102
|
+
ruby-progressbar (~> 1.7)
|
|
103
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
104
|
+
rubocop-ast (1.49.1)
|
|
105
|
+
parser (>= 3.3.7.2)
|
|
106
|
+
prism (~> 1.7)
|
|
107
|
+
rubocop-rspec (3.9.0)
|
|
108
|
+
lint_roller (~> 1.1)
|
|
109
|
+
rubocop (~> 1.81)
|
|
110
|
+
ruby-progressbar (1.13.0)
|
|
111
|
+
securerandom (0.4.1)
|
|
112
|
+
steep (1.10.0)
|
|
113
|
+
activesupport (>= 5.1)
|
|
114
|
+
concurrent-ruby (>= 1.1.10)
|
|
115
|
+
csv (>= 3.0.9)
|
|
116
|
+
fileutils (>= 1.1.0)
|
|
117
|
+
json (>= 2.1.0)
|
|
118
|
+
language_server-protocol (>= 3.17.0.4, < 4.0)
|
|
119
|
+
listen (~> 3.0)
|
|
120
|
+
logger (>= 1.3.0)
|
|
121
|
+
mutex_m (>= 0.3.0)
|
|
122
|
+
parser (>= 3.1)
|
|
123
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
124
|
+
rbs (~> 3.9)
|
|
125
|
+
securerandom (>= 0.1)
|
|
126
|
+
strscan (>= 1.0.0)
|
|
127
|
+
terminal-table (>= 2, < 5)
|
|
128
|
+
uri (>= 0.12.0)
|
|
129
|
+
strscan (3.1.7)
|
|
130
|
+
terminal-table (4.0.0)
|
|
131
|
+
unicode-display_width (>= 1.1.1, < 4)
|
|
132
|
+
tsort (0.2.0)
|
|
133
|
+
tzinfo (2.0.6)
|
|
134
|
+
concurrent-ruby (~> 1.0)
|
|
135
|
+
unicode-display_width (3.2.0)
|
|
136
|
+
unicode-emoji (~> 4.1)
|
|
137
|
+
unicode-emoji (4.2.0)
|
|
138
|
+
uri (1.1.1)
|
|
139
|
+
|
|
140
|
+
PLATFORMS
|
|
141
|
+
aarch64-linux
|
|
142
|
+
arm64-darwin
|
|
143
|
+
x64-mingw-ucrt
|
|
144
|
+
x86_64-darwin
|
|
145
|
+
x86_64-linux
|
|
146
|
+
x86_64-linux-gnu
|
|
147
|
+
|
|
148
|
+
DEPENDENCIES
|
|
149
|
+
html-to-markdown!
|
|
150
|
+
rake-compiler
|
|
151
|
+
rb_sys
|
|
152
|
+
rbs
|
|
153
|
+
rspec
|
|
154
|
+
rubocop
|
|
155
|
+
rubocop-rspec
|
|
156
|
+
steep
|
|
157
|
+
|
|
158
|
+
CHECKSUMS
|
|
159
|
+
activesupport (8.1.2) sha256=88842578ccd0d40f658289b0e8c842acfe9af751afee2e0744a7873f50b6fdae
|
|
160
|
+
addressable (2.8.9) sha256=cc154fcbe689711808a43601dee7b980238ce54368d23e127421753e46895485
|
|
161
|
+
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
|
162
|
+
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
|
163
|
+
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
|
|
164
|
+
concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
|
|
165
|
+
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
|
|
166
|
+
csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f
|
|
167
|
+
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
|
168
|
+
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
|
|
169
|
+
ffi (1.17.3-aarch64-linux-gnu) sha256=28ad573df26560f0aedd8a90c3371279a0b2bd0b4e834b16a2baa10bd7a97068
|
|
170
|
+
ffi (1.17.3-arm64-darwin) sha256=0c690555d4cee17a7f07c04d59df39b2fba74ec440b19da1f685c6579bb0717f
|
|
171
|
+
ffi (1.17.3-x64-mingw-ucrt) sha256=5f1d7d067a9a1058ad183dba25b05557cd51c85fc1768c49338eabc1cf242d7c
|
|
172
|
+
ffi (1.17.3-x86_64-darwin) sha256=1f211811eb5cfaa25998322cdd92ab104bfbd26d1c4c08471599c511f2c00bb5
|
|
173
|
+
ffi (1.17.3-x86_64-linux-gnu) sha256=3746b01f677aae7b16dc1acb7cb3cc17b3e35bdae7676a3f568153fb0e2c887f
|
|
174
|
+
fileutils (1.8.0) sha256=8c6b1df54e2540bdb2f39258f08af78853aa70bad52b4d394bbc6424593c6e02
|
|
175
|
+
html-to-markdown (2.29.0)
|
|
176
|
+
i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
|
|
177
|
+
json (2.19.2) sha256=e7e1bd318b2c37c4ceee2444841c86539bc462e81f40d134cf97826cb14e83cf
|
|
178
|
+
json-schema (6.2.0) sha256=e8bff46ed845a22c1ab2bd0d7eccf831c01fe23bb3920caa4c74db4306813666
|
|
179
|
+
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
|
|
180
|
+
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
181
|
+
listen (3.10.0) sha256=c6e182db62143aeccc2e1960033bebe7445309c7272061979bb098d03760c9d2
|
|
182
|
+
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
|
183
|
+
mcp (0.9.0) sha256=a0a3737b0ac9df0772f4ef7e2b013c260ddbcf217a5d50a66bff0baeddf03e47
|
|
184
|
+
minitest (6.0.2) sha256=db6e57956f6ecc6134683b4c87467d6dd792323c7f0eea7b93f66bd284adbc3d
|
|
185
|
+
mutex_m (0.3.0) sha256=cfcb04ac16b69c4813777022fdceda24e9f798e48092a2b817eb4c0a782b0751
|
|
186
|
+
parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
|
|
187
|
+
parser (3.3.10.2) sha256=6f60c84aa4bdcedb6d1a2434b738fe8a8136807b6adc8f7f53b97da9bc4e9357
|
|
188
|
+
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
|
|
189
|
+
public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
|
|
190
|
+
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
191
|
+
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
|
192
|
+
rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
|
|
193
|
+
rake-compiler (1.3.1) sha256=6b351612b6e2d73ddd5563ee799bb58685176e05363db6758504bd11573d670a
|
|
194
|
+
rake-compiler-dock (1.11.0) sha256=eab51f2cd533eb35cea6b624a75281f047123e70a64c58b607471bb49428f8c2
|
|
195
|
+
rb-fsevent (0.11.2) sha256=43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe
|
|
196
|
+
rb-inotify (0.11.1) sha256=a0a700441239b0ff18eb65e3866236cd78613d6b9f78fea1f9ac47a85e47be6e
|
|
197
|
+
rb_sys (0.9.124) sha256=513476557b12eaf73764b3da9f8746024558fe8699bda785fb548c9aa3877ae7
|
|
198
|
+
rbs (3.10.3) sha256=70627f3919016134d554e6c99195552ae3ef6020fe034c8e983facc9c192daa6
|
|
199
|
+
regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
|
|
200
|
+
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
201
|
+
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
202
|
+
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
203
|
+
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
|
|
204
|
+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
205
|
+
rubocop (1.85.1) sha256=3dbcf9e961baa4c376eeeb2a03913dca5e3987033b04d38fa538aa1e7406cc77
|
|
206
|
+
rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035
|
|
207
|
+
rubocop-rspec (3.9.0) sha256=8fa70a3619408237d789aeecfb9beef40576acc855173e60939d63332fdb55e2
|
|
208
|
+
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
|
209
|
+
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
|
|
210
|
+
steep (1.10.0) sha256=1b295b55f9aaff1b8d3ee42453ee55bc2a1078fda0268f288edb2dc014f4d7d1
|
|
211
|
+
strscan (3.1.7) sha256=5f76462b94a3ea50b44973225b7d75b2cb96d4e1bee9ef1319b99ca117b72c8c
|
|
212
|
+
terminal-table (4.0.0) sha256=f504793203f8251b2ea7c7068333053f0beeea26093ec9962e62ea79f94301d2
|
|
213
|
+
tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
|
|
214
|
+
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
|
|
215
|
+
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
|
216
|
+
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
|
217
|
+
uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
|
|
218
|
+
|
|
219
|
+
RUBY VERSION
|
|
220
|
+
ruby 3.4.8
|
|
221
|
+
|
|
222
|
+
BUNDLED WITH
|
|
223
|
+
4.0.3
|
data/README.md
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
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.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
gem install html-to-markdown
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Requires Ruby 3.2+ with Magnus native extension bindings. Published for Linux, macOS.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## Performance Snapshot
|
|
80
|
+
|
|
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 |
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
See [Performance Guide](../../examples/performance/) for detailed benchmarks.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Quick Start
|
|
94
|
+
|
|
95
|
+
Basic conversion:
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
require 'html_to_markdown'
|
|
99
|
+
|
|
100
|
+
html = "<h1>Hello</h1><p>This is <strong>fast</strong>!</p>"
|
|
101
|
+
markdown = HtmlToMarkdown.convert(html)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
With conversion options:
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
require 'html_to_markdown'
|
|
110
|
+
|
|
111
|
+
html = "<h1>Hello</h1><p>This is <strong>fast</strong>!</p>"
|
|
112
|
+
markdown = HtmlToMarkdown.convert(html, heading_style: :atx, code_block_style: :fenced)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
|
|
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
|
+
|
|
185
|
+
|
|
186
|
+
```ruby
|
|
187
|
+
require 'html_to_markdown'
|
|
188
|
+
|
|
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."
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
|
|
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
|
+
|
|
208
|
+
|
|
209
|
+
```ruby
|
|
210
|
+
require 'html_to_markdown'
|
|
211
|
+
|
|
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."
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
|
|
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
|
+
|
|
238
|
+
|
|
239
|
+
```ruby
|
|
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)
|
|
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
|
|
250
|
+
```
|
|
251
|
+
|
|
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
|
+
|
|
274
|
+
|
|
275
|
+
```ruby
|
|
276
|
+
require 'html_to_markdown'
|
|
277
|
+
|
|
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
|
|
292
|
+
|
|
293
|
+
html = '<a href="https://old-cdn.com/file.pdf">Download</a>'
|
|
294
|
+
markdown = HtmlToMarkdown.convert_with_visitor(html, visitor: MyVisitor.new)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
For comprehensive examples including content filtering, link footnotes, accessibility validation, and asynchronous URL validation, see the [Visitor Pattern Guide](../../examples/visitor-pattern/).
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
## Examples
|
|
304
|
+
|
|
305
|
+
- [Visitor Pattern Guide](../../examples/visitor-pattern/)
|
|
306
|
+
- [Metadata Extraction Guide](../../examples/metadata-extraction/)
|
|
307
|
+
- [Performance Guide](../../examples/performance/)
|
|
308
|
+
|
|
309
|
+
## Links
|
|
310
|
+
|
|
311
|
+
- **GitHub:** [github.com/kreuzberg-dev/html-to-markdown](https://github.com/kreuzberg-dev/html-to-markdown)
|
|
312
|
+
|
|
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
|
|
326
|
+
|
|
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
|
|
332
|
+
|
|
333
|
+
## License
|
|
334
|
+
|
|
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
|