html-to-markdown 3.11.6 → 3.12.1
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 +4 -4
- data/ext/html_to_markdown_rb/Cargo.lock +4 -4
- data/ext/html_to_markdown_rb/Cargo.toml +1 -1
- data/ext/html_to_markdown_rb/native/Cargo.lock +14 -14
- data/ext/html_to_markdown_rb/native/Cargo.toml +4 -4
- data/ext/html_to_markdown_rb/src/lib.rs +1710 -634
- data/lib/html_to_markdown/version.rb +2 -2
- metadata +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is auto-generated by alef. DO NOT EDIT.
|
|
2
|
-
// alef:hash:
|
|
2
|
+
// alef:hash:2a25867ec087a834fd64967be75675eaaa818c9513d0dc42ccfdfdf161523deb
|
|
3
3
|
// Re-generate with: alef generate
|
|
4
4
|
#![allow(dead_code, unused_imports, unused_variables)]
|
|
5
5
|
#![allow(
|
|
@@ -148,177 +148,393 @@ impl ConversionOptions {
|
|
|
148
148
|
let (kwargs_opt,) = args.optional;
|
|
149
149
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
150
150
|
Ok(Self {
|
|
151
|
-
heading_style: kwargs
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
151
|
+
heading_style: match kwargs.get(ruby.to_symbol("heading_style")) {
|
|
152
|
+
Some(v) => HeadingStyle::try_convert(v).map_err(|e| {
|
|
153
|
+
magnus::Error::new(
|
|
154
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
155
|
+
format!("invalid value for `heading_style`: {}", e),
|
|
156
|
+
)
|
|
157
|
+
})?,
|
|
158
|
+
None => HeadingStyle::Atx,
|
|
159
|
+
},
|
|
160
|
+
list_indent_type: match kwargs.get(ruby.to_symbol("list_indent_type")) {
|
|
161
|
+
Some(v) => ListIndentType::try_convert(v).map_err(|e| {
|
|
162
|
+
magnus::Error::new(
|
|
163
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
164
|
+
format!("invalid value for `list_indent_type`: {}", e),
|
|
165
|
+
)
|
|
166
|
+
})?,
|
|
167
|
+
None => ListIndentType::Spaces,
|
|
168
|
+
},
|
|
169
|
+
list_indent_width: match kwargs.get(ruby.to_symbol("list_indent_width")) {
|
|
170
|
+
Some(v) => usize::try_convert(v).map_err(|e| {
|
|
171
|
+
magnus::Error::new(
|
|
172
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
173
|
+
format!("invalid value for `list_indent_width`: {}", e),
|
|
174
|
+
)
|
|
175
|
+
})?,
|
|
176
|
+
None => 2,
|
|
177
|
+
},
|
|
178
|
+
bullets: match kwargs.get(ruby.to_symbol("bullets")) {
|
|
179
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
180
|
+
magnus::Error::new(
|
|
181
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
182
|
+
format!("invalid value for `bullets`: {}", e),
|
|
183
|
+
)
|
|
184
|
+
})?,
|
|
185
|
+
None => "-*+".to_string(),
|
|
186
|
+
},
|
|
187
|
+
strong_em_symbol: match kwargs.get(ruby.to_symbol("strong_em_symbol")) {
|
|
188
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
189
|
+
magnus::Error::new(
|
|
190
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
191
|
+
format!("invalid value for `strong_em_symbol`: {}", e),
|
|
192
|
+
)
|
|
193
|
+
})?,
|
|
194
|
+
None => "*".to_string(),
|
|
195
|
+
},
|
|
196
|
+
escape_asterisks: match kwargs.get(ruby.to_symbol("escape_asterisks")) {
|
|
197
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
198
|
+
magnus::Error::new(
|
|
199
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
200
|
+
format!("invalid value for `escape_asterisks`: {}", e),
|
|
201
|
+
)
|
|
202
|
+
})?,
|
|
203
|
+
None => false,
|
|
204
|
+
},
|
|
205
|
+
escape_underscores: match kwargs.get(ruby.to_symbol("escape_underscores")) {
|
|
206
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
207
|
+
magnus::Error::new(
|
|
208
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
209
|
+
format!("invalid value for `escape_underscores`: {}", e),
|
|
210
|
+
)
|
|
211
|
+
})?,
|
|
212
|
+
None => false,
|
|
213
|
+
},
|
|
214
|
+
escape_misc: match kwargs.get(ruby.to_symbol("escape_misc")) {
|
|
215
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
216
|
+
magnus::Error::new(
|
|
217
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
218
|
+
format!("invalid value for `escape_misc`: {}", e),
|
|
219
|
+
)
|
|
220
|
+
})?,
|
|
221
|
+
None => false,
|
|
222
|
+
},
|
|
223
|
+
escape_ascii: match kwargs.get(ruby.to_symbol("escape_ascii")) {
|
|
224
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
225
|
+
magnus::Error::new(
|
|
226
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
227
|
+
format!("invalid value for `escape_ascii`: {}", e),
|
|
228
|
+
)
|
|
229
|
+
})?,
|
|
230
|
+
None => false,
|
|
231
|
+
},
|
|
232
|
+
code_language: match kwargs.get(ruby.to_symbol("code_language")) {
|
|
233
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
234
|
+
magnus::Error::new(
|
|
235
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
236
|
+
format!("invalid value for `code_language`: {}", e),
|
|
237
|
+
)
|
|
238
|
+
})?,
|
|
239
|
+
None => "".to_string(),
|
|
240
|
+
},
|
|
241
|
+
autolinks: match kwargs.get(ruby.to_symbol("autolinks")) {
|
|
242
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
243
|
+
magnus::Error::new(
|
|
244
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
245
|
+
format!("invalid value for `autolinks`: {}", e),
|
|
246
|
+
)
|
|
247
|
+
})?,
|
|
248
|
+
None => true,
|
|
249
|
+
},
|
|
250
|
+
default_title: match kwargs.get(ruby.to_symbol("default_title")) {
|
|
251
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
252
|
+
magnus::Error::new(
|
|
253
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
254
|
+
format!("invalid value for `default_title`: {}", e),
|
|
255
|
+
)
|
|
256
|
+
})?,
|
|
257
|
+
None => false,
|
|
258
|
+
},
|
|
259
|
+
br_in_tables: match kwargs.get(ruby.to_symbol("br_in_tables")) {
|
|
260
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
261
|
+
magnus::Error::new(
|
|
262
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
263
|
+
format!("invalid value for `br_in_tables`: {}", e),
|
|
264
|
+
)
|
|
265
|
+
})?,
|
|
266
|
+
None => false,
|
|
267
|
+
},
|
|
268
|
+
compact_tables: match kwargs.get(ruby.to_symbol("compact_tables")) {
|
|
269
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
270
|
+
magnus::Error::new(
|
|
271
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
272
|
+
format!("invalid value for `compact_tables`: {}", e),
|
|
273
|
+
)
|
|
274
|
+
})?,
|
|
275
|
+
None => false,
|
|
276
|
+
},
|
|
277
|
+
highlight_style: match kwargs.get(ruby.to_symbol("highlight_style")) {
|
|
278
|
+
Some(v) => HighlightStyle::try_convert(v).map_err(|e| {
|
|
279
|
+
magnus::Error::new(
|
|
280
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
281
|
+
format!("invalid value for `highlight_style`: {}", e),
|
|
282
|
+
)
|
|
283
|
+
})?,
|
|
284
|
+
None => HighlightStyle::DoubleEqual,
|
|
285
|
+
},
|
|
286
|
+
extract_metadata: match kwargs.get(ruby.to_symbol("extract_metadata")) {
|
|
287
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
288
|
+
magnus::Error::new(
|
|
289
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
290
|
+
format!("invalid value for `extract_metadata`: {}", e),
|
|
291
|
+
)
|
|
292
|
+
})?,
|
|
293
|
+
None => true,
|
|
294
|
+
},
|
|
295
|
+
whitespace_mode: match kwargs.get(ruby.to_symbol("whitespace_mode")) {
|
|
296
|
+
Some(v) => WhitespaceMode::try_convert(v).map_err(|e| {
|
|
297
|
+
magnus::Error::new(
|
|
298
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
299
|
+
format!("invalid value for `whitespace_mode`: {}", e),
|
|
300
|
+
)
|
|
301
|
+
})?,
|
|
302
|
+
None => WhitespaceMode::Normalized,
|
|
303
|
+
},
|
|
304
|
+
strip_newlines: match kwargs.get(ruby.to_symbol("strip_newlines")) {
|
|
305
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
306
|
+
magnus::Error::new(
|
|
307
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
308
|
+
format!("invalid value for `strip_newlines`: {}", e),
|
|
309
|
+
)
|
|
310
|
+
})?,
|
|
311
|
+
None => false,
|
|
312
|
+
},
|
|
313
|
+
wrap: match kwargs.get(ruby.to_symbol("wrap")) {
|
|
314
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
315
|
+
magnus::Error::new(
|
|
316
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
317
|
+
format!("invalid value for `wrap`: {}", e),
|
|
318
|
+
)
|
|
319
|
+
})?,
|
|
320
|
+
None => false,
|
|
321
|
+
},
|
|
322
|
+
wrap_width: match kwargs.get(ruby.to_symbol("wrap_width")) {
|
|
323
|
+
Some(v) => usize::try_convert(v).map_err(|e| {
|
|
324
|
+
magnus::Error::new(
|
|
325
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
326
|
+
format!("invalid value for `wrap_width`: {}", e),
|
|
327
|
+
)
|
|
328
|
+
})?,
|
|
329
|
+
None => 80,
|
|
330
|
+
},
|
|
331
|
+
convert_as_inline: match kwargs.get(ruby.to_symbol("convert_as_inline")) {
|
|
332
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
333
|
+
magnus::Error::new(
|
|
334
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
335
|
+
format!("invalid value for `convert_as_inline`: {}", e),
|
|
336
|
+
)
|
|
337
|
+
})?,
|
|
338
|
+
None => false,
|
|
339
|
+
},
|
|
340
|
+
sub_symbol: match kwargs.get(ruby.to_symbol("sub_symbol")) {
|
|
341
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
342
|
+
magnus::Error::new(
|
|
343
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
344
|
+
format!("invalid value for `sub_symbol`: {}", e),
|
|
345
|
+
)
|
|
346
|
+
})?,
|
|
347
|
+
None => "".to_string(),
|
|
348
|
+
},
|
|
349
|
+
sup_symbol: match kwargs.get(ruby.to_symbol("sup_symbol")) {
|
|
350
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
351
|
+
magnus::Error::new(
|
|
352
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
353
|
+
format!("invalid value for `sup_symbol`: {}", e),
|
|
354
|
+
)
|
|
355
|
+
})?,
|
|
356
|
+
None => "".to_string(),
|
|
357
|
+
},
|
|
358
|
+
newline_style: match kwargs.get(ruby.to_symbol("newline_style")) {
|
|
359
|
+
Some(v) => NewlineStyle::try_convert(v).map_err(|e| {
|
|
360
|
+
magnus::Error::new(
|
|
361
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
362
|
+
format!("invalid value for `newline_style`: {}", e),
|
|
363
|
+
)
|
|
364
|
+
})?,
|
|
365
|
+
None => NewlineStyle::Spaces,
|
|
366
|
+
},
|
|
367
|
+
code_block_style: match kwargs.get(ruby.to_symbol("code_block_style")) {
|
|
368
|
+
Some(v) => CodeBlockStyle::try_convert(v).map_err(|e| {
|
|
369
|
+
magnus::Error::new(
|
|
370
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
371
|
+
format!("invalid value for `code_block_style`: {}", e),
|
|
372
|
+
)
|
|
373
|
+
})?,
|
|
374
|
+
None => CodeBlockStyle::Backticks,
|
|
375
|
+
},
|
|
376
|
+
keep_inline_images_in: match kwargs.get(ruby.to_symbol("keep_inline_images_in")) {
|
|
377
|
+
Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
|
|
378
|
+
magnus::Error::new(
|
|
379
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
380
|
+
format!("invalid value for `keep_inline_images_in`: {}", e),
|
|
381
|
+
)
|
|
382
|
+
})?,
|
|
383
|
+
None => Default::default(),
|
|
384
|
+
},
|
|
385
|
+
preprocessing: match kwargs.get(ruby.to_symbol("preprocessing")) {
|
|
386
|
+
Some(v) => PreprocessingOptions::try_convert(v).map_err(|e| {
|
|
387
|
+
magnus::Error::new(
|
|
388
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
389
|
+
format!("invalid value for `preprocessing`: {}", e),
|
|
390
|
+
)
|
|
391
|
+
})?,
|
|
392
|
+
None => Default::default(),
|
|
393
|
+
},
|
|
394
|
+
encoding: match kwargs.get(ruby.to_symbol("encoding")) {
|
|
395
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
396
|
+
magnus::Error::new(
|
|
397
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
398
|
+
format!("invalid value for `encoding`: {}", e),
|
|
399
|
+
)
|
|
400
|
+
})?,
|
|
401
|
+
None => "utf-8".to_string(),
|
|
402
|
+
},
|
|
403
|
+
debug: match kwargs.get(ruby.to_symbol("debug")) {
|
|
404
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
405
|
+
magnus::Error::new(
|
|
406
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
407
|
+
format!("invalid value for `debug`: {}", e),
|
|
408
|
+
)
|
|
409
|
+
})?,
|
|
410
|
+
None => false,
|
|
411
|
+
},
|
|
412
|
+
strip_tags: match kwargs.get(ruby.to_symbol("strip_tags")) {
|
|
413
|
+
Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
|
|
414
|
+
magnus::Error::new(
|
|
415
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
416
|
+
format!("invalid value for `strip_tags`: {}", e),
|
|
417
|
+
)
|
|
418
|
+
})?,
|
|
419
|
+
None => Default::default(),
|
|
420
|
+
},
|
|
421
|
+
preserve_tags: match kwargs.get(ruby.to_symbol("preserve_tags")) {
|
|
422
|
+
Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
|
|
423
|
+
magnus::Error::new(
|
|
424
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
425
|
+
format!("invalid value for `preserve_tags`: {}", e),
|
|
426
|
+
)
|
|
427
|
+
})?,
|
|
428
|
+
None => Default::default(),
|
|
429
|
+
},
|
|
430
|
+
skip_images: match kwargs.get(ruby.to_symbol("skip_images")) {
|
|
431
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
432
|
+
magnus::Error::new(
|
|
433
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
434
|
+
format!("invalid value for `skip_images`: {}", e),
|
|
435
|
+
)
|
|
436
|
+
})?,
|
|
437
|
+
None => false,
|
|
438
|
+
},
|
|
439
|
+
url_escape_style: match kwargs.get(ruby.to_symbol("url_escape_style")) {
|
|
440
|
+
Some(v) => UrlEscapeStyle::try_convert(v).map_err(|e| {
|
|
441
|
+
magnus::Error::new(
|
|
442
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
443
|
+
format!("invalid value for `url_escape_style`: {}", e),
|
|
444
|
+
)
|
|
445
|
+
})?,
|
|
446
|
+
None => UrlEscapeStyle::Angle,
|
|
447
|
+
},
|
|
448
|
+
link_style: match kwargs.get(ruby.to_symbol("link_style")) {
|
|
449
|
+
Some(v) => LinkStyle::try_convert(v).map_err(|e| {
|
|
450
|
+
magnus::Error::new(
|
|
451
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
452
|
+
format!("invalid value for `link_style`: {}", e),
|
|
453
|
+
)
|
|
454
|
+
})?,
|
|
455
|
+
None => LinkStyle::Inline,
|
|
456
|
+
},
|
|
457
|
+
output_format: match kwargs.get(ruby.to_symbol("output_format")) {
|
|
458
|
+
Some(v) => OutputFormat::try_convert(v).map_err(|e| {
|
|
459
|
+
magnus::Error::new(
|
|
460
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
461
|
+
format!("invalid value for `output_format`: {}", e),
|
|
462
|
+
)
|
|
463
|
+
})?,
|
|
464
|
+
None => OutputFormat::Markdown,
|
|
465
|
+
},
|
|
466
|
+
include_document_structure: match kwargs.get(ruby.to_symbol("include_document_structure")) {
|
|
467
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
468
|
+
magnus::Error::new(
|
|
469
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
470
|
+
format!("invalid value for `include_document_structure`: {}", e),
|
|
471
|
+
)
|
|
472
|
+
})?,
|
|
473
|
+
None => false,
|
|
474
|
+
},
|
|
475
|
+
extract_images: match kwargs.get(ruby.to_symbol("extract_images")) {
|
|
476
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
477
|
+
magnus::Error::new(
|
|
478
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
479
|
+
format!("invalid value for `extract_images`: {}", e),
|
|
480
|
+
)
|
|
481
|
+
})?,
|
|
482
|
+
None => false,
|
|
483
|
+
},
|
|
484
|
+
max_image_size: match kwargs.get(ruby.to_symbol("max_image_size")) {
|
|
485
|
+
Some(v) => u64::try_convert(v).map_err(|e| {
|
|
486
|
+
magnus::Error::new(
|
|
487
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
488
|
+
format!("invalid value for `max_image_size`: {}", e),
|
|
489
|
+
)
|
|
490
|
+
})?,
|
|
491
|
+
None => 5242880,
|
|
492
|
+
},
|
|
493
|
+
capture_svg: match kwargs.get(ruby.to_symbol("capture_svg")) {
|
|
494
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
495
|
+
magnus::Error::new(
|
|
496
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
497
|
+
format!("invalid value for `capture_svg`: {}", e),
|
|
498
|
+
)
|
|
499
|
+
})?,
|
|
500
|
+
None => false,
|
|
501
|
+
},
|
|
502
|
+
infer_dimensions: match kwargs.get(ruby.to_symbol("infer_dimensions")) {
|
|
503
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
504
|
+
magnus::Error::new(
|
|
505
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
506
|
+
format!("invalid value for `infer_dimensions`: {}", e),
|
|
507
|
+
)
|
|
508
|
+
})?,
|
|
509
|
+
None => true,
|
|
510
|
+
},
|
|
511
|
+
max_depth: match kwargs.get(ruby.to_symbol("max_depth")) {
|
|
512
|
+
Some(v) => Some(usize::try_convert(v).map_err(|e| {
|
|
513
|
+
magnus::Error::new(
|
|
514
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
515
|
+
format!("invalid value for `max_depth`: {}", e),
|
|
516
|
+
)
|
|
517
|
+
})?),
|
|
518
|
+
None => None,
|
|
519
|
+
},
|
|
520
|
+
exclude_selectors: match kwargs.get(ruby.to_symbol("exclude_selectors")) {
|
|
521
|
+
Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
|
|
522
|
+
magnus::Error::new(
|
|
523
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
524
|
+
format!("invalid value for `exclude_selectors`: {}", e),
|
|
525
|
+
)
|
|
526
|
+
})?,
|
|
527
|
+
None => Default::default(),
|
|
528
|
+
},
|
|
529
|
+
tier_strategy: match kwargs.get(ruby.to_symbol("tier_strategy")) {
|
|
530
|
+
Some(v) => TierStrategy::try_convert(v).map_err(|e| {
|
|
531
|
+
magnus::Error::new(
|
|
532
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
533
|
+
format!("invalid value for `tier_strategy`: {}", e),
|
|
534
|
+
)
|
|
535
|
+
})?,
|
|
536
|
+
None => TierStrategy::Auto,
|
|
537
|
+
},
|
|
322
538
|
})
|
|
323
539
|
}
|
|
324
540
|
|
|
@@ -585,135 +801,393 @@ impl ConversionOptionsUpdate {
|
|
|
585
801
|
let (kwargs_opt,) = args.optional;
|
|
586
802
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
587
803
|
Ok(Self {
|
|
588
|
-
heading_style: kwargs
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
804
|
+
heading_style: match kwargs.get(ruby.to_symbol("heading_style")) {
|
|
805
|
+
Some(v) => Some(HeadingStyle::try_convert(v).map_err(|e| {
|
|
806
|
+
magnus::Error::new(
|
|
807
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
808
|
+
format!("invalid value for `heading_style`: {}", e),
|
|
809
|
+
)
|
|
810
|
+
})?),
|
|
811
|
+
None => None,
|
|
812
|
+
},
|
|
813
|
+
list_indent_type: match kwargs.get(ruby.to_symbol("list_indent_type")) {
|
|
814
|
+
Some(v) => Some(ListIndentType::try_convert(v).map_err(|e| {
|
|
815
|
+
magnus::Error::new(
|
|
816
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
817
|
+
format!("invalid value for `list_indent_type`: {}", e),
|
|
818
|
+
)
|
|
819
|
+
})?),
|
|
820
|
+
None => None,
|
|
821
|
+
},
|
|
822
|
+
list_indent_width: match kwargs.get(ruby.to_symbol("list_indent_width")) {
|
|
823
|
+
Some(v) => Some(usize::try_convert(v).map_err(|e| {
|
|
824
|
+
magnus::Error::new(
|
|
825
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
826
|
+
format!("invalid value for `list_indent_width`: {}", e),
|
|
827
|
+
)
|
|
828
|
+
})?),
|
|
829
|
+
None => None,
|
|
830
|
+
},
|
|
831
|
+
bullets: match kwargs.get(ruby.to_symbol("bullets")) {
|
|
832
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
833
|
+
magnus::Error::new(
|
|
834
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
835
|
+
format!("invalid value for `bullets`: {}", e),
|
|
836
|
+
)
|
|
837
|
+
})?),
|
|
838
|
+
None => None,
|
|
839
|
+
},
|
|
840
|
+
strong_em_symbol: match kwargs.get(ruby.to_symbol("strong_em_symbol")) {
|
|
841
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
842
|
+
magnus::Error::new(
|
|
843
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
844
|
+
format!("invalid value for `strong_em_symbol`: {}", e),
|
|
845
|
+
)
|
|
846
|
+
})?),
|
|
847
|
+
None => None,
|
|
848
|
+
},
|
|
849
|
+
escape_asterisks: match kwargs.get(ruby.to_symbol("escape_asterisks")) {
|
|
850
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
851
|
+
magnus::Error::new(
|
|
852
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
853
|
+
format!("invalid value for `escape_asterisks`: {}", e),
|
|
854
|
+
)
|
|
855
|
+
})?),
|
|
856
|
+
None => None,
|
|
857
|
+
},
|
|
858
|
+
escape_underscores: match kwargs.get(ruby.to_symbol("escape_underscores")) {
|
|
859
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
860
|
+
magnus::Error::new(
|
|
861
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
862
|
+
format!("invalid value for `escape_underscores`: {}", e),
|
|
863
|
+
)
|
|
864
|
+
})?),
|
|
865
|
+
None => None,
|
|
866
|
+
},
|
|
867
|
+
escape_misc: match kwargs.get(ruby.to_symbol("escape_misc")) {
|
|
868
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
869
|
+
magnus::Error::new(
|
|
870
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
871
|
+
format!("invalid value for `escape_misc`: {}", e),
|
|
872
|
+
)
|
|
873
|
+
})?),
|
|
874
|
+
None => None,
|
|
875
|
+
},
|
|
876
|
+
escape_ascii: match kwargs.get(ruby.to_symbol("escape_ascii")) {
|
|
877
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
878
|
+
magnus::Error::new(
|
|
879
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
880
|
+
format!("invalid value for `escape_ascii`: {}", e),
|
|
881
|
+
)
|
|
882
|
+
})?),
|
|
883
|
+
None => None,
|
|
884
|
+
},
|
|
885
|
+
code_language: match kwargs.get(ruby.to_symbol("code_language")) {
|
|
886
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
887
|
+
magnus::Error::new(
|
|
888
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
889
|
+
format!("invalid value for `code_language`: {}", e),
|
|
890
|
+
)
|
|
891
|
+
})?),
|
|
892
|
+
None => None,
|
|
893
|
+
},
|
|
894
|
+
autolinks: match kwargs.get(ruby.to_symbol("autolinks")) {
|
|
895
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
896
|
+
magnus::Error::new(
|
|
897
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
898
|
+
format!("invalid value for `autolinks`: {}", e),
|
|
899
|
+
)
|
|
900
|
+
})?),
|
|
901
|
+
None => None,
|
|
902
|
+
},
|
|
903
|
+
default_title: match kwargs.get(ruby.to_symbol("default_title")) {
|
|
904
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
905
|
+
magnus::Error::new(
|
|
906
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
907
|
+
format!("invalid value for `default_title`: {}", e),
|
|
908
|
+
)
|
|
909
|
+
})?),
|
|
910
|
+
None => None,
|
|
911
|
+
},
|
|
912
|
+
br_in_tables: match kwargs.get(ruby.to_symbol("br_in_tables")) {
|
|
913
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
914
|
+
magnus::Error::new(
|
|
915
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
916
|
+
format!("invalid value for `br_in_tables`: {}", e),
|
|
917
|
+
)
|
|
918
|
+
})?),
|
|
919
|
+
None => None,
|
|
920
|
+
},
|
|
921
|
+
compact_tables: match kwargs.get(ruby.to_symbol("compact_tables")) {
|
|
922
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
923
|
+
magnus::Error::new(
|
|
924
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
925
|
+
format!("invalid value for `compact_tables`: {}", e),
|
|
926
|
+
)
|
|
927
|
+
})?),
|
|
928
|
+
None => None,
|
|
929
|
+
},
|
|
930
|
+
highlight_style: match kwargs.get(ruby.to_symbol("highlight_style")) {
|
|
931
|
+
Some(v) => Some(HighlightStyle::try_convert(v).map_err(|e| {
|
|
932
|
+
magnus::Error::new(
|
|
933
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
934
|
+
format!("invalid value for `highlight_style`: {}", e),
|
|
935
|
+
)
|
|
936
|
+
})?),
|
|
937
|
+
None => None,
|
|
938
|
+
},
|
|
939
|
+
extract_metadata: match kwargs.get(ruby.to_symbol("extract_metadata")) {
|
|
940
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
941
|
+
magnus::Error::new(
|
|
942
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
943
|
+
format!("invalid value for `extract_metadata`: {}", e),
|
|
944
|
+
)
|
|
945
|
+
})?),
|
|
946
|
+
None => None,
|
|
947
|
+
},
|
|
948
|
+
whitespace_mode: match kwargs.get(ruby.to_symbol("whitespace_mode")) {
|
|
949
|
+
Some(v) => Some(WhitespaceMode::try_convert(v).map_err(|e| {
|
|
950
|
+
magnus::Error::new(
|
|
951
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
952
|
+
format!("invalid value for `whitespace_mode`: {}", e),
|
|
953
|
+
)
|
|
954
|
+
})?),
|
|
955
|
+
None => None,
|
|
956
|
+
},
|
|
957
|
+
strip_newlines: match kwargs.get(ruby.to_symbol("strip_newlines")) {
|
|
958
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
959
|
+
magnus::Error::new(
|
|
960
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
961
|
+
format!("invalid value for `strip_newlines`: {}", e),
|
|
962
|
+
)
|
|
963
|
+
})?),
|
|
964
|
+
None => None,
|
|
965
|
+
},
|
|
966
|
+
wrap: match kwargs.get(ruby.to_symbol("wrap")) {
|
|
967
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
968
|
+
magnus::Error::new(
|
|
969
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
970
|
+
format!("invalid value for `wrap`: {}", e),
|
|
971
|
+
)
|
|
972
|
+
})?),
|
|
973
|
+
None => None,
|
|
974
|
+
},
|
|
975
|
+
wrap_width: match kwargs.get(ruby.to_symbol("wrap_width")) {
|
|
976
|
+
Some(v) => Some(usize::try_convert(v).map_err(|e| {
|
|
977
|
+
magnus::Error::new(
|
|
978
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
979
|
+
format!("invalid value for `wrap_width`: {}", e),
|
|
980
|
+
)
|
|
981
|
+
})?),
|
|
982
|
+
None => None,
|
|
983
|
+
},
|
|
984
|
+
convert_as_inline: match kwargs.get(ruby.to_symbol("convert_as_inline")) {
|
|
985
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
986
|
+
magnus::Error::new(
|
|
987
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
988
|
+
format!("invalid value for `convert_as_inline`: {}", e),
|
|
989
|
+
)
|
|
990
|
+
})?),
|
|
991
|
+
None => None,
|
|
992
|
+
},
|
|
993
|
+
sub_symbol: match kwargs.get(ruby.to_symbol("sub_symbol")) {
|
|
994
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
995
|
+
magnus::Error::new(
|
|
996
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
997
|
+
format!("invalid value for `sub_symbol`: {}", e),
|
|
998
|
+
)
|
|
999
|
+
})?),
|
|
1000
|
+
None => None,
|
|
1001
|
+
},
|
|
1002
|
+
sup_symbol: match kwargs.get(ruby.to_symbol("sup_symbol")) {
|
|
1003
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1004
|
+
magnus::Error::new(
|
|
1005
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1006
|
+
format!("invalid value for `sup_symbol`: {}", e),
|
|
1007
|
+
)
|
|
1008
|
+
})?),
|
|
1009
|
+
None => None,
|
|
1010
|
+
},
|
|
1011
|
+
newline_style: match kwargs.get(ruby.to_symbol("newline_style")) {
|
|
1012
|
+
Some(v) => Some(NewlineStyle::try_convert(v).map_err(|e| {
|
|
1013
|
+
magnus::Error::new(
|
|
1014
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1015
|
+
format!("invalid value for `newline_style`: {}", e),
|
|
1016
|
+
)
|
|
1017
|
+
})?),
|
|
1018
|
+
None => None,
|
|
1019
|
+
},
|
|
1020
|
+
code_block_style: match kwargs.get(ruby.to_symbol("code_block_style")) {
|
|
1021
|
+
Some(v) => Some(CodeBlockStyle::try_convert(v).map_err(|e| {
|
|
1022
|
+
magnus::Error::new(
|
|
1023
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1024
|
+
format!("invalid value for `code_block_style`: {}", e),
|
|
1025
|
+
)
|
|
1026
|
+
})?),
|
|
1027
|
+
None => None,
|
|
1028
|
+
},
|
|
1029
|
+
keep_inline_images_in: match kwargs.get(ruby.to_symbol("keep_inline_images_in")) {
|
|
1030
|
+
Some(v) => Some(<Vec<String>>::try_convert(v).map_err(|e| {
|
|
1031
|
+
magnus::Error::new(
|
|
1032
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1033
|
+
format!("invalid value for `keep_inline_images_in`: {}", e),
|
|
1034
|
+
)
|
|
1035
|
+
})?),
|
|
1036
|
+
None => None,
|
|
1037
|
+
},
|
|
1038
|
+
preprocessing: match kwargs.get(ruby.to_symbol("preprocessing")) {
|
|
1039
|
+
Some(v) => Some(PreprocessingOptionsUpdate::try_convert(v).map_err(|e| {
|
|
1040
|
+
magnus::Error::new(
|
|
1041
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1042
|
+
format!("invalid value for `preprocessing`: {}", e),
|
|
1043
|
+
)
|
|
1044
|
+
})?),
|
|
1045
|
+
None => None,
|
|
1046
|
+
},
|
|
1047
|
+
encoding: match kwargs.get(ruby.to_symbol("encoding")) {
|
|
1048
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1049
|
+
magnus::Error::new(
|
|
1050
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1051
|
+
format!("invalid value for `encoding`: {}", e),
|
|
1052
|
+
)
|
|
1053
|
+
})?),
|
|
1054
|
+
None => None,
|
|
1055
|
+
},
|
|
1056
|
+
debug: match kwargs.get(ruby.to_symbol("debug")) {
|
|
1057
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
1058
|
+
magnus::Error::new(
|
|
1059
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1060
|
+
format!("invalid value for `debug`: {}", e),
|
|
1061
|
+
)
|
|
1062
|
+
})?),
|
|
1063
|
+
None => None,
|
|
1064
|
+
},
|
|
1065
|
+
strip_tags: match kwargs.get(ruby.to_symbol("strip_tags")) {
|
|
1066
|
+
Some(v) => Some(<Vec<String>>::try_convert(v).map_err(|e| {
|
|
1067
|
+
magnus::Error::new(
|
|
1068
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1069
|
+
format!("invalid value for `strip_tags`: {}", e),
|
|
1070
|
+
)
|
|
1071
|
+
})?),
|
|
1072
|
+
None => None,
|
|
1073
|
+
},
|
|
1074
|
+
preserve_tags: match kwargs.get(ruby.to_symbol("preserve_tags")) {
|
|
1075
|
+
Some(v) => Some(<Vec<String>>::try_convert(v).map_err(|e| {
|
|
1076
|
+
magnus::Error::new(
|
|
1077
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1078
|
+
format!("invalid value for `preserve_tags`: {}", e),
|
|
1079
|
+
)
|
|
1080
|
+
})?),
|
|
1081
|
+
None => None,
|
|
1082
|
+
},
|
|
1083
|
+
skip_images: match kwargs.get(ruby.to_symbol("skip_images")) {
|
|
1084
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
1085
|
+
magnus::Error::new(
|
|
1086
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1087
|
+
format!("invalid value for `skip_images`: {}", e),
|
|
1088
|
+
)
|
|
1089
|
+
})?),
|
|
1090
|
+
None => None,
|
|
1091
|
+
},
|
|
1092
|
+
url_escape_style: match kwargs.get(ruby.to_symbol("url_escape_style")) {
|
|
1093
|
+
Some(v) => Some(UrlEscapeStyle::try_convert(v).map_err(|e| {
|
|
1094
|
+
magnus::Error::new(
|
|
1095
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1096
|
+
format!("invalid value for `url_escape_style`: {}", e),
|
|
1097
|
+
)
|
|
1098
|
+
})?),
|
|
1099
|
+
None => None,
|
|
1100
|
+
},
|
|
1101
|
+
link_style: match kwargs.get(ruby.to_symbol("link_style")) {
|
|
1102
|
+
Some(v) => Some(LinkStyle::try_convert(v).map_err(|e| {
|
|
1103
|
+
magnus::Error::new(
|
|
1104
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1105
|
+
format!("invalid value for `link_style`: {}", e),
|
|
1106
|
+
)
|
|
1107
|
+
})?),
|
|
1108
|
+
None => None,
|
|
1109
|
+
},
|
|
1110
|
+
output_format: match kwargs.get(ruby.to_symbol("output_format")) {
|
|
1111
|
+
Some(v) => Some(OutputFormat::try_convert(v).map_err(|e| {
|
|
1112
|
+
magnus::Error::new(
|
|
1113
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1114
|
+
format!("invalid value for `output_format`: {}", e),
|
|
1115
|
+
)
|
|
1116
|
+
})?),
|
|
1117
|
+
None => None,
|
|
1118
|
+
},
|
|
1119
|
+
include_document_structure: match kwargs.get(ruby.to_symbol("include_document_structure")) {
|
|
1120
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
1121
|
+
magnus::Error::new(
|
|
1122
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1123
|
+
format!("invalid value for `include_document_structure`: {}", e),
|
|
1124
|
+
)
|
|
1125
|
+
})?),
|
|
1126
|
+
None => None,
|
|
1127
|
+
},
|
|
1128
|
+
extract_images: match kwargs.get(ruby.to_symbol("extract_images")) {
|
|
1129
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
1130
|
+
magnus::Error::new(
|
|
1131
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1132
|
+
format!("invalid value for `extract_images`: {}", e),
|
|
1133
|
+
)
|
|
1134
|
+
})?),
|
|
1135
|
+
None => None,
|
|
1136
|
+
},
|
|
1137
|
+
max_image_size: match kwargs.get(ruby.to_symbol("max_image_size")) {
|
|
1138
|
+
Some(v) => Some(u64::try_convert(v).map_err(|e| {
|
|
1139
|
+
magnus::Error::new(
|
|
1140
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1141
|
+
format!("invalid value for `max_image_size`: {}", e),
|
|
1142
|
+
)
|
|
1143
|
+
})?),
|
|
1144
|
+
None => None,
|
|
1145
|
+
},
|
|
1146
|
+
capture_svg: match kwargs.get(ruby.to_symbol("capture_svg")) {
|
|
1147
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
1148
|
+
magnus::Error::new(
|
|
1149
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1150
|
+
format!("invalid value for `capture_svg`: {}", e),
|
|
1151
|
+
)
|
|
1152
|
+
})?),
|
|
1153
|
+
None => None,
|
|
1154
|
+
},
|
|
1155
|
+
infer_dimensions: match kwargs.get(ruby.to_symbol("infer_dimensions")) {
|
|
1156
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
1157
|
+
magnus::Error::new(
|
|
1158
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1159
|
+
format!("invalid value for `infer_dimensions`: {}", e),
|
|
1160
|
+
)
|
|
1161
|
+
})?),
|
|
1162
|
+
None => None,
|
|
1163
|
+
},
|
|
1164
|
+
max_depth: match kwargs.get(ruby.to_symbol("max_depth")) {
|
|
1165
|
+
Some(v) => Some(usize::try_convert(v).map_err(|e| {
|
|
1166
|
+
magnus::Error::new(
|
|
1167
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1168
|
+
format!("invalid value for `max_depth`: {}", e),
|
|
1169
|
+
)
|
|
1170
|
+
})?),
|
|
1171
|
+
None => None,
|
|
1172
|
+
},
|
|
1173
|
+
exclude_selectors: match kwargs.get(ruby.to_symbol("exclude_selectors")) {
|
|
1174
|
+
Some(v) => Some(<Vec<String>>::try_convert(v).map_err(|e| {
|
|
1175
|
+
magnus::Error::new(
|
|
1176
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1177
|
+
format!("invalid value for `exclude_selectors`: {}", e),
|
|
1178
|
+
)
|
|
1179
|
+
})?),
|
|
1180
|
+
None => None,
|
|
1181
|
+
},
|
|
1182
|
+
tier_strategy: match kwargs.get(ruby.to_symbol("tier_strategy")) {
|
|
1183
|
+
Some(v) => Some(TierStrategy::try_convert(v).map_err(|e| {
|
|
1184
|
+
magnus::Error::new(
|
|
1185
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1186
|
+
format!("invalid value for `tier_strategy`: {}", e),
|
|
1187
|
+
)
|
|
1188
|
+
})?),
|
|
1189
|
+
None => None,
|
|
1190
|
+
},
|
|
717
1191
|
})
|
|
718
1192
|
}
|
|
719
1193
|
|
|
@@ -896,6 +1370,7 @@ impl ConversionOptionsUpdate {
|
|
|
896
1370
|
pub struct ConversionResult {
|
|
897
1371
|
content: Option<String>,
|
|
898
1372
|
document: Option<DocumentStructure>,
|
|
1373
|
+
#[cfg(feature = "metadata")]
|
|
899
1374
|
metadata: HtmlMetadata,
|
|
900
1375
|
tables: Vec<TableData>,
|
|
901
1376
|
warnings: Vec<ProcessingWarning>,
|
|
@@ -942,24 +1417,52 @@ impl ConversionResult {
|
|
|
942
1417
|
let (kwargs_opt,) = args.optional;
|
|
943
1418
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
944
1419
|
Ok(Self {
|
|
945
|
-
content: kwargs
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1420
|
+
content: match kwargs.get(ruby.to_symbol("content")) {
|
|
1421
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1422
|
+
magnus::Error::new(
|
|
1423
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1424
|
+
format!("invalid value for `content`: {}", e),
|
|
1425
|
+
)
|
|
1426
|
+
})?),
|
|
1427
|
+
None => None,
|
|
1428
|
+
},
|
|
1429
|
+
document: match kwargs.get(ruby.to_symbol("document")) {
|
|
1430
|
+
Some(v) => Some(DocumentStructure::try_convert(v).map_err(|e| {
|
|
1431
|
+
magnus::Error::new(
|
|
1432
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1433
|
+
format!("invalid value for `document`: {}", e),
|
|
1434
|
+
)
|
|
1435
|
+
})?),
|
|
1436
|
+
None => None,
|
|
1437
|
+
},
|
|
1438
|
+
#[cfg(feature = "metadata")]
|
|
1439
|
+
metadata: match kwargs.get(ruby.to_symbol("metadata")) {
|
|
1440
|
+
Some(v) => HtmlMetadata::try_convert(v).map_err(|e| {
|
|
1441
|
+
magnus::Error::new(
|
|
1442
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1443
|
+
format!("invalid value for `metadata`: {}", e),
|
|
1444
|
+
)
|
|
1445
|
+
})?,
|
|
1446
|
+
None => Default::default(),
|
|
1447
|
+
},
|
|
1448
|
+
tables: match kwargs.get(ruby.to_symbol("tables")) {
|
|
1449
|
+
Some(v) => <Vec<TableData>>::try_convert(v).map_err(|e| {
|
|
1450
|
+
magnus::Error::new(
|
|
1451
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1452
|
+
format!("invalid value for `tables`: {}", e),
|
|
1453
|
+
)
|
|
1454
|
+
})?,
|
|
1455
|
+
None => Default::default(),
|
|
1456
|
+
},
|
|
1457
|
+
warnings: match kwargs.get(ruby.to_symbol("warnings")) {
|
|
1458
|
+
Some(v) => <Vec<ProcessingWarning>>::try_convert(v).map_err(|e| {
|
|
1459
|
+
magnus::Error::new(
|
|
1460
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1461
|
+
format!("invalid value for `warnings`: {}", e),
|
|
1462
|
+
)
|
|
1463
|
+
})?,
|
|
1464
|
+
None => Default::default(),
|
|
1465
|
+
},
|
|
963
1466
|
})
|
|
964
1467
|
}
|
|
965
1468
|
|
|
@@ -971,6 +1474,7 @@ impl ConversionResult {
|
|
|
971
1474
|
self.document.clone()
|
|
972
1475
|
}
|
|
973
1476
|
|
|
1477
|
+
#[cfg(feature = "metadata")]
|
|
974
1478
|
fn metadata(&self) -> HtmlMetadata {
|
|
975
1479
|
self.metadata.clone()
|
|
976
1480
|
}
|
|
@@ -989,6 +1493,7 @@ impl ConversionResult {
|
|
|
989
1493
|
}
|
|
990
1494
|
}
|
|
991
1495
|
|
|
1496
|
+
#[cfg(feature = "metadata")]
|
|
992
1497
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
993
1498
|
#[serde(default)]
|
|
994
1499
|
#[magnus::wrap(class = "HtmlToMarkdownRs::DocumentMetadata")]
|
|
@@ -1006,8 +1511,10 @@ pub struct DocumentMetadata {
|
|
|
1006
1511
|
meta_tags: HashMap<String, String>,
|
|
1007
1512
|
}
|
|
1008
1513
|
|
|
1514
|
+
#[cfg(feature = "metadata")]
|
|
1009
1515
|
unsafe impl IntoValueFromNative for DocumentMetadata {}
|
|
1010
1516
|
|
|
1517
|
+
#[cfg(feature = "metadata")]
|
|
1011
1518
|
impl magnus::TryConvert for DocumentMetadata {
|
|
1012
1519
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
1013
1520
|
if let Ok(r) = <&DocumentMetadata as magnus::TryConvert>::try_convert(val) {
|
|
@@ -1032,14 +1539,17 @@ impl magnus::TryConvert for DocumentMetadata {
|
|
|
1032
1539
|
}
|
|
1033
1540
|
}
|
|
1034
1541
|
|
|
1542
|
+
#[cfg(feature = "metadata")]
|
|
1035
1543
|
unsafe impl TryConvertOwned for DocumentMetadata {}
|
|
1036
1544
|
|
|
1545
|
+
#[cfg(feature = "metadata")]
|
|
1037
1546
|
impl Default for DocumentMetadata {
|
|
1038
1547
|
fn default() -> Self {
|
|
1039
1548
|
html_to_markdown_rs::metadata::DocumentMetadata::default().into()
|
|
1040
1549
|
}
|
|
1041
1550
|
}
|
|
1042
1551
|
|
|
1552
|
+
#[cfg(feature = "metadata")]
|
|
1043
1553
|
impl DocumentMetadata {
|
|
1044
1554
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1045
1555
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1047,43 +1557,105 @@ impl DocumentMetadata {
|
|
|
1047
1557
|
let (kwargs_opt,) = args.optional;
|
|
1048
1558
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1049
1559
|
Ok(Self {
|
|
1050
|
-
title: kwargs
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
.
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1560
|
+
title: match kwargs.get(ruby.to_symbol("title")) {
|
|
1561
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1562
|
+
magnus::Error::new(
|
|
1563
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1564
|
+
format!("invalid value for `title`: {}", e),
|
|
1565
|
+
)
|
|
1566
|
+
})?),
|
|
1567
|
+
None => None,
|
|
1568
|
+
},
|
|
1569
|
+
description: match kwargs.get(ruby.to_symbol("description")) {
|
|
1570
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1571
|
+
magnus::Error::new(
|
|
1572
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1573
|
+
format!("invalid value for `description`: {}", e),
|
|
1574
|
+
)
|
|
1575
|
+
})?),
|
|
1576
|
+
None => None,
|
|
1577
|
+
},
|
|
1578
|
+
keywords: match kwargs.get(ruby.to_symbol("keywords")) {
|
|
1579
|
+
Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
|
|
1580
|
+
magnus::Error::new(
|
|
1581
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1582
|
+
format!("invalid value for `keywords`: {}", e),
|
|
1583
|
+
)
|
|
1584
|
+
})?,
|
|
1585
|
+
None => Default::default(),
|
|
1586
|
+
},
|
|
1587
|
+
author: match kwargs.get(ruby.to_symbol("author")) {
|
|
1588
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1589
|
+
magnus::Error::new(
|
|
1590
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1591
|
+
format!("invalid value for `author`: {}", e),
|
|
1592
|
+
)
|
|
1593
|
+
})?),
|
|
1594
|
+
None => None,
|
|
1595
|
+
},
|
|
1596
|
+
canonical_url: match kwargs.get(ruby.to_symbol("canonical_url")) {
|
|
1597
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1598
|
+
magnus::Error::new(
|
|
1599
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1600
|
+
format!("invalid value for `canonical_url`: {}", e),
|
|
1601
|
+
)
|
|
1602
|
+
})?),
|
|
1603
|
+
None => None,
|
|
1604
|
+
},
|
|
1605
|
+
base_href: match kwargs.get(ruby.to_symbol("base_href")) {
|
|
1606
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1607
|
+
magnus::Error::new(
|
|
1608
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1609
|
+
format!("invalid value for `base_href`: {}", e),
|
|
1610
|
+
)
|
|
1611
|
+
})?),
|
|
1612
|
+
None => None,
|
|
1613
|
+
},
|
|
1614
|
+
language: match kwargs.get(ruby.to_symbol("language")) {
|
|
1615
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1616
|
+
magnus::Error::new(
|
|
1617
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1618
|
+
format!("invalid value for `language`: {}", e),
|
|
1619
|
+
)
|
|
1620
|
+
})?),
|
|
1621
|
+
None => None,
|
|
1622
|
+
},
|
|
1623
|
+
text_direction: match kwargs.get(ruby.to_symbol("text_direction")) {
|
|
1624
|
+
Some(v) => Some(TextDirection::try_convert(v).map_err(|e| {
|
|
1625
|
+
magnus::Error::new(
|
|
1626
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1627
|
+
format!("invalid value for `text_direction`: {}", e),
|
|
1628
|
+
)
|
|
1629
|
+
})?),
|
|
1630
|
+
None => None,
|
|
1631
|
+
},
|
|
1632
|
+
open_graph: match kwargs.get(ruby.to_symbol("open_graph")) {
|
|
1633
|
+
Some(v) => <HashMap<String, String>>::try_convert(v).map_err(|e| {
|
|
1634
|
+
magnus::Error::new(
|
|
1635
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1636
|
+
format!("invalid value for `open_graph`: {}", e),
|
|
1637
|
+
)
|
|
1638
|
+
})?,
|
|
1639
|
+
None => Default::default(),
|
|
1640
|
+
},
|
|
1641
|
+
twitter_card: match kwargs.get(ruby.to_symbol("twitter_card")) {
|
|
1642
|
+
Some(v) => <HashMap<String, String>>::try_convert(v).map_err(|e| {
|
|
1643
|
+
magnus::Error::new(
|
|
1644
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1645
|
+
format!("invalid value for `twitter_card`: {}", e),
|
|
1646
|
+
)
|
|
1647
|
+
})?,
|
|
1648
|
+
None => Default::default(),
|
|
1649
|
+
},
|
|
1650
|
+
meta_tags: match kwargs.get(ruby.to_symbol("meta_tags")) {
|
|
1651
|
+
Some(v) => <HashMap<String, String>>::try_convert(v).map_err(|e| {
|
|
1652
|
+
magnus::Error::new(
|
|
1653
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1654
|
+
format!("invalid value for `meta_tags`: {}", e),
|
|
1655
|
+
)
|
|
1656
|
+
})?,
|
|
1657
|
+
None => Default::default(),
|
|
1658
|
+
},
|
|
1087
1659
|
})
|
|
1088
1660
|
}
|
|
1089
1661
|
|
|
@@ -1132,7 +1704,7 @@ impl DocumentMetadata {
|
|
|
1132
1704
|
}
|
|
1133
1705
|
}
|
|
1134
1706
|
|
|
1135
|
-
#[derive(Clone, Debug, serde::Serialize
|
|
1707
|
+
#[derive(Clone, Debug, serde::Serialize)]
|
|
1136
1708
|
#[magnus::wrap(class = "HtmlToMarkdownRs::DocumentNode")]
|
|
1137
1709
|
pub struct DocumentNode {
|
|
1138
1710
|
id: String,
|
|
@@ -1170,6 +1742,14 @@ impl magnus::TryConvert for DocumentNode {
|
|
|
1170
1742
|
}
|
|
1171
1743
|
|
|
1172
1744
|
unsafe impl TryConvertOwned for DocumentNode {}
|
|
1745
|
+
impl<'de> serde::Deserialize<'de> for DocumentNode {
|
|
1746
|
+
fn deserialize<D>(deserializer: D) -> ::core::result::Result<Self, D::Error>
|
|
1747
|
+
where
|
|
1748
|
+
D: serde::Deserializer<'de>,
|
|
1749
|
+
{
|
|
1750
|
+
<html_to_markdown_rs::DocumentNode as serde::Deserialize>::deserialize(deserializer).map(Into::into)
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1173
1753
|
|
|
1174
1754
|
impl DocumentNode {
|
|
1175
1755
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
@@ -1178,33 +1758,65 @@ impl DocumentNode {
|
|
|
1178
1758
|
let (kwargs_opt,) = args.optional;
|
|
1179
1759
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1180
1760
|
Ok(Self {
|
|
1181
|
-
id: kwargs
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1761
|
+
id: match kwargs.get(ruby.to_symbol("id")) {
|
|
1762
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
1763
|
+
magnus::Error::new(
|
|
1764
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1765
|
+
format!("invalid value for `id`: {}", e),
|
|
1766
|
+
)
|
|
1767
|
+
})?,
|
|
1768
|
+
None => Default::default(),
|
|
1769
|
+
},
|
|
1770
|
+
content: match kwargs.get(ruby.to_symbol("content")) {
|
|
1771
|
+
Some(v) => NodeContent::try_convert(v).map_err(|e| {
|
|
1189
1772
|
magnus::Error::new(
|
|
1773
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1774
|
+
format!("invalid value for `content`: {}", e),
|
|
1775
|
+
)
|
|
1776
|
+
})?,
|
|
1777
|
+
None => {
|
|
1778
|
+
return Err(magnus::Error::new(
|
|
1190
1779
|
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
1191
1780
|
"missing required field: content",
|
|
1781
|
+
));
|
|
1782
|
+
}
|
|
1783
|
+
},
|
|
1784
|
+
parent: match kwargs.get(ruby.to_symbol("parent")) {
|
|
1785
|
+
Some(v) => Some(u32::try_convert(v).map_err(|e| {
|
|
1786
|
+
magnus::Error::new(
|
|
1787
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1788
|
+
format!("invalid value for `parent`: {}", e),
|
|
1789
|
+
)
|
|
1790
|
+
})?),
|
|
1791
|
+
None => None,
|
|
1792
|
+
},
|
|
1793
|
+
children: match kwargs.get(ruby.to_symbol("children")) {
|
|
1794
|
+
Some(v) => <Vec<u32>>::try_convert(v).map_err(|e| {
|
|
1795
|
+
magnus::Error::new(
|
|
1796
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1797
|
+
format!("invalid value for `children`: {}", e),
|
|
1192
1798
|
)
|
|
1193
1799
|
})?,
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
attributes: kwargs
|
|
1206
|
-
|
|
1207
|
-
|
|
1800
|
+
None => vec![],
|
|
1801
|
+
},
|
|
1802
|
+
annotations: match kwargs.get(ruby.to_symbol("annotations")) {
|
|
1803
|
+
Some(v) => <Vec<TextAnnotation>>::try_convert(v).map_err(|e| {
|
|
1804
|
+
magnus::Error::new(
|
|
1805
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1806
|
+
format!("invalid value for `annotations`: {}", e),
|
|
1807
|
+
)
|
|
1808
|
+
})?,
|
|
1809
|
+
None => vec![],
|
|
1810
|
+
},
|
|
1811
|
+
attributes: match kwargs.get(ruby.to_symbol("attributes")) {
|
|
1812
|
+
Some(v) => Some(<HashMap<String, String>>::try_convert(v).map_err(|e| {
|
|
1813
|
+
magnus::Error::new(
|
|
1814
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1815
|
+
format!("invalid value for `attributes`: {}", e),
|
|
1816
|
+
)
|
|
1817
|
+
})?),
|
|
1818
|
+
None => None,
|
|
1819
|
+
},
|
|
1208
1820
|
})
|
|
1209
1821
|
}
|
|
1210
1822
|
|
|
@@ -1275,13 +1887,24 @@ impl DocumentStructure {
|
|
|
1275
1887
|
let (kwargs_opt,) = args.optional;
|
|
1276
1888
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1277
1889
|
Ok(Self {
|
|
1278
|
-
nodes: kwargs
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1890
|
+
nodes: match kwargs.get(ruby.to_symbol("nodes")) {
|
|
1891
|
+
Some(v) => <Vec<DocumentNode>>::try_convert(v).map_err(|e| {
|
|
1892
|
+
magnus::Error::new(
|
|
1893
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1894
|
+
format!("invalid value for `nodes`: {}", e),
|
|
1895
|
+
)
|
|
1896
|
+
})?,
|
|
1897
|
+
None => Default::default(),
|
|
1898
|
+
},
|
|
1899
|
+
source_format: match kwargs.get(ruby.to_symbol("source_format")) {
|
|
1900
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1901
|
+
magnus::Error::new(
|
|
1902
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1903
|
+
format!("invalid value for `source_format`: {}", e),
|
|
1904
|
+
)
|
|
1905
|
+
})?),
|
|
1906
|
+
None => None,
|
|
1907
|
+
},
|
|
1285
1908
|
})
|
|
1286
1909
|
}
|
|
1287
1910
|
|
|
@@ -1294,7 +1917,7 @@ impl DocumentStructure {
|
|
|
1294
1917
|
}
|
|
1295
1918
|
}
|
|
1296
1919
|
|
|
1297
|
-
#[derive(Clone, Debug, serde::Serialize
|
|
1920
|
+
#[derive(Clone, Debug, serde::Serialize)]
|
|
1298
1921
|
#[magnus::wrap(class = "HtmlToMarkdownRs::GridCell")]
|
|
1299
1922
|
pub struct GridCell {
|
|
1300
1923
|
content: String,
|
|
@@ -1332,6 +1955,14 @@ impl magnus::TryConvert for GridCell {
|
|
|
1332
1955
|
}
|
|
1333
1956
|
|
|
1334
1957
|
unsafe impl TryConvertOwned for GridCell {}
|
|
1958
|
+
impl<'de> serde::Deserialize<'de> for GridCell {
|
|
1959
|
+
fn deserialize<D>(deserializer: D) -> ::core::result::Result<Self, D::Error>
|
|
1960
|
+
where
|
|
1961
|
+
D: serde::Deserializer<'de>,
|
|
1962
|
+
{
|
|
1963
|
+
<html_to_markdown_rs::GridCell as serde::Deserialize>::deserialize(deserializer).map(Into::into)
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1335
1966
|
|
|
1336
1967
|
impl Default for GridCell {
|
|
1337
1968
|
fn default() -> Self {
|
|
@@ -1339,12 +1970,8 @@ impl Default for GridCell {
|
|
|
1339
1970
|
content: String::new(),
|
|
1340
1971
|
row: 0,
|
|
1341
1972
|
col: 0,
|
|
1342
|
-
row_span:
|
|
1343
|
-
|
|
1344
|
-
.row_span,
|
|
1345
|
-
col_span: serde_json::from_str::<html_to_markdown_rs::GridCell>(r#"{"content":"","row":0,"col":0}"#)
|
|
1346
|
-
.expect("alef-generated default JSON for `GridCell` failed to deserialize")
|
|
1347
|
-
.col_span,
|
|
1973
|
+
row_span: 1,
|
|
1974
|
+
col_span: 1,
|
|
1348
1975
|
is_header: false,
|
|
1349
1976
|
}
|
|
1350
1977
|
}
|
|
@@ -1357,38 +1984,60 @@ impl GridCell {
|
|
|
1357
1984
|
let (kwargs_opt,) = args.optional;
|
|
1358
1985
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1359
1986
|
Ok(Self {
|
|
1360
|
-
content: kwargs
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
)
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1987
|
+
content: match kwargs.get(ruby.to_symbol("content")) {
|
|
1988
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
1989
|
+
magnus::Error::new(
|
|
1990
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1991
|
+
format!("invalid value for `content`: {}", e),
|
|
1992
|
+
)
|
|
1993
|
+
})?,
|
|
1994
|
+
None => Default::default(),
|
|
1995
|
+
},
|
|
1996
|
+
row: match kwargs.get(ruby.to_symbol("row")) {
|
|
1997
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
1998
|
+
magnus::Error::new(
|
|
1999
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2000
|
+
format!("invalid value for `row`: {}", e),
|
|
2001
|
+
)
|
|
2002
|
+
})?,
|
|
2003
|
+
None => Default::default(),
|
|
2004
|
+
},
|
|
2005
|
+
col: match kwargs.get(ruby.to_symbol("col")) {
|
|
2006
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
2007
|
+
magnus::Error::new(
|
|
2008
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2009
|
+
format!("invalid value for `col`: {}", e),
|
|
2010
|
+
)
|
|
2011
|
+
})?,
|
|
2012
|
+
None => Default::default(),
|
|
2013
|
+
},
|
|
2014
|
+
row_span: match kwargs.get(ruby.to_symbol("row_span")) {
|
|
2015
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
2016
|
+
magnus::Error::new(
|
|
2017
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2018
|
+
format!("invalid value for `row_span`: {}", e),
|
|
2019
|
+
)
|
|
2020
|
+
})?,
|
|
2021
|
+
None => 1,
|
|
2022
|
+
},
|
|
2023
|
+
col_span: match kwargs.get(ruby.to_symbol("col_span")) {
|
|
2024
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
2025
|
+
magnus::Error::new(
|
|
2026
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2027
|
+
format!("invalid value for `col_span`: {}", e),
|
|
2028
|
+
)
|
|
2029
|
+
})?,
|
|
2030
|
+
None => 1,
|
|
2031
|
+
},
|
|
2032
|
+
is_header: match kwargs.get(ruby.to_symbol("is_header")) {
|
|
2033
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
2034
|
+
magnus::Error::new(
|
|
2035
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2036
|
+
format!("invalid value for `is_header`: {}", e),
|
|
2037
|
+
)
|
|
2038
|
+
})?,
|
|
2039
|
+
None => false,
|
|
2040
|
+
},
|
|
1392
2041
|
})
|
|
1393
2042
|
}
|
|
1394
2043
|
|
|
@@ -1422,6 +2071,7 @@ impl GridCell {
|
|
|
1422
2071
|
}
|
|
1423
2072
|
}
|
|
1424
2073
|
|
|
2074
|
+
#[cfg(feature = "metadata")]
|
|
1425
2075
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1426
2076
|
#[magnus::wrap(class = "HtmlToMarkdownRs::HeaderMetadata")]
|
|
1427
2077
|
pub struct HeaderMetadata {
|
|
@@ -1432,8 +2082,10 @@ pub struct HeaderMetadata {
|
|
|
1432
2082
|
html_offset: usize,
|
|
1433
2083
|
}
|
|
1434
2084
|
|
|
2085
|
+
#[cfg(feature = "metadata")]
|
|
1435
2086
|
unsafe impl IntoValueFromNative for HeaderMetadata {}
|
|
1436
2087
|
|
|
2088
|
+
#[cfg(feature = "metadata")]
|
|
1437
2089
|
impl magnus::TryConvert for HeaderMetadata {
|
|
1438
2090
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
1439
2091
|
if let Ok(r) = <&HeaderMetadata as magnus::TryConvert>::try_convert(val) {
|
|
@@ -1458,8 +2110,10 @@ impl magnus::TryConvert for HeaderMetadata {
|
|
|
1458
2110
|
}
|
|
1459
2111
|
}
|
|
1460
2112
|
|
|
2113
|
+
#[cfg(feature = "metadata")]
|
|
1461
2114
|
unsafe impl TryConvertOwned for HeaderMetadata {}
|
|
1462
2115
|
|
|
2116
|
+
#[cfg(feature = "metadata")]
|
|
1463
2117
|
impl HeaderMetadata {
|
|
1464
2118
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1465
2119
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1467,25 +2121,51 @@ impl HeaderMetadata {
|
|
|
1467
2121
|
let (kwargs_opt,) = args.optional;
|
|
1468
2122
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1469
2123
|
Ok(Self {
|
|
1470
|
-
level: kwargs
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
2124
|
+
level: match kwargs.get(ruby.to_symbol("level")) {
|
|
2125
|
+
Some(v) => u8::try_convert(v).map_err(|e| {
|
|
2126
|
+
magnus::Error::new(
|
|
2127
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2128
|
+
format!("invalid value for `level`: {}", e),
|
|
2129
|
+
)
|
|
2130
|
+
})?,
|
|
2131
|
+
None => Default::default(),
|
|
2132
|
+
},
|
|
2133
|
+
text: match kwargs.get(ruby.to_symbol("text")) {
|
|
2134
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
2135
|
+
magnus::Error::new(
|
|
2136
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2137
|
+
format!("invalid value for `text`: {}", e),
|
|
2138
|
+
)
|
|
2139
|
+
})?,
|
|
2140
|
+
None => Default::default(),
|
|
2141
|
+
},
|
|
2142
|
+
id: match kwargs.get(ruby.to_symbol("id")) {
|
|
2143
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
2144
|
+
magnus::Error::new(
|
|
2145
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2146
|
+
format!("invalid value for `id`: {}", e),
|
|
2147
|
+
)
|
|
2148
|
+
})?),
|
|
2149
|
+
None => None,
|
|
2150
|
+
},
|
|
2151
|
+
depth: match kwargs.get(ruby.to_symbol("depth")) {
|
|
2152
|
+
Some(v) => usize::try_convert(v).map_err(|e| {
|
|
2153
|
+
magnus::Error::new(
|
|
2154
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2155
|
+
format!("invalid value for `depth`: {}", e),
|
|
2156
|
+
)
|
|
2157
|
+
})?,
|
|
2158
|
+
None => Default::default(),
|
|
2159
|
+
},
|
|
2160
|
+
html_offset: match kwargs.get(ruby.to_symbol("html_offset")) {
|
|
2161
|
+
Some(v) => usize::try_convert(v).map_err(|e| {
|
|
2162
|
+
magnus::Error::new(
|
|
2163
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2164
|
+
format!("invalid value for `html_offset`: {}", e),
|
|
2165
|
+
)
|
|
2166
|
+
})?,
|
|
2167
|
+
None => Default::default(),
|
|
2168
|
+
},
|
|
1489
2169
|
})
|
|
1490
2170
|
}
|
|
1491
2171
|
|
|
@@ -1525,19 +2205,27 @@ impl HeaderMetadata {
|
|
|
1525
2205
|
}
|
|
1526
2206
|
}
|
|
1527
2207
|
|
|
2208
|
+
#[cfg(feature = "metadata")]
|
|
1528
2209
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1529
2210
|
#[serde(default)]
|
|
1530
2211
|
#[magnus::wrap(class = "HtmlToMarkdownRs::HtmlMetadata")]
|
|
1531
2212
|
pub struct HtmlMetadata {
|
|
2213
|
+
#[cfg(feature = "metadata")]
|
|
1532
2214
|
document: DocumentMetadata,
|
|
2215
|
+
#[cfg(feature = "metadata")]
|
|
1533
2216
|
headers: Vec<HeaderMetadata>,
|
|
2217
|
+
#[cfg(feature = "metadata")]
|
|
1534
2218
|
links: Vec<LinkMetadata>,
|
|
2219
|
+
#[cfg(feature = "metadata")]
|
|
1535
2220
|
images: Vec<ImageMetadata>,
|
|
2221
|
+
#[cfg(feature = "metadata")]
|
|
1536
2222
|
structured_data: Vec<StructuredData>,
|
|
1537
2223
|
}
|
|
1538
2224
|
|
|
2225
|
+
#[cfg(feature = "metadata")]
|
|
1539
2226
|
unsafe impl IntoValueFromNative for HtmlMetadata {}
|
|
1540
2227
|
|
|
2228
|
+
#[cfg(feature = "metadata")]
|
|
1541
2229
|
impl magnus::TryConvert for HtmlMetadata {
|
|
1542
2230
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
1543
2231
|
if let Ok(r) = <&HtmlMetadata as magnus::TryConvert>::try_convert(val) {
|
|
@@ -1562,14 +2250,17 @@ impl magnus::TryConvert for HtmlMetadata {
|
|
|
1562
2250
|
}
|
|
1563
2251
|
}
|
|
1564
2252
|
|
|
2253
|
+
#[cfg(feature = "metadata")]
|
|
1565
2254
|
unsafe impl TryConvertOwned for HtmlMetadata {}
|
|
1566
2255
|
|
|
2256
|
+
#[cfg(feature = "metadata")]
|
|
1567
2257
|
impl Default for HtmlMetadata {
|
|
1568
2258
|
fn default() -> Self {
|
|
1569
2259
|
html_to_markdown_rs::metadata::HtmlMetadata::default().into()
|
|
1570
2260
|
}
|
|
1571
2261
|
}
|
|
1572
2262
|
|
|
2263
|
+
#[cfg(feature = "metadata")]
|
|
1573
2264
|
impl HtmlMetadata {
|
|
1574
2265
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1575
2266
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1577,45 +2268,80 @@ impl HtmlMetadata {
|
|
|
1577
2268
|
let (kwargs_opt,) = args.optional;
|
|
1578
2269
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1579
2270
|
Ok(Self {
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
2271
|
+
#[cfg(feature = "metadata")]
|
|
2272
|
+
document: match kwargs.get(ruby.to_symbol("document")) {
|
|
2273
|
+
Some(v) => DocumentMetadata::try_convert(v).map_err(|e| {
|
|
2274
|
+
magnus::Error::new(
|
|
2275
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2276
|
+
format!("invalid value for `document`: {}", e),
|
|
2277
|
+
)
|
|
2278
|
+
})?,
|
|
2279
|
+
None => Default::default(),
|
|
2280
|
+
},
|
|
2281
|
+
#[cfg(feature = "metadata")]
|
|
2282
|
+
headers: match kwargs.get(ruby.to_symbol("headers")) {
|
|
2283
|
+
Some(v) => <Vec<HeaderMetadata>>::try_convert(v).map_err(|e| {
|
|
2284
|
+
magnus::Error::new(
|
|
2285
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2286
|
+
format!("invalid value for `headers`: {}", e),
|
|
2287
|
+
)
|
|
2288
|
+
})?,
|
|
2289
|
+
None => Default::default(),
|
|
2290
|
+
},
|
|
2291
|
+
#[cfg(feature = "metadata")]
|
|
2292
|
+
links: match kwargs.get(ruby.to_symbol("links")) {
|
|
2293
|
+
Some(v) => <Vec<LinkMetadata>>::try_convert(v).map_err(|e| {
|
|
2294
|
+
magnus::Error::new(
|
|
2295
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2296
|
+
format!("invalid value for `links`: {}", e),
|
|
2297
|
+
)
|
|
2298
|
+
})?,
|
|
2299
|
+
None => Default::default(),
|
|
2300
|
+
},
|
|
2301
|
+
#[cfg(feature = "metadata")]
|
|
2302
|
+
images: match kwargs.get(ruby.to_symbol("images")) {
|
|
2303
|
+
Some(v) => <Vec<ImageMetadata>>::try_convert(v).map_err(|e| {
|
|
2304
|
+
magnus::Error::new(
|
|
2305
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2306
|
+
format!("invalid value for `images`: {}", e),
|
|
2307
|
+
)
|
|
2308
|
+
})?,
|
|
2309
|
+
None => Default::default(),
|
|
2310
|
+
},
|
|
2311
|
+
#[cfg(feature = "metadata")]
|
|
2312
|
+
structured_data: match kwargs.get(ruby.to_symbol("structured_data")) {
|
|
2313
|
+
Some(v) => <Vec<StructuredData>>::try_convert(v).map_err(|e| {
|
|
2314
|
+
magnus::Error::new(
|
|
2315
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2316
|
+
format!("invalid value for `structured_data`: {}", e),
|
|
2317
|
+
)
|
|
2318
|
+
})?,
|
|
2319
|
+
None => Default::default(),
|
|
2320
|
+
},
|
|
1600
2321
|
})
|
|
1601
2322
|
}
|
|
1602
2323
|
|
|
2324
|
+
#[cfg(feature = "metadata")]
|
|
1603
2325
|
fn document(&self) -> DocumentMetadata {
|
|
1604
2326
|
self.document.clone()
|
|
1605
2327
|
}
|
|
1606
2328
|
|
|
2329
|
+
#[cfg(feature = "metadata")]
|
|
1607
2330
|
fn headers(&self) -> Vec<HeaderMetadata> {
|
|
1608
2331
|
self.headers.clone()
|
|
1609
2332
|
}
|
|
1610
2333
|
|
|
2334
|
+
#[cfg(feature = "metadata")]
|
|
1611
2335
|
fn links(&self) -> Vec<LinkMetadata> {
|
|
1612
2336
|
self.links.clone()
|
|
1613
2337
|
}
|
|
1614
2338
|
|
|
2339
|
+
#[cfg(feature = "metadata")]
|
|
1615
2340
|
fn images(&self) -> Vec<ImageMetadata> {
|
|
1616
2341
|
self.images.clone()
|
|
1617
2342
|
}
|
|
1618
2343
|
|
|
2344
|
+
#[cfg(feature = "metadata")]
|
|
1619
2345
|
fn structured_data(&self) -> Vec<StructuredData> {
|
|
1620
2346
|
self.structured_data.clone()
|
|
1621
2347
|
}
|
|
@@ -1663,14 +2389,24 @@ impl ImageDimensions {
|
|
|
1663
2389
|
let (kwargs_opt,) = args.optional;
|
|
1664
2390
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1665
2391
|
Ok(Self {
|
|
1666
|
-
width: kwargs
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
2392
|
+
width: match kwargs.get(ruby.to_symbol("width")) {
|
|
2393
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
2394
|
+
magnus::Error::new(
|
|
2395
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2396
|
+
format!("invalid value for `width`: {}", e),
|
|
2397
|
+
)
|
|
2398
|
+
})?,
|
|
2399
|
+
None => Default::default(),
|
|
2400
|
+
},
|
|
2401
|
+
height: match kwargs.get(ruby.to_symbol("height")) {
|
|
2402
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
2403
|
+
magnus::Error::new(
|
|
2404
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2405
|
+
format!("invalid value for `height`: {}", e),
|
|
2406
|
+
)
|
|
2407
|
+
})?,
|
|
2408
|
+
None => Default::default(),
|
|
2409
|
+
},
|
|
1674
2410
|
})
|
|
1675
2411
|
}
|
|
1676
2412
|
|
|
@@ -1683,6 +2419,7 @@ impl ImageDimensions {
|
|
|
1683
2419
|
}
|
|
1684
2420
|
}
|
|
1685
2421
|
|
|
2422
|
+
#[cfg(feature = "metadata")]
|
|
1686
2423
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1687
2424
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ImageMetadata")]
|
|
1688
2425
|
pub struct ImageMetadata {
|
|
@@ -1694,8 +2431,10 @@ pub struct ImageMetadata {
|
|
|
1694
2431
|
attributes: HashMap<String, String>,
|
|
1695
2432
|
}
|
|
1696
2433
|
|
|
2434
|
+
#[cfg(feature = "metadata")]
|
|
1697
2435
|
unsafe impl IntoValueFromNative for ImageMetadata {}
|
|
1698
2436
|
|
|
2437
|
+
#[cfg(feature = "metadata")]
|
|
1699
2438
|
impl magnus::TryConvert for ImageMetadata {
|
|
1700
2439
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
1701
2440
|
if let Ok(r) = <&ImageMetadata as magnus::TryConvert>::try_convert(val) {
|
|
@@ -1720,8 +2459,10 @@ impl magnus::TryConvert for ImageMetadata {
|
|
|
1720
2459
|
}
|
|
1721
2460
|
}
|
|
1722
2461
|
|
|
2462
|
+
#[cfg(feature = "metadata")]
|
|
1723
2463
|
unsafe impl TryConvertOwned for ImageMetadata {}
|
|
1724
2464
|
|
|
2465
|
+
#[cfg(feature = "metadata")]
|
|
1725
2466
|
impl ImageMetadata {
|
|
1726
2467
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1727
2468
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1729,32 +2470,65 @@ impl ImageMetadata {
|
|
|
1729
2470
|
let (kwargs_opt,) = args.optional;
|
|
1730
2471
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1731
2472
|
Ok(Self {
|
|
1732
|
-
src: kwargs
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
2473
|
+
src: match kwargs.get(ruby.to_symbol("src")) {
|
|
2474
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
2475
|
+
magnus::Error::new(
|
|
2476
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2477
|
+
format!("invalid value for `src`: {}", e),
|
|
2478
|
+
)
|
|
2479
|
+
})?,
|
|
2480
|
+
None => Default::default(),
|
|
2481
|
+
},
|
|
2482
|
+
alt: match kwargs.get(ruby.to_symbol("alt")) {
|
|
2483
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
2484
|
+
magnus::Error::new(
|
|
2485
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2486
|
+
format!("invalid value for `alt`: {}", e),
|
|
2487
|
+
)
|
|
2488
|
+
})?),
|
|
2489
|
+
None => None,
|
|
2490
|
+
},
|
|
2491
|
+
title: match kwargs.get(ruby.to_symbol("title")) {
|
|
2492
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
1749
2493
|
magnus::Error::new(
|
|
2494
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2495
|
+
format!("invalid value for `title`: {}", e),
|
|
2496
|
+
)
|
|
2497
|
+
})?),
|
|
2498
|
+
None => None,
|
|
2499
|
+
},
|
|
2500
|
+
dimensions: match kwargs.get(ruby.to_symbol("dimensions")) {
|
|
2501
|
+
Some(v) => Some(ImageDimensions::try_convert(v).map_err(|e| {
|
|
2502
|
+
magnus::Error::new(
|
|
2503
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2504
|
+
format!("invalid value for `dimensions`: {}", e),
|
|
2505
|
+
)
|
|
2506
|
+
})?),
|
|
2507
|
+
None => None,
|
|
2508
|
+
},
|
|
2509
|
+
image_type: match kwargs.get(ruby.to_symbol("image_type")) {
|
|
2510
|
+
Some(v) => ImageType::try_convert(v).map_err(|e| {
|
|
2511
|
+
magnus::Error::new(
|
|
2512
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2513
|
+
format!("invalid value for `image_type`: {}", e),
|
|
2514
|
+
)
|
|
2515
|
+
})?,
|
|
2516
|
+
None => {
|
|
2517
|
+
return Err(magnus::Error::new(
|
|
1750
2518
|
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
1751
2519
|
"missing required field: image_type",
|
|
2520
|
+
));
|
|
2521
|
+
}
|
|
2522
|
+
},
|
|
2523
|
+
attributes: match kwargs.get(ruby.to_symbol("attributes")) {
|
|
2524
|
+
Some(v) => <HashMap<String, String>>::try_convert(v).map_err(|e| {
|
|
2525
|
+
magnus::Error::new(
|
|
2526
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2527
|
+
format!("invalid value for `attributes`: {}", e),
|
|
1752
2528
|
)
|
|
1753
2529
|
})?,
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok())
|
|
1757
|
-
.unwrap_or_default(),
|
|
2530
|
+
None => Default::default(),
|
|
2531
|
+
},
|
|
1758
2532
|
})
|
|
1759
2533
|
}
|
|
1760
2534
|
|
|
@@ -1783,6 +2557,7 @@ impl ImageMetadata {
|
|
|
1783
2557
|
}
|
|
1784
2558
|
}
|
|
1785
2559
|
|
|
2560
|
+
#[cfg(feature = "metadata")]
|
|
1786
2561
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1787
2562
|
#[magnus::wrap(class = "HtmlToMarkdownRs::LinkMetadata")]
|
|
1788
2563
|
pub struct LinkMetadata {
|
|
@@ -1794,8 +2569,10 @@ pub struct LinkMetadata {
|
|
|
1794
2569
|
attributes: HashMap<String, String>,
|
|
1795
2570
|
}
|
|
1796
2571
|
|
|
2572
|
+
#[cfg(feature = "metadata")]
|
|
1797
2573
|
unsafe impl IntoValueFromNative for LinkMetadata {}
|
|
1798
2574
|
|
|
2575
|
+
#[cfg(feature = "metadata")]
|
|
1799
2576
|
impl magnus::TryConvert for LinkMetadata {
|
|
1800
2577
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
1801
2578
|
if let Ok(r) = <&LinkMetadata as magnus::TryConvert>::try_convert(val) {
|
|
@@ -1820,8 +2597,10 @@ impl magnus::TryConvert for LinkMetadata {
|
|
|
1820
2597
|
}
|
|
1821
2598
|
}
|
|
1822
2599
|
|
|
2600
|
+
#[cfg(feature = "metadata")]
|
|
1823
2601
|
unsafe impl TryConvertOwned for LinkMetadata {}
|
|
1824
2602
|
|
|
2603
|
+
#[cfg(feature = "metadata")]
|
|
1825
2604
|
impl LinkMetadata {
|
|
1826
2605
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1827
2606
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1829,34 +2608,65 @@ impl LinkMetadata {
|
|
|
1829
2608
|
let (kwargs_opt,) = args.optional;
|
|
1830
2609
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1831
2610
|
Ok(Self {
|
|
1832
|
-
href: kwargs
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
link_type: kwargs
|
|
1844
|
-
.get(ruby.to_symbol("link_type"))
|
|
1845
|
-
.and_then(|v| LinkType::try_convert(v).ok())
|
|
1846
|
-
.ok_or_else(|| {
|
|
2611
|
+
href: match kwargs.get(ruby.to_symbol("href")) {
|
|
2612
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
2613
|
+
magnus::Error::new(
|
|
2614
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2615
|
+
format!("invalid value for `href`: {}", e),
|
|
2616
|
+
)
|
|
2617
|
+
})?,
|
|
2618
|
+
None => Default::default(),
|
|
2619
|
+
},
|
|
2620
|
+
text: match kwargs.get(ruby.to_symbol("text")) {
|
|
2621
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
1847
2622
|
magnus::Error::new(
|
|
2623
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2624
|
+
format!("invalid value for `text`: {}", e),
|
|
2625
|
+
)
|
|
2626
|
+
})?,
|
|
2627
|
+
None => Default::default(),
|
|
2628
|
+
},
|
|
2629
|
+
title: match kwargs.get(ruby.to_symbol("title")) {
|
|
2630
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
2631
|
+
magnus::Error::new(
|
|
2632
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2633
|
+
format!("invalid value for `title`: {}", e),
|
|
2634
|
+
)
|
|
2635
|
+
})?),
|
|
2636
|
+
None => None,
|
|
2637
|
+
},
|
|
2638
|
+
link_type: match kwargs.get(ruby.to_symbol("link_type")) {
|
|
2639
|
+
Some(v) => LinkType::try_convert(v).map_err(|e| {
|
|
2640
|
+
magnus::Error::new(
|
|
2641
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2642
|
+
format!("invalid value for `link_type`: {}", e),
|
|
2643
|
+
)
|
|
2644
|
+
})?,
|
|
2645
|
+
None => {
|
|
2646
|
+
return Err(magnus::Error::new(
|
|
1848
2647
|
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
1849
2648
|
"missing required field: link_type",
|
|
2649
|
+
));
|
|
2650
|
+
}
|
|
2651
|
+
},
|
|
2652
|
+
rel: match kwargs.get(ruby.to_symbol("rel")) {
|
|
2653
|
+
Some(v) => <Vec<String>>::try_convert(v).map_err(|e| {
|
|
2654
|
+
magnus::Error::new(
|
|
2655
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2656
|
+
format!("invalid value for `rel`: {}", e),
|
|
2657
|
+
)
|
|
2658
|
+
})?,
|
|
2659
|
+
None => Default::default(),
|
|
2660
|
+
},
|
|
2661
|
+
attributes: match kwargs.get(ruby.to_symbol("attributes")) {
|
|
2662
|
+
Some(v) => <HashMap<String, String>>::try_convert(v).map_err(|e| {
|
|
2663
|
+
magnus::Error::new(
|
|
2664
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2665
|
+
format!("invalid value for `attributes`: {}", e),
|
|
1850
2666
|
)
|
|
1851
2667
|
})?,
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
.and_then(|v| <Vec<String>>::try_convert(v).ok())
|
|
1855
|
-
.unwrap_or_default(),
|
|
1856
|
-
attributes: kwargs
|
|
1857
|
-
.get(ruby.to_symbol("attributes"))
|
|
1858
|
-
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok())
|
|
1859
|
-
.unwrap_or_default(),
|
|
2668
|
+
None => Default::default(),
|
|
2669
|
+
},
|
|
1860
2670
|
})
|
|
1861
2671
|
}
|
|
1862
2672
|
|
|
@@ -1927,14 +2737,24 @@ impl MetadataEntry {
|
|
|
1927
2737
|
let (kwargs_opt,) = args.optional;
|
|
1928
2738
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1929
2739
|
Ok(Self {
|
|
1930
|
-
key: kwargs
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
2740
|
+
key: match kwargs.get(ruby.to_symbol("key")) {
|
|
2741
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
2742
|
+
magnus::Error::new(
|
|
2743
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2744
|
+
format!("invalid value for `key`: {}", e),
|
|
2745
|
+
)
|
|
2746
|
+
})?,
|
|
2747
|
+
None => Default::default(),
|
|
2748
|
+
},
|
|
2749
|
+
value: match kwargs.get(ruby.to_symbol("value")) {
|
|
2750
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
2751
|
+
magnus::Error::new(
|
|
2752
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2753
|
+
format!("invalid value for `value`: {}", e),
|
|
2754
|
+
)
|
|
2755
|
+
})?,
|
|
2756
|
+
None => Default::default(),
|
|
2757
|
+
},
|
|
1938
2758
|
})
|
|
1939
2759
|
}
|
|
1940
2760
|
|
|
@@ -1947,6 +2767,7 @@ impl MetadataEntry {
|
|
|
1947
2767
|
}
|
|
1948
2768
|
}
|
|
1949
2769
|
|
|
2770
|
+
#[cfg(feature = "visitor")]
|
|
1950
2771
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1951
2772
|
#[magnus::wrap(class = "HtmlToMarkdownRs::NodeContext")]
|
|
1952
2773
|
pub struct NodeContext {
|
|
@@ -1958,8 +2779,10 @@ pub struct NodeContext {
|
|
|
1958
2779
|
is_inline: bool,
|
|
1959
2780
|
}
|
|
1960
2781
|
|
|
2782
|
+
#[cfg(feature = "visitor")]
|
|
1961
2783
|
unsafe impl IntoValueFromNative for NodeContext {}
|
|
1962
2784
|
|
|
2785
|
+
#[cfg(feature = "visitor")]
|
|
1963
2786
|
impl magnus::TryConvert for NodeContext {
|
|
1964
2787
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
1965
2788
|
if let Ok(r) = <&NodeContext as magnus::TryConvert>::try_convert(val) {
|
|
@@ -1984,8 +2807,10 @@ impl magnus::TryConvert for NodeContext {
|
|
|
1984
2807
|
}
|
|
1985
2808
|
}
|
|
1986
2809
|
|
|
2810
|
+
#[cfg(feature = "visitor")]
|
|
1987
2811
|
unsafe impl TryConvertOwned for NodeContext {}
|
|
1988
2812
|
|
|
2813
|
+
#[cfg(feature = "visitor")]
|
|
1989
2814
|
impl NodeContext {
|
|
1990
2815
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1991
2816
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1993,34 +2818,65 @@ impl NodeContext {
|
|
|
1993
2818
|
let (kwargs_opt,) = args.optional;
|
|
1994
2819
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1995
2820
|
Ok(Self {
|
|
1996
|
-
node_type: kwargs
|
|
1997
|
-
|
|
1998
|
-
.and_then(|v| NodeType::try_convert(v).ok())
|
|
1999
|
-
.ok_or_else(|| {
|
|
2821
|
+
node_type: match kwargs.get(ruby.to_symbol("node_type")) {
|
|
2822
|
+
Some(v) => NodeType::try_convert(v).map_err(|e| {
|
|
2000
2823
|
magnus::Error::new(
|
|
2824
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2825
|
+
format!("invalid value for `node_type`: {}", e),
|
|
2826
|
+
)
|
|
2827
|
+
})?,
|
|
2828
|
+
None => {
|
|
2829
|
+
return Err(magnus::Error::new(
|
|
2001
2830
|
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
2002
2831
|
"missing required field: node_type",
|
|
2832
|
+
));
|
|
2833
|
+
}
|
|
2834
|
+
},
|
|
2835
|
+
tag_name: match kwargs.get(ruby.to_symbol("tag_name")) {
|
|
2836
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
2837
|
+
magnus::Error::new(
|
|
2838
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2839
|
+
format!("invalid value for `tag_name`: {}", e),
|
|
2840
|
+
)
|
|
2841
|
+
})?,
|
|
2842
|
+
None => Default::default(),
|
|
2843
|
+
},
|
|
2844
|
+
depth: match kwargs.get(ruby.to_symbol("depth")) {
|
|
2845
|
+
Some(v) => usize::try_convert(v).map_err(|e| {
|
|
2846
|
+
magnus::Error::new(
|
|
2847
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2848
|
+
format!("invalid value for `depth`: {}", e),
|
|
2849
|
+
)
|
|
2850
|
+
})?,
|
|
2851
|
+
None => Default::default(),
|
|
2852
|
+
},
|
|
2853
|
+
index_in_parent: match kwargs.get(ruby.to_symbol("index_in_parent")) {
|
|
2854
|
+
Some(v) => usize::try_convert(v).map_err(|e| {
|
|
2855
|
+
magnus::Error::new(
|
|
2856
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2857
|
+
format!("invalid value for `index_in_parent`: {}", e),
|
|
2858
|
+
)
|
|
2859
|
+
})?,
|
|
2860
|
+
None => Default::default(),
|
|
2861
|
+
},
|
|
2862
|
+
parent_tag: match kwargs.get(ruby.to_symbol("parent_tag")) {
|
|
2863
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
2864
|
+
magnus::Error::new(
|
|
2865
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2866
|
+
format!("invalid value for `parent_tag`: {}", e),
|
|
2867
|
+
)
|
|
2868
|
+
})?),
|
|
2869
|
+
None => None,
|
|
2870
|
+
},
|
|
2871
|
+
is_inline: match kwargs.get(ruby.to_symbol("is_inline")) {
|
|
2872
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
2873
|
+
magnus::Error::new(
|
|
2874
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2875
|
+
format!("invalid value for `is_inline`: {}", e),
|
|
2003
2876
|
)
|
|
2004
2877
|
})?,
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
.and_then(|v| String::try_convert(v).ok())
|
|
2008
|
-
.unwrap_or_default(),
|
|
2009
|
-
depth: kwargs
|
|
2010
|
-
.get(ruby.to_symbol("depth"))
|
|
2011
|
-
.and_then(|v| usize::try_convert(v).ok())
|
|
2012
|
-
.unwrap_or_default(),
|
|
2013
|
-
index_in_parent: kwargs
|
|
2014
|
-
.get(ruby.to_symbol("index_in_parent"))
|
|
2015
|
-
.and_then(|v| usize::try_convert(v).ok())
|
|
2016
|
-
.unwrap_or_default(),
|
|
2017
|
-
parent_tag: kwargs
|
|
2018
|
-
.get(ruby.to_symbol("parent_tag"))
|
|
2019
|
-
.and_then(|v| String::try_convert(v).ok()),
|
|
2020
|
-
is_inline: kwargs
|
|
2021
|
-
.get(ruby.to_symbol("is_inline"))
|
|
2022
|
-
.and_then(|v| bool::try_convert(v).ok())
|
|
2023
|
-
.unwrap_or_default(),
|
|
2878
|
+
None => Default::default(),
|
|
2879
|
+
},
|
|
2024
2880
|
})
|
|
2025
2881
|
}
|
|
2026
2882
|
|
|
@@ -2063,7 +2919,7 @@ impl NodeContext {
|
|
|
2063
2919
|
}
|
|
2064
2920
|
}
|
|
2065
2921
|
|
|
2066
|
-
#[derive(Clone, Debug, serde::Serialize
|
|
2922
|
+
#[derive(Clone, Debug, serde::Serialize)]
|
|
2067
2923
|
#[serde(default)]
|
|
2068
2924
|
#[magnus::wrap(class = "HtmlToMarkdownRs::PreprocessingOptions")]
|
|
2069
2925
|
pub struct PreprocessingOptions {
|
|
@@ -2100,6 +2956,15 @@ impl magnus::TryConvert for PreprocessingOptions {
|
|
|
2100
2956
|
}
|
|
2101
2957
|
|
|
2102
2958
|
unsafe impl TryConvertOwned for PreprocessingOptions {}
|
|
2959
|
+
impl<'de> serde::Deserialize<'de> for PreprocessingOptions {
|
|
2960
|
+
fn deserialize<D>(deserializer: D) -> ::core::result::Result<Self, D::Error>
|
|
2961
|
+
where
|
|
2962
|
+
D: serde::Deserializer<'de>,
|
|
2963
|
+
{
|
|
2964
|
+
<html_to_markdown_rs::options::PreprocessingOptions as serde::Deserialize>::deserialize(deserializer)
|
|
2965
|
+
.map(Into::into)
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2103
2968
|
|
|
2104
2969
|
impl Default for PreprocessingOptions {
|
|
2105
2970
|
fn default() -> Self {
|
|
@@ -2114,22 +2979,42 @@ impl PreprocessingOptions {
|
|
|
2114
2979
|
let (kwargs_opt,) = args.optional;
|
|
2115
2980
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2116
2981
|
Ok(Self {
|
|
2117
|
-
enabled: kwargs
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2982
|
+
enabled: match kwargs.get(ruby.to_symbol("enabled")) {
|
|
2983
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
2984
|
+
magnus::Error::new(
|
|
2985
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2986
|
+
format!("invalid value for `enabled`: {}", e),
|
|
2987
|
+
)
|
|
2988
|
+
})?,
|
|
2989
|
+
None => true,
|
|
2990
|
+
},
|
|
2991
|
+
preset: match kwargs.get(ruby.to_symbol("preset")) {
|
|
2992
|
+
Some(v) => PreprocessingPreset::try_convert(v).map_err(|e| {
|
|
2993
|
+
magnus::Error::new(
|
|
2994
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2995
|
+
format!("invalid value for `preset`: {}", e),
|
|
2996
|
+
)
|
|
2997
|
+
})?,
|
|
2998
|
+
None => PreprocessingPreset::Standard,
|
|
2999
|
+
},
|
|
3000
|
+
remove_navigation: match kwargs.get(ruby.to_symbol("remove_navigation")) {
|
|
3001
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
3002
|
+
magnus::Error::new(
|
|
3003
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3004
|
+
format!("invalid value for `remove_navigation`: {}", e),
|
|
3005
|
+
)
|
|
3006
|
+
})?,
|
|
3007
|
+
None => true,
|
|
3008
|
+
},
|
|
3009
|
+
remove_forms: match kwargs.get(ruby.to_symbol("remove_forms")) {
|
|
3010
|
+
Some(v) => bool::try_convert(v).map_err(|e| {
|
|
3011
|
+
magnus::Error::new(
|
|
3012
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3013
|
+
format!("invalid value for `remove_forms`: {}", e),
|
|
3014
|
+
)
|
|
3015
|
+
})?,
|
|
3016
|
+
None => true,
|
|
3017
|
+
},
|
|
2133
3018
|
})
|
|
2134
3019
|
}
|
|
2135
3020
|
|
|
@@ -2201,18 +3086,42 @@ impl PreprocessingOptionsUpdate {
|
|
|
2201
3086
|
let (kwargs_opt,) = args.optional;
|
|
2202
3087
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2203
3088
|
Ok(Self {
|
|
2204
|
-
enabled: kwargs
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
3089
|
+
enabled: match kwargs.get(ruby.to_symbol("enabled")) {
|
|
3090
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
3091
|
+
magnus::Error::new(
|
|
3092
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3093
|
+
format!("invalid value for `enabled`: {}", e),
|
|
3094
|
+
)
|
|
3095
|
+
})?),
|
|
3096
|
+
None => None,
|
|
3097
|
+
},
|
|
3098
|
+
preset: match kwargs.get(ruby.to_symbol("preset")) {
|
|
3099
|
+
Some(v) => Some(PreprocessingPreset::try_convert(v).map_err(|e| {
|
|
3100
|
+
magnus::Error::new(
|
|
3101
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3102
|
+
format!("invalid value for `preset`: {}", e),
|
|
3103
|
+
)
|
|
3104
|
+
})?),
|
|
3105
|
+
None => None,
|
|
3106
|
+
},
|
|
3107
|
+
remove_navigation: match kwargs.get(ruby.to_symbol("remove_navigation")) {
|
|
3108
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
3109
|
+
magnus::Error::new(
|
|
3110
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3111
|
+
format!("invalid value for `remove_navigation`: {}", e),
|
|
3112
|
+
)
|
|
3113
|
+
})?),
|
|
3114
|
+
None => None,
|
|
3115
|
+
},
|
|
3116
|
+
remove_forms: match kwargs.get(ruby.to_symbol("remove_forms")) {
|
|
3117
|
+
Some(v) => Some(bool::try_convert(v).map_err(|e| {
|
|
3118
|
+
magnus::Error::new(
|
|
3119
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3120
|
+
format!("invalid value for `remove_forms`: {}", e),
|
|
3121
|
+
)
|
|
3122
|
+
})?),
|
|
3123
|
+
None => None,
|
|
3124
|
+
},
|
|
2216
3125
|
})
|
|
2217
3126
|
}
|
|
2218
3127
|
|
|
@@ -2275,19 +3184,29 @@ impl ProcessingWarning {
|
|
|
2275
3184
|
let (kwargs_opt,) = args.optional;
|
|
2276
3185
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2277
3186
|
Ok(Self {
|
|
2278
|
-
message: kwargs
|
|
2279
|
-
|
|
2280
|
-
.and_then(|v| String::try_convert(v).ok())
|
|
2281
|
-
.unwrap_or_default(),
|
|
2282
|
-
kind: kwargs
|
|
2283
|
-
.get(ruby.to_symbol("kind"))
|
|
2284
|
-
.and_then(|v| WarningKind::try_convert(v).ok())
|
|
2285
|
-
.ok_or_else(|| {
|
|
3187
|
+
message: match kwargs.get(ruby.to_symbol("message")) {
|
|
3188
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
2286
3189
|
magnus::Error::new(
|
|
2287
|
-
unsafe { magnus::Ruby::get_unchecked() }.
|
|
2288
|
-
"
|
|
3190
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3191
|
+
format!("invalid value for `message`: {}", e),
|
|
3192
|
+
)
|
|
3193
|
+
})?,
|
|
3194
|
+
None => Default::default(),
|
|
3195
|
+
},
|
|
3196
|
+
kind: match kwargs.get(ruby.to_symbol("kind")) {
|
|
3197
|
+
Some(v) => WarningKind::try_convert(v).map_err(|e| {
|
|
3198
|
+
magnus::Error::new(
|
|
3199
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3200
|
+
format!("invalid value for `kind`: {}", e),
|
|
2289
3201
|
)
|
|
2290
3202
|
})?,
|
|
3203
|
+
None => {
|
|
3204
|
+
return Err(magnus::Error::new(
|
|
3205
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
3206
|
+
"missing required field: kind",
|
|
3207
|
+
));
|
|
3208
|
+
}
|
|
3209
|
+
},
|
|
2291
3210
|
})
|
|
2292
3211
|
}
|
|
2293
3212
|
|
|
@@ -2300,6 +3219,7 @@ impl ProcessingWarning {
|
|
|
2300
3219
|
}
|
|
2301
3220
|
}
|
|
2302
3221
|
|
|
3222
|
+
#[cfg(feature = "metadata")]
|
|
2303
3223
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
2304
3224
|
#[magnus::wrap(class = "HtmlToMarkdownRs::StructuredData")]
|
|
2305
3225
|
pub struct StructuredData {
|
|
@@ -2308,8 +3228,10 @@ pub struct StructuredData {
|
|
|
2308
3228
|
schema_type: Option<String>,
|
|
2309
3229
|
}
|
|
2310
3230
|
|
|
3231
|
+
#[cfg(feature = "metadata")]
|
|
2311
3232
|
unsafe impl IntoValueFromNative for StructuredData {}
|
|
2312
3233
|
|
|
3234
|
+
#[cfg(feature = "metadata")]
|
|
2313
3235
|
impl magnus::TryConvert for StructuredData {
|
|
2314
3236
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2315
3237
|
if let Ok(r) = <&StructuredData as magnus::TryConvert>::try_convert(val) {
|
|
@@ -2334,8 +3256,10 @@ impl magnus::TryConvert for StructuredData {
|
|
|
2334
3256
|
}
|
|
2335
3257
|
}
|
|
2336
3258
|
|
|
3259
|
+
#[cfg(feature = "metadata")]
|
|
2337
3260
|
unsafe impl TryConvertOwned for StructuredData {}
|
|
2338
3261
|
|
|
3262
|
+
#[cfg(feature = "metadata")]
|
|
2339
3263
|
impl StructuredData {
|
|
2340
3264
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
2341
3265
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -2343,22 +3267,38 @@ impl StructuredData {
|
|
|
2343
3267
|
let (kwargs_opt,) = args.optional;
|
|
2344
3268
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2345
3269
|
Ok(Self {
|
|
2346
|
-
data_type: kwargs
|
|
2347
|
-
|
|
2348
|
-
.and_then(|v| StructuredDataType::try_convert(v).ok())
|
|
2349
|
-
.ok_or_else(|| {
|
|
3270
|
+
data_type: match kwargs.get(ruby.to_symbol("data_type")) {
|
|
3271
|
+
Some(v) => StructuredDataType::try_convert(v).map_err(|e| {
|
|
2350
3272
|
magnus::Error::new(
|
|
3273
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3274
|
+
format!("invalid value for `data_type`: {}", e),
|
|
3275
|
+
)
|
|
3276
|
+
})?,
|
|
3277
|
+
None => {
|
|
3278
|
+
return Err(magnus::Error::new(
|
|
2351
3279
|
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
2352
3280
|
"missing required field: data_type",
|
|
3281
|
+
));
|
|
3282
|
+
}
|
|
3283
|
+
},
|
|
3284
|
+
raw_json: match kwargs.get(ruby.to_symbol("raw_json")) {
|
|
3285
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
3286
|
+
magnus::Error::new(
|
|
3287
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3288
|
+
format!("invalid value for `raw_json`: {}", e),
|
|
2353
3289
|
)
|
|
2354
3290
|
})?,
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
.
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
3291
|
+
None => Default::default(),
|
|
3292
|
+
},
|
|
3293
|
+
schema_type: match kwargs.get(ruby.to_symbol("schema_type")) {
|
|
3294
|
+
Some(v) => Some(String::try_convert(v).map_err(|e| {
|
|
3295
|
+
magnus::Error::new(
|
|
3296
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3297
|
+
format!("invalid value for `schema_type`: {}", e),
|
|
3298
|
+
)
|
|
3299
|
+
})?),
|
|
3300
|
+
None => None,
|
|
3301
|
+
},
|
|
2362
3302
|
})
|
|
2363
3303
|
}
|
|
2364
3304
|
|
|
@@ -2417,19 +3357,29 @@ impl TableData {
|
|
|
2417
3357
|
let (kwargs_opt,) = args.optional;
|
|
2418
3358
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2419
3359
|
Ok(Self {
|
|
2420
|
-
grid: kwargs
|
|
2421
|
-
|
|
2422
|
-
.and_then(|v| TableGrid::try_convert(v).ok())
|
|
2423
|
-
.ok_or_else(|| {
|
|
3360
|
+
grid: match kwargs.get(ruby.to_symbol("grid")) {
|
|
3361
|
+
Some(v) => TableGrid::try_convert(v).map_err(|e| {
|
|
2424
3362
|
magnus::Error::new(
|
|
3363
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3364
|
+
format!("invalid value for `grid`: {}", e),
|
|
3365
|
+
)
|
|
3366
|
+
})?,
|
|
3367
|
+
None => {
|
|
3368
|
+
return Err(magnus::Error::new(
|
|
2425
3369
|
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
2426
3370
|
"missing required field: grid",
|
|
3371
|
+
));
|
|
3372
|
+
}
|
|
3373
|
+
},
|
|
3374
|
+
markdown: match kwargs.get(ruby.to_symbol("markdown")) {
|
|
3375
|
+
Some(v) => String::try_convert(v).map_err(|e| {
|
|
3376
|
+
magnus::Error::new(
|
|
3377
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3378
|
+
format!("invalid value for `markdown`: {}", e),
|
|
2427
3379
|
)
|
|
2428
3380
|
})?,
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
.and_then(|v| String::try_convert(v).ok())
|
|
2432
|
-
.unwrap_or_default(),
|
|
3381
|
+
None => Default::default(),
|
|
3382
|
+
},
|
|
2433
3383
|
})
|
|
2434
3384
|
}
|
|
2435
3385
|
|
|
@@ -2492,18 +3442,33 @@ impl TableGrid {
|
|
|
2492
3442
|
let (kwargs_opt,) = args.optional;
|
|
2493
3443
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2494
3444
|
Ok(Self {
|
|
2495
|
-
rows: kwargs
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
3445
|
+
rows: match kwargs.get(ruby.to_symbol("rows")) {
|
|
3446
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
3447
|
+
magnus::Error::new(
|
|
3448
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3449
|
+
format!("invalid value for `rows`: {}", e),
|
|
3450
|
+
)
|
|
3451
|
+
})?,
|
|
3452
|
+
None => Default::default(),
|
|
3453
|
+
},
|
|
3454
|
+
cols: match kwargs.get(ruby.to_symbol("cols")) {
|
|
3455
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
3456
|
+
magnus::Error::new(
|
|
3457
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3458
|
+
format!("invalid value for `cols`: {}", e),
|
|
3459
|
+
)
|
|
3460
|
+
})?,
|
|
3461
|
+
None => Default::default(),
|
|
3462
|
+
},
|
|
3463
|
+
cells: match kwargs.get(ruby.to_symbol("cells")) {
|
|
3464
|
+
Some(v) => <Vec<GridCell>>::try_convert(v).map_err(|e| {
|
|
3465
|
+
magnus::Error::new(
|
|
3466
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3467
|
+
format!("invalid value for `cells`: {}", e),
|
|
3468
|
+
)
|
|
3469
|
+
})?,
|
|
3470
|
+
None => Default::default(),
|
|
3471
|
+
},
|
|
2507
3472
|
})
|
|
2508
3473
|
}
|
|
2509
3474
|
|
|
@@ -2563,23 +3528,38 @@ impl TextAnnotation {
|
|
|
2563
3528
|
let (kwargs_opt,) = args.optional;
|
|
2564
3529
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2565
3530
|
Ok(Self {
|
|
2566
|
-
start: kwargs
|
|
2567
|
-
|
|
2568
|
-
.and_then(|v| u32::try_convert(v).ok())
|
|
2569
|
-
.unwrap_or_default(),
|
|
2570
|
-
end: kwargs
|
|
2571
|
-
.get(ruby.to_symbol("end"))
|
|
2572
|
-
.and_then(|v| u32::try_convert(v).ok())
|
|
2573
|
-
.unwrap_or_default(),
|
|
2574
|
-
kind: kwargs
|
|
2575
|
-
.get(ruby.to_symbol("kind"))
|
|
2576
|
-
.and_then(|v| AnnotationKind::try_convert(v).ok())
|
|
2577
|
-
.ok_or_else(|| {
|
|
3531
|
+
start: match kwargs.get(ruby.to_symbol("start")) {
|
|
3532
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
2578
3533
|
magnus::Error::new(
|
|
2579
|
-
unsafe { magnus::Ruby::get_unchecked() }.
|
|
2580
|
-
"
|
|
3534
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3535
|
+
format!("invalid value for `start`: {}", e),
|
|
3536
|
+
)
|
|
3537
|
+
})?,
|
|
3538
|
+
None => Default::default(),
|
|
3539
|
+
},
|
|
3540
|
+
end: match kwargs.get(ruby.to_symbol("end")) {
|
|
3541
|
+
Some(v) => u32::try_convert(v).map_err(|e| {
|
|
3542
|
+
magnus::Error::new(
|
|
3543
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3544
|
+
format!("invalid value for `end`: {}", e),
|
|
2581
3545
|
)
|
|
2582
3546
|
})?,
|
|
3547
|
+
None => Default::default(),
|
|
3548
|
+
},
|
|
3549
|
+
kind: match kwargs.get(ruby.to_symbol("kind")) {
|
|
3550
|
+
Some(v) => AnnotationKind::try_convert(v).map_err(|e| {
|
|
3551
|
+
magnus::Error::new(
|
|
3552
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
3553
|
+
format!("invalid value for `kind`: {}", e),
|
|
3554
|
+
)
|
|
3555
|
+
})?,
|
|
3556
|
+
None => {
|
|
3557
|
+
return Err(magnus::Error::new(
|
|
3558
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
3559
|
+
"missing required field: kind",
|
|
3560
|
+
));
|
|
3561
|
+
}
|
|
3562
|
+
},
|
|
2583
3563
|
})
|
|
2584
3564
|
}
|
|
2585
3565
|
|
|
@@ -2596,14 +3576,17 @@ impl TextAnnotation {
|
|
|
2596
3576
|
}
|
|
2597
3577
|
}
|
|
2598
3578
|
|
|
3579
|
+
#[cfg(feature = "visitor")]
|
|
2599
3580
|
#[derive(Clone)]
|
|
2600
3581
|
#[magnus::wrap(class = "HtmlToMarkdownRs::VisitorHandle")]
|
|
2601
3582
|
pub struct VisitorHandle {
|
|
2602
3583
|
inner: Arc<html_to_markdown_rs::VisitorHandle>,
|
|
2603
3584
|
}
|
|
2604
3585
|
|
|
3586
|
+
#[cfg(feature = "visitor")]
|
|
2605
3587
|
unsafe impl IntoValueFromNative for VisitorHandle {}
|
|
2606
3588
|
|
|
3589
|
+
#[cfg(feature = "visitor")]
|
|
2607
3590
|
impl magnus::TryConvert for VisitorHandle {
|
|
2608
3591
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2609
3592
|
let r: &VisitorHandle = magnus::TryConvert::try_convert(val)?;
|
|
@@ -2611,8 +3594,10 @@ impl magnus::TryConvert for VisitorHandle {
|
|
|
2611
3594
|
}
|
|
2612
3595
|
}
|
|
2613
3596
|
|
|
3597
|
+
#[cfg(feature = "visitor")]
|
|
2614
3598
|
unsafe impl TryConvertOwned for VisitorHandle {}
|
|
2615
3599
|
|
|
3600
|
+
#[cfg(feature = "visitor")]
|
|
2616
3601
|
impl VisitorHandle {}
|
|
2617
3602
|
|
|
2618
3603
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
@@ -3922,7 +4907,7 @@ pub fn convert(args: &[magnus::Value]) -> Result<ConversionResult, Error> {
|
|
|
3922
4907
|
} else if let Ok(opts_binding) = <&ConversionOptions as magnus::TryConvert>::try_convert(v) {
|
|
3923
4908
|
opts_binding.clone().into()
|
|
3924
4909
|
} else {
|
|
3925
|
-
let bridge = RbHtmlVisitorBridge::new(v)
|
|
4910
|
+
let bridge = RbHtmlVisitorBridge::new(v, String::new())?;
|
|
3926
4911
|
let handle = std::sync::Arc::new(std::sync::Mutex::new(bridge)) as html_to_markdown_rs::VisitorHandle;
|
|
3927
4912
|
let mut opts = html_to_markdown_rs::ConversionOptions::default();
|
|
3928
4913
|
opts.visitor = Some(handle);
|
|
@@ -3970,8 +4955,9 @@ impl std::fmt::Debug for RbHtmlVisitorBridge {
|
|
|
3970
4955
|
}
|
|
3971
4956
|
|
|
3972
4957
|
impl RbHtmlVisitorBridge {
|
|
3973
|
-
pub fn new(rb_obj: magnus::Value) -> Self {
|
|
3974
|
-
|
|
4958
|
+
pub fn new(rb_obj: magnus::Value, name: String) -> Result<Self, magnus::Error> {
|
|
4959
|
+
let _ = name;
|
|
4960
|
+
Ok(Self { rb_obj })
|
|
3975
4961
|
}
|
|
3976
4962
|
}
|
|
3977
4963
|
|
|
@@ -5786,6 +6772,7 @@ impl From<ConversionResult> for html_to_markdown_rs::ConversionResult {
|
|
|
5786
6772
|
Self {
|
|
5787
6773
|
content: val.content,
|
|
5788
6774
|
document: val.document.map(Into::into),
|
|
6775
|
+
#[cfg(feature = "metadata")]
|
|
5789
6776
|
metadata: val.metadata.into(),
|
|
5790
6777
|
tables: val.tables.into_iter().map(Into::into).collect(),
|
|
5791
6778
|
warnings: val.warnings.into_iter().map(Into::into).collect(),
|
|
@@ -5800,6 +6787,7 @@ impl From<html_to_markdown_rs::ConversionResult> for ConversionResult {
|
|
|
5800
6787
|
Self {
|
|
5801
6788
|
content: val.content.map(|v| v.to_string()),
|
|
5802
6789
|
document: val.document.map(Into::into),
|
|
6790
|
+
#[cfg(feature = "metadata")]
|
|
5803
6791
|
metadata: val.metadata.into(),
|
|
5804
6792
|
tables: val.tables.into_iter().map(Into::into).collect(),
|
|
5805
6793
|
warnings: val.warnings.into_iter().map(Into::into).collect(),
|
|
@@ -5807,6 +6795,7 @@ impl From<html_to_markdown_rs::ConversionResult> for ConversionResult {
|
|
|
5807
6795
|
}
|
|
5808
6796
|
}
|
|
5809
6797
|
|
|
6798
|
+
#[cfg(feature = "metadata")]
|
|
5810
6799
|
#[allow(clippy::needless_update)]
|
|
5811
6800
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
5812
6801
|
impl From<DocumentMetadata> for html_to_markdown_rs::metadata::DocumentMetadata {
|
|
@@ -5832,6 +6821,7 @@ impl From<DocumentMetadata> for html_to_markdown_rs::metadata::DocumentMetadata
|
|
|
5832
6821
|
}
|
|
5833
6822
|
}
|
|
5834
6823
|
|
|
6824
|
+
#[cfg(feature = "metadata")]
|
|
5835
6825
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
5836
6826
|
impl From<html_to_markdown_rs::metadata::DocumentMetadata> for DocumentMetadata {
|
|
5837
6827
|
fn from(val: html_to_markdown_rs::metadata::DocumentMetadata) -> Self {
|
|
@@ -5933,6 +6923,7 @@ impl From<html_to_markdown_rs::GridCell> for GridCell {
|
|
|
5933
6923
|
}
|
|
5934
6924
|
}
|
|
5935
6925
|
|
|
6926
|
+
#[cfg(feature = "metadata")]
|
|
5936
6927
|
impl From<HeaderMetadata> for html_to_markdown_rs::metadata::HeaderMetadata {
|
|
5937
6928
|
fn from(val: HeaderMetadata) -> Self {
|
|
5938
6929
|
Self {
|
|
@@ -5945,6 +6936,7 @@ impl From<HeaderMetadata> for html_to_markdown_rs::metadata::HeaderMetadata {
|
|
|
5945
6936
|
}
|
|
5946
6937
|
}
|
|
5947
6938
|
|
|
6939
|
+
#[cfg(feature = "metadata")]
|
|
5948
6940
|
#[allow(clippy::redundant_closure)]
|
|
5949
6941
|
impl From<html_to_markdown_rs::metadata::HeaderMetadata> for HeaderMetadata {
|
|
5950
6942
|
fn from(val: html_to_markdown_rs::metadata::HeaderMetadata) -> Self {
|
|
@@ -5958,29 +6950,41 @@ impl From<html_to_markdown_rs::metadata::HeaderMetadata> for HeaderMetadata {
|
|
|
5958
6950
|
}
|
|
5959
6951
|
}
|
|
5960
6952
|
|
|
6953
|
+
#[cfg(feature = "metadata")]
|
|
5961
6954
|
#[allow(clippy::needless_update)]
|
|
5962
6955
|
#[allow(clippy::useless_conversion)]
|
|
5963
6956
|
impl From<HtmlMetadata> for html_to_markdown_rs::metadata::HtmlMetadata {
|
|
5964
6957
|
fn from(val: HtmlMetadata) -> Self {
|
|
5965
6958
|
Self {
|
|
6959
|
+
#[cfg(feature = "metadata")]
|
|
5966
6960
|
document: val.document.into(),
|
|
6961
|
+
#[cfg(feature = "metadata")]
|
|
5967
6962
|
headers: val.headers.into_iter().map(Into::into).collect(),
|
|
6963
|
+
#[cfg(feature = "metadata")]
|
|
5968
6964
|
links: val.links.into_iter().map(Into::into).collect(),
|
|
6965
|
+
#[cfg(feature = "metadata")]
|
|
5969
6966
|
images: val.images.into_iter().map(Into::into).collect(),
|
|
6967
|
+
#[cfg(feature = "metadata")]
|
|
5970
6968
|
structured_data: val.structured_data.into_iter().map(Into::into).collect(),
|
|
5971
6969
|
..Default::default()
|
|
5972
6970
|
}
|
|
5973
6971
|
}
|
|
5974
6972
|
}
|
|
5975
6973
|
|
|
6974
|
+
#[cfg(feature = "metadata")]
|
|
5976
6975
|
#[allow(clippy::useless_conversion)]
|
|
5977
6976
|
impl From<html_to_markdown_rs::metadata::HtmlMetadata> for HtmlMetadata {
|
|
5978
6977
|
fn from(val: html_to_markdown_rs::metadata::HtmlMetadata) -> Self {
|
|
5979
6978
|
Self {
|
|
6979
|
+
#[cfg(feature = "metadata")]
|
|
5980
6980
|
document: val.document.into(),
|
|
6981
|
+
#[cfg(feature = "metadata")]
|
|
5981
6982
|
headers: val.headers.into_iter().map(Into::into).collect(),
|
|
6983
|
+
#[cfg(feature = "metadata")]
|
|
5982
6984
|
links: val.links.into_iter().map(Into::into).collect(),
|
|
6985
|
+
#[cfg(feature = "metadata")]
|
|
5983
6986
|
images: val.images.into_iter().map(Into::into).collect(),
|
|
6987
|
+
#[cfg(feature = "metadata")]
|
|
5984
6988
|
structured_data: val.structured_data.into_iter().map(Into::into).collect(),
|
|
5985
6989
|
}
|
|
5986
6990
|
}
|
|
@@ -6004,6 +7008,7 @@ impl From<html_to_markdown_rs::ImageDimensions> for ImageDimensions {
|
|
|
6004
7008
|
}
|
|
6005
7009
|
}
|
|
6006
7010
|
|
|
7011
|
+
#[cfg(feature = "metadata")]
|
|
6007
7012
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6008
7013
|
impl From<ImageMetadata> for html_to_markdown_rs::metadata::ImageMetadata {
|
|
6009
7014
|
fn from(val: ImageMetadata) -> Self {
|
|
@@ -6018,6 +7023,7 @@ impl From<ImageMetadata> for html_to_markdown_rs::metadata::ImageMetadata {
|
|
|
6018
7023
|
}
|
|
6019
7024
|
}
|
|
6020
7025
|
|
|
7026
|
+
#[cfg(feature = "metadata")]
|
|
6021
7027
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6022
7028
|
impl From<html_to_markdown_rs::metadata::ImageMetadata> for ImageMetadata {
|
|
6023
7029
|
fn from(val: html_to_markdown_rs::metadata::ImageMetadata) -> Self {
|
|
@@ -6032,6 +7038,7 @@ impl From<html_to_markdown_rs::metadata::ImageMetadata> for ImageMetadata {
|
|
|
6032
7038
|
}
|
|
6033
7039
|
}
|
|
6034
7040
|
|
|
7041
|
+
#[cfg(feature = "metadata")]
|
|
6035
7042
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6036
7043
|
impl From<LinkMetadata> for html_to_markdown_rs::metadata::LinkMetadata {
|
|
6037
7044
|
fn from(val: LinkMetadata) -> Self {
|
|
@@ -6046,6 +7053,7 @@ impl From<LinkMetadata> for html_to_markdown_rs::metadata::LinkMetadata {
|
|
|
6046
7053
|
}
|
|
6047
7054
|
}
|
|
6048
7055
|
|
|
7056
|
+
#[cfg(feature = "metadata")]
|
|
6049
7057
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6050
7058
|
impl From<html_to_markdown_rs::metadata::LinkMetadata> for LinkMetadata {
|
|
6051
7059
|
fn from(val: html_to_markdown_rs::metadata::LinkMetadata) -> Self {
|
|
@@ -6078,6 +7086,7 @@ impl From<html_to_markdown_rs::MetadataEntry> for MetadataEntry {
|
|
|
6078
7086
|
}
|
|
6079
7087
|
}
|
|
6080
7088
|
|
|
7089
|
+
#[cfg(feature = "visitor")]
|
|
6081
7090
|
#[allow(clippy::useless_conversion)]
|
|
6082
7091
|
impl From<NodeContext> for html_to_markdown_rs::NodeContext<'_> {
|
|
6083
7092
|
fn from(val: NodeContext) -> Self {
|
|
@@ -6093,6 +7102,7 @@ impl From<NodeContext> for html_to_markdown_rs::NodeContext<'_> {
|
|
|
6093
7102
|
}
|
|
6094
7103
|
}
|
|
6095
7104
|
|
|
7105
|
+
#[cfg(feature = "visitor")]
|
|
6096
7106
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6097
7107
|
impl From<html_to_markdown_rs::NodeContext<'_>> for NodeContext {
|
|
6098
7108
|
fn from(val: html_to_markdown_rs::NodeContext<'_>) -> Self {
|
|
@@ -6165,6 +7175,7 @@ impl From<html_to_markdown_rs::ProcessingWarning> for ProcessingWarning {
|
|
|
6165
7175
|
}
|
|
6166
7176
|
}
|
|
6167
7177
|
|
|
7178
|
+
#[cfg(feature = "metadata")]
|
|
6168
7179
|
#[allow(clippy::useless_conversion)]
|
|
6169
7180
|
impl From<StructuredData> for html_to_markdown_rs::metadata::StructuredData {
|
|
6170
7181
|
fn from(val: StructuredData) -> Self {
|
|
@@ -6176,6 +7187,7 @@ impl From<StructuredData> for html_to_markdown_rs::metadata::StructuredData {
|
|
|
6176
7187
|
}
|
|
6177
7188
|
}
|
|
6178
7189
|
|
|
7190
|
+
#[cfg(feature = "metadata")]
|
|
6179
7191
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6180
7192
|
impl From<html_to_markdown_rs::metadata::StructuredData> for StructuredData {
|
|
6181
7193
|
fn from(val: html_to_markdown_rs::metadata::StructuredData) -> Self {
|
|
@@ -6350,6 +7362,7 @@ impl From<html_to_markdown_rs::options::HighlightStyle> for HighlightStyle {
|
|
|
6350
7362
|
}
|
|
6351
7363
|
}
|
|
6352
7364
|
|
|
7365
|
+
#[cfg(feature = "metadata")]
|
|
6353
7366
|
impl From<ImageType> for html_to_markdown_rs::metadata::ImageType {
|
|
6354
7367
|
fn from(val: ImageType) -> Self {
|
|
6355
7368
|
match val {
|
|
@@ -6361,6 +7374,7 @@ impl From<ImageType> for html_to_markdown_rs::metadata::ImageType {
|
|
|
6361
7374
|
}
|
|
6362
7375
|
}
|
|
6363
7376
|
|
|
7377
|
+
#[cfg(feature = "metadata")]
|
|
6364
7378
|
impl From<html_to_markdown_rs::metadata::ImageType> for ImageType {
|
|
6365
7379
|
fn from(val: html_to_markdown_rs::metadata::ImageType) -> Self {
|
|
6366
7380
|
match val {
|
|
@@ -6390,6 +7404,7 @@ impl From<html_to_markdown_rs::options::LinkStyle> for LinkStyle {
|
|
|
6390
7404
|
}
|
|
6391
7405
|
}
|
|
6392
7406
|
|
|
7407
|
+
#[cfg(feature = "metadata")]
|
|
6393
7408
|
impl From<LinkType> for html_to_markdown_rs::metadata::LinkType {
|
|
6394
7409
|
fn from(val: LinkType) -> Self {
|
|
6395
7410
|
match val {
|
|
@@ -6403,6 +7418,7 @@ impl From<LinkType> for html_to_markdown_rs::metadata::LinkType {
|
|
|
6403
7418
|
}
|
|
6404
7419
|
}
|
|
6405
7420
|
|
|
7421
|
+
#[cfg(feature = "metadata")]
|
|
6406
7422
|
impl From<html_to_markdown_rs::metadata::LinkType> for LinkType {
|
|
6407
7423
|
fn from(val: html_to_markdown_rs::metadata::LinkType) -> Self {
|
|
6408
7424
|
match val {
|
|
@@ -6540,6 +7556,7 @@ impl From<html_to_markdown_rs::NodeContent> for NodeContent {
|
|
|
6540
7556
|
}
|
|
6541
7557
|
}
|
|
6542
7558
|
|
|
7559
|
+
#[cfg(feature = "visitor")]
|
|
6543
7560
|
impl From<NodeType> for html_to_markdown_rs::NodeType {
|
|
6544
7561
|
fn from(val: NodeType) -> Self {
|
|
6545
7562
|
match val {
|
|
@@ -6635,6 +7652,7 @@ impl From<NodeType> for html_to_markdown_rs::NodeType {
|
|
|
6635
7652
|
}
|
|
6636
7653
|
}
|
|
6637
7654
|
|
|
7655
|
+
#[cfg(feature = "visitor")]
|
|
6638
7656
|
impl From<html_to_markdown_rs::NodeType> for NodeType {
|
|
6639
7657
|
fn from(val: html_to_markdown_rs::NodeType) -> Self {
|
|
6640
7658
|
match val {
|
|
@@ -6770,6 +7788,7 @@ impl From<html_to_markdown_rs::options::PreprocessingPreset> for PreprocessingPr
|
|
|
6770
7788
|
}
|
|
6771
7789
|
}
|
|
6772
7790
|
|
|
7791
|
+
#[cfg(feature = "metadata")]
|
|
6773
7792
|
impl From<StructuredDataType> for html_to_markdown_rs::metadata::StructuredDataType {
|
|
6774
7793
|
fn from(val: StructuredDataType) -> Self {
|
|
6775
7794
|
match val {
|
|
@@ -6780,6 +7799,7 @@ impl From<StructuredDataType> for html_to_markdown_rs::metadata::StructuredDataT
|
|
|
6780
7799
|
}
|
|
6781
7800
|
}
|
|
6782
7801
|
|
|
7802
|
+
#[cfg(feature = "metadata")]
|
|
6783
7803
|
impl From<html_to_markdown_rs::metadata::StructuredDataType> for StructuredDataType {
|
|
6784
7804
|
fn from(val: html_to_markdown_rs::metadata::StructuredDataType) -> Self {
|
|
6785
7805
|
match val {
|
|
@@ -6790,6 +7810,7 @@ impl From<html_to_markdown_rs::metadata::StructuredDataType> for StructuredDataT
|
|
|
6790
7810
|
}
|
|
6791
7811
|
}
|
|
6792
7812
|
|
|
7813
|
+
#[cfg(feature = "metadata")]
|
|
6793
7814
|
impl From<TextDirection> for html_to_markdown_rs::metadata::TextDirection {
|
|
6794
7815
|
fn from(val: TextDirection) -> Self {
|
|
6795
7816
|
match val {
|
|
@@ -6800,6 +7821,7 @@ impl From<TextDirection> for html_to_markdown_rs::metadata::TextDirection {
|
|
|
6800
7821
|
}
|
|
6801
7822
|
}
|
|
6802
7823
|
|
|
7824
|
+
#[cfg(feature = "metadata")]
|
|
6803
7825
|
impl From<html_to_markdown_rs::metadata::TextDirection> for TextDirection {
|
|
6804
7826
|
fn from(val: html_to_markdown_rs::metadata::TextDirection) -> Self {
|
|
6805
7827
|
match val {
|
|
@@ -6850,6 +7872,7 @@ impl From<html_to_markdown_rs::options::UrlEscapeStyle> for UrlEscapeStyle {
|
|
|
6850
7872
|
}
|
|
6851
7873
|
}
|
|
6852
7874
|
|
|
7875
|
+
#[cfg(feature = "visitor")]
|
|
6853
7876
|
impl From<html_to_markdown_rs::VisitResult> for VisitResult {
|
|
6854
7877
|
fn from(val: html_to_markdown_rs::VisitResult) -> Self {
|
|
6855
7878
|
match val {
|
|
@@ -7153,6 +8176,7 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
7153
8176
|
|
|
7154
8177
|
class.define_method("document", method!(ConversionResult::document, 0))?;
|
|
7155
8178
|
|
|
8179
|
+
#[cfg(feature = "metadata")]
|
|
7156
8180
|
class.define_method("metadata", method!(ConversionResult::metadata, 0))?;
|
|
7157
8181
|
|
|
7158
8182
|
class.define_method("tables", method!(ConversionResult::tables, 0))?;
|
|
@@ -7163,28 +8187,40 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
7163
8187
|
|
|
7164
8188
|
let class = module.define_class("DocumentMetadata", ruby.class_object())?;
|
|
7165
8189
|
|
|
8190
|
+
#[cfg(feature = "metadata")]
|
|
7166
8191
|
class.define_singleton_method("new", function!(DocumentMetadata::new, -1))?;
|
|
7167
8192
|
|
|
8193
|
+
#[cfg(feature = "metadata")]
|
|
7168
8194
|
class.define_method("title", method!(DocumentMetadata::title, 0))?;
|
|
7169
8195
|
|
|
8196
|
+
#[cfg(feature = "metadata")]
|
|
7170
8197
|
class.define_method("description", method!(DocumentMetadata::description, 0))?;
|
|
7171
8198
|
|
|
8199
|
+
#[cfg(feature = "metadata")]
|
|
7172
8200
|
class.define_method("keywords", method!(DocumentMetadata::keywords, 0))?;
|
|
7173
8201
|
|
|
8202
|
+
#[cfg(feature = "metadata")]
|
|
7174
8203
|
class.define_method("author", method!(DocumentMetadata::author, 0))?;
|
|
7175
8204
|
|
|
8205
|
+
#[cfg(feature = "metadata")]
|
|
7176
8206
|
class.define_method("canonical_url", method!(DocumentMetadata::canonical_url, 0))?;
|
|
7177
8207
|
|
|
8208
|
+
#[cfg(feature = "metadata")]
|
|
7178
8209
|
class.define_method("base_href", method!(DocumentMetadata::base_href, 0))?;
|
|
7179
8210
|
|
|
8211
|
+
#[cfg(feature = "metadata")]
|
|
7180
8212
|
class.define_method("language", method!(DocumentMetadata::language, 0))?;
|
|
7181
8213
|
|
|
8214
|
+
#[cfg(feature = "metadata")]
|
|
7182
8215
|
class.define_method("text_direction", method!(DocumentMetadata::text_direction, 0))?;
|
|
7183
8216
|
|
|
8217
|
+
#[cfg(feature = "metadata")]
|
|
7184
8218
|
class.define_method("open_graph", method!(DocumentMetadata::open_graph, 0))?;
|
|
7185
8219
|
|
|
8220
|
+
#[cfg(feature = "metadata")]
|
|
7186
8221
|
class.define_method("twitter_card", method!(DocumentMetadata::twitter_card, 0))?;
|
|
7187
8222
|
|
|
8223
|
+
#[cfg(feature = "metadata")]
|
|
7188
8224
|
class.define_method("meta_tags", method!(DocumentMetadata::meta_tags, 0))?;
|
|
7189
8225
|
|
|
7190
8226
|
let class = module.define_class("DocumentNode", ruby.class_object())?;
|
|
@@ -7231,32 +8267,45 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
7231
8267
|
|
|
7232
8268
|
let class = module.define_class("HeaderMetadata", ruby.class_object())?;
|
|
7233
8269
|
|
|
8270
|
+
#[cfg(feature = "metadata")]
|
|
7234
8271
|
class.define_singleton_method("new", function!(HeaderMetadata::new, -1))?;
|
|
7235
8272
|
|
|
8273
|
+
#[cfg(feature = "metadata")]
|
|
7236
8274
|
class.define_method("level", method!(HeaderMetadata::level, 0))?;
|
|
7237
8275
|
|
|
8276
|
+
#[cfg(feature = "metadata")]
|
|
7238
8277
|
class.define_method("text", method!(HeaderMetadata::text, 0))?;
|
|
7239
8278
|
|
|
8279
|
+
#[cfg(feature = "metadata")]
|
|
7240
8280
|
class.define_method("id", method!(HeaderMetadata::id, 0))?;
|
|
7241
8281
|
|
|
8282
|
+
#[cfg(feature = "metadata")]
|
|
7242
8283
|
class.define_method("depth", method!(HeaderMetadata::depth, 0))?;
|
|
7243
8284
|
|
|
8285
|
+
#[cfg(feature = "metadata")]
|
|
7244
8286
|
class.define_method("html_offset", method!(HeaderMetadata::html_offset, 0))?;
|
|
7245
8287
|
|
|
8288
|
+
#[cfg(feature = "metadata")]
|
|
7246
8289
|
class.define_method("is_valid", method!(HeaderMetadata::is_valid, 0))?;
|
|
7247
8290
|
|
|
7248
8291
|
let class = module.define_class("HtmlMetadata", ruby.class_object())?;
|
|
7249
8292
|
|
|
8293
|
+
#[cfg(feature = "metadata")]
|
|
7250
8294
|
class.define_singleton_method("new", function!(HtmlMetadata::new, -1))?;
|
|
7251
8295
|
|
|
8296
|
+
#[cfg(feature = "metadata")]
|
|
7252
8297
|
class.define_method("document", method!(HtmlMetadata::document, 0))?;
|
|
7253
8298
|
|
|
8299
|
+
#[cfg(feature = "metadata")]
|
|
7254
8300
|
class.define_method("headers", method!(HtmlMetadata::headers, 0))?;
|
|
7255
8301
|
|
|
8302
|
+
#[cfg(feature = "metadata")]
|
|
7256
8303
|
class.define_method("links", method!(HtmlMetadata::links, 0))?;
|
|
7257
8304
|
|
|
8305
|
+
#[cfg(feature = "metadata")]
|
|
7258
8306
|
class.define_method("images", method!(HtmlMetadata::images, 0))?;
|
|
7259
8307
|
|
|
8308
|
+
#[cfg(feature = "metadata")]
|
|
7260
8309
|
class.define_method("structured_data", method!(HtmlMetadata::structured_data, 0))?;
|
|
7261
8310
|
|
|
7262
8311
|
let class = module.define_class("ImageDimensions", ruby.class_object())?;
|
|
@@ -7269,34 +8318,48 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
7269
8318
|
|
|
7270
8319
|
let class = module.define_class("ImageMetadata", ruby.class_object())?;
|
|
7271
8320
|
|
|
8321
|
+
#[cfg(feature = "metadata")]
|
|
7272
8322
|
class.define_singleton_method("new", function!(ImageMetadata::new, -1))?;
|
|
7273
8323
|
|
|
8324
|
+
#[cfg(feature = "metadata")]
|
|
7274
8325
|
class.define_method("src", method!(ImageMetadata::src, 0))?;
|
|
7275
8326
|
|
|
8327
|
+
#[cfg(feature = "metadata")]
|
|
7276
8328
|
class.define_method("alt", method!(ImageMetadata::alt, 0))?;
|
|
7277
8329
|
|
|
8330
|
+
#[cfg(feature = "metadata")]
|
|
7278
8331
|
class.define_method("title", method!(ImageMetadata::title, 0))?;
|
|
7279
8332
|
|
|
8333
|
+
#[cfg(feature = "metadata")]
|
|
7280
8334
|
class.define_method("dimensions", method!(ImageMetadata::dimensions, 0))?;
|
|
7281
8335
|
|
|
8336
|
+
#[cfg(feature = "metadata")]
|
|
7282
8337
|
class.define_method("image_type", method!(ImageMetadata::image_type, 0))?;
|
|
7283
8338
|
|
|
8339
|
+
#[cfg(feature = "metadata")]
|
|
7284
8340
|
class.define_method("attributes", method!(ImageMetadata::attributes, 0))?;
|
|
7285
8341
|
|
|
7286
8342
|
let class = module.define_class("LinkMetadata", ruby.class_object())?;
|
|
7287
8343
|
|
|
8344
|
+
#[cfg(feature = "metadata")]
|
|
7288
8345
|
class.define_singleton_method("new", function!(LinkMetadata::new, -1))?;
|
|
7289
8346
|
|
|
8347
|
+
#[cfg(feature = "metadata")]
|
|
7290
8348
|
class.define_method("href", method!(LinkMetadata::href, 0))?;
|
|
7291
8349
|
|
|
8350
|
+
#[cfg(feature = "metadata")]
|
|
7292
8351
|
class.define_method("text", method!(LinkMetadata::text, 0))?;
|
|
7293
8352
|
|
|
8353
|
+
#[cfg(feature = "metadata")]
|
|
7294
8354
|
class.define_method("title", method!(LinkMetadata::title, 0))?;
|
|
7295
8355
|
|
|
8356
|
+
#[cfg(feature = "metadata")]
|
|
7296
8357
|
class.define_method("link_type", method!(LinkMetadata::link_type, 0))?;
|
|
7297
8358
|
|
|
8359
|
+
#[cfg(feature = "metadata")]
|
|
7298
8360
|
class.define_method("rel", method!(LinkMetadata::rel, 0))?;
|
|
7299
8361
|
|
|
8362
|
+
#[cfg(feature = "metadata")]
|
|
7300
8363
|
class.define_method("attributes", method!(LinkMetadata::attributes, 0))?;
|
|
7301
8364
|
|
|
7302
8365
|
let class = module.define_class("MetadataEntry", ruby.class_object())?;
|
|
@@ -7309,22 +8372,31 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
7309
8372
|
|
|
7310
8373
|
let class = module.define_class("NodeContext", ruby.class_object())?;
|
|
7311
8374
|
|
|
8375
|
+
#[cfg(feature = "visitor")]
|
|
7312
8376
|
class.define_singleton_method("new", function!(NodeContext::new, -1))?;
|
|
7313
8377
|
|
|
8378
|
+
#[cfg(feature = "visitor")]
|
|
7314
8379
|
class.define_method("node_type", method!(NodeContext::node_type, 0))?;
|
|
7315
8380
|
|
|
8381
|
+
#[cfg(feature = "visitor")]
|
|
7316
8382
|
class.define_method("tag_name", method!(NodeContext::tag_name, 0))?;
|
|
7317
8383
|
|
|
8384
|
+
#[cfg(feature = "visitor")]
|
|
7318
8385
|
class.define_method("depth", method!(NodeContext::depth, 0))?;
|
|
7319
8386
|
|
|
8387
|
+
#[cfg(feature = "visitor")]
|
|
7320
8388
|
class.define_method("index_in_parent", method!(NodeContext::index_in_parent, 0))?;
|
|
7321
8389
|
|
|
8390
|
+
#[cfg(feature = "visitor")]
|
|
7322
8391
|
class.define_method("parent_tag", method!(NodeContext::parent_tag, 0))?;
|
|
7323
8392
|
|
|
8393
|
+
#[cfg(feature = "visitor")]
|
|
7324
8394
|
class.define_method("is_inline", method!(NodeContext::is_inline, 0))?;
|
|
7325
8395
|
|
|
8396
|
+
#[cfg(feature = "visitor")]
|
|
7326
8397
|
class.define_method("attributes", method!(NodeContext::attributes, 0))?;
|
|
7327
8398
|
|
|
8399
|
+
#[cfg(feature = "visitor")]
|
|
7328
8400
|
class.define_method("into_owned", method!(NodeContext::into_owned, 0))?;
|
|
7329
8401
|
|
|
7330
8402
|
let class = module.define_class("PreprocessingOptions", ruby.class_object())?;
|
|
@@ -7364,12 +8436,16 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
7364
8436
|
|
|
7365
8437
|
let class = module.define_class("StructuredData", ruby.class_object())?;
|
|
7366
8438
|
|
|
8439
|
+
#[cfg(feature = "metadata")]
|
|
7367
8440
|
class.define_singleton_method("new", function!(StructuredData::new, -1))?;
|
|
7368
8441
|
|
|
8442
|
+
#[cfg(feature = "metadata")]
|
|
7369
8443
|
class.define_method("data_type", method!(StructuredData::data_type, 0))?;
|
|
7370
8444
|
|
|
8445
|
+
#[cfg(feature = "metadata")]
|
|
7371
8446
|
class.define_method("raw_json", method!(StructuredData::raw_json, 0))?;
|
|
7372
8447
|
|
|
8448
|
+
#[cfg(feature = "metadata")]
|
|
7373
8449
|
class.define_method("schema_type", method!(StructuredData::schema_type, 0))?;
|
|
7374
8450
|
|
|
7375
8451
|
let class = module.define_class("TableData", ruby.class_object())?;
|