html-to-markdown 3.4.0.pre.rc.43 → 3.4.0.pre.rc.44
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.toml +1 -1
- data/ext/html_to_markdown_rb/src/lib.rs +478 -238
- data/lib/bin/html-to-markdown +0 -0
- data/lib/html_to_markdown/native.rb +36 -1
- data/lib/html_to_markdown/version.rb +2 -2
- data/vendor/Cargo.toml +1 -1
- data/vendor/html-to-markdown-rs/Cargo.toml +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d5a2e4bc34ff80125912031e6e942772c52769430f5520f8ab312222cdf099cb
|
|
4
|
+
data.tar.gz: e3985c9fa10a4507043670283f7965c2a04a92eb6073f917e48f1514b4dac428
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a179c7450759417b24669b8bda93462f707af97183634740a687205b7a16b2ce5169daa1369f402b17a3e9ae07a124603a6c2d3ce3f7dc5c2b1832fd42559f8
|
|
7
|
+
data.tar.gz: b56307b497e4794a1dc08b9dee9d5fd61dc0df09fa9ea40a819b7b39b8b89daa658798c0b909c2030ab9472b4b72186319f4a73a2cb6fbb194f274e783943a04
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is auto-generated by alef. DO NOT EDIT.
|
|
2
|
-
// alef:hash:
|
|
2
|
+
// alef:hash:bbf4dbc4dd189a338ff88a6816fc1b65d7c952b6a87f2a76367ebcc321db930a
|
|
3
3
|
// Re-generate with: alef generate
|
|
4
4
|
#![allow(dead_code, unused_imports, unused_variables)]
|
|
5
5
|
#![allow(
|
|
@@ -100,32 +100,50 @@ impl magnus::TryConvert for DocumentMetadata {
|
|
|
100
100
|
unsafe impl TryConvertOwned for DocumentMetadata {}
|
|
101
101
|
|
|
102
102
|
impl DocumentMetadata {
|
|
103
|
-
fn new(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
103
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
104
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
105
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
106
|
+
let (kwargs_opt,) = args.optional;
|
|
107
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
108
|
+
Ok(Self {
|
|
109
|
+
title: kwargs
|
|
110
|
+
.get(ruby.to_symbol("title"))
|
|
111
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
112
|
+
description: kwargs
|
|
113
|
+
.get(ruby.to_symbol("description"))
|
|
114
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
115
|
+
keywords: kwargs
|
|
116
|
+
.get(ruby.to_symbol("keywords"))
|
|
117
|
+
.and_then(|v| <Vec<String>>::try_convert(v).ok())
|
|
118
|
+
.unwrap_or_default(),
|
|
119
|
+
author: kwargs
|
|
120
|
+
.get(ruby.to_symbol("author"))
|
|
121
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
122
|
+
canonical_url: kwargs
|
|
123
|
+
.get(ruby.to_symbol("canonical_url"))
|
|
124
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
125
|
+
base_href: kwargs
|
|
126
|
+
.get(ruby.to_symbol("base_href"))
|
|
127
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
128
|
+
language: kwargs
|
|
129
|
+
.get(ruby.to_symbol("language"))
|
|
130
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
131
|
+
text_direction: kwargs
|
|
132
|
+
.get(ruby.to_symbol("text_direction"))
|
|
133
|
+
.and_then(|v| TextDirection::try_convert(v).ok()),
|
|
134
|
+
open_graph: kwargs
|
|
135
|
+
.get(ruby.to_symbol("open_graph"))
|
|
136
|
+
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok())
|
|
137
|
+
.unwrap_or_default(),
|
|
138
|
+
twitter_card: kwargs
|
|
139
|
+
.get(ruby.to_symbol("twitter_card"))
|
|
140
|
+
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok())
|
|
141
|
+
.unwrap_or_default(),
|
|
142
|
+
meta_tags: kwargs
|
|
143
|
+
.get(ruby.to_symbol("meta_tags"))
|
|
144
|
+
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok())
|
|
145
|
+
.unwrap_or_default(),
|
|
146
|
+
})
|
|
129
147
|
}
|
|
130
148
|
|
|
131
149
|
fn title(&self) -> Option<String> {
|
|
@@ -212,14 +230,32 @@ impl magnus::TryConvert for HeaderMetadata {
|
|
|
212
230
|
unsafe impl TryConvertOwned for HeaderMetadata {}
|
|
213
231
|
|
|
214
232
|
impl HeaderMetadata {
|
|
215
|
-
fn new(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
233
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
234
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
235
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
236
|
+
let (kwargs_opt,) = args.optional;
|
|
237
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
238
|
+
Ok(Self {
|
|
239
|
+
level: kwargs
|
|
240
|
+
.get(ruby.to_symbol("level"))
|
|
241
|
+
.and_then(|v| u8::try_convert(v).ok())
|
|
242
|
+
.unwrap_or_default(),
|
|
243
|
+
text: kwargs
|
|
244
|
+
.get(ruby.to_symbol("text"))
|
|
245
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
246
|
+
.unwrap_or_default(),
|
|
247
|
+
id: kwargs
|
|
248
|
+
.get(ruby.to_symbol("id"))
|
|
249
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
250
|
+
depth: kwargs
|
|
251
|
+
.get(ruby.to_symbol("depth"))
|
|
252
|
+
.and_then(|v| usize::try_convert(v).ok())
|
|
253
|
+
.unwrap_or_default(),
|
|
254
|
+
html_offset: kwargs
|
|
255
|
+
.get(ruby.to_symbol("html_offset"))
|
|
256
|
+
.and_then(|v| usize::try_convert(v).ok())
|
|
257
|
+
.unwrap_or_default(),
|
|
258
|
+
})
|
|
223
259
|
}
|
|
224
260
|
|
|
225
261
|
fn level(&self) -> u8 {
|
|
@@ -298,22 +334,36 @@ impl magnus::TryConvert for LinkMetadata {
|
|
|
298
334
|
unsafe impl TryConvertOwned for LinkMetadata {}
|
|
299
335
|
|
|
300
336
|
impl LinkMetadata {
|
|
301
|
-
fn new(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
text
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
337
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
338
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
339
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
340
|
+
let (kwargs_opt,) = args.optional;
|
|
341
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
342
|
+
Ok(Self {
|
|
343
|
+
href: kwargs
|
|
344
|
+
.get(ruby.to_symbol("href"))
|
|
345
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
346
|
+
.unwrap_or_default(),
|
|
347
|
+
text: kwargs
|
|
348
|
+
.get(ruby.to_symbol("text"))
|
|
349
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
350
|
+
.unwrap_or_default(),
|
|
351
|
+
title: kwargs
|
|
352
|
+
.get(ruby.to_symbol("title"))
|
|
353
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
354
|
+
link_type: kwargs
|
|
355
|
+
.get(ruby.to_symbol("link_type"))
|
|
356
|
+
.and_then(|v| LinkType::try_convert(v).ok())
|
|
357
|
+
.unwrap_or(LinkType::default()),
|
|
358
|
+
rel: kwargs
|
|
359
|
+
.get(ruby.to_symbol("rel"))
|
|
360
|
+
.and_then(|v| <Vec<String>>::try_convert(v).ok())
|
|
361
|
+
.unwrap_or_default(),
|
|
362
|
+
attributes: kwargs
|
|
363
|
+
.get(ruby.to_symbol("attributes"))
|
|
364
|
+
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok())
|
|
365
|
+
.unwrap_or_default(),
|
|
366
|
+
})
|
|
317
367
|
}
|
|
318
368
|
|
|
319
369
|
fn href(&self) -> String {
|
|
@@ -381,22 +431,34 @@ impl magnus::TryConvert for ImageMetadata {
|
|
|
381
431
|
unsafe impl TryConvertOwned for ImageMetadata {}
|
|
382
432
|
|
|
383
433
|
impl ImageMetadata {
|
|
384
|
-
fn new(
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
alt
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
434
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
435
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
436
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
437
|
+
let (kwargs_opt,) = args.optional;
|
|
438
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
439
|
+
Ok(Self {
|
|
440
|
+
src: kwargs
|
|
441
|
+
.get(ruby.to_symbol("src"))
|
|
442
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
443
|
+
.unwrap_or_default(),
|
|
444
|
+
alt: kwargs
|
|
445
|
+
.get(ruby.to_symbol("alt"))
|
|
446
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
447
|
+
title: kwargs
|
|
448
|
+
.get(ruby.to_symbol("title"))
|
|
449
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
450
|
+
dimensions: kwargs
|
|
451
|
+
.get(ruby.to_symbol("dimensions"))
|
|
452
|
+
.and_then(|v| <Vec<u32>>::try_convert(v).ok()),
|
|
453
|
+
image_type: kwargs
|
|
454
|
+
.get(ruby.to_symbol("image_type"))
|
|
455
|
+
.and_then(|v| ImageType::try_convert(v).ok())
|
|
456
|
+
.unwrap_or(ImageType::default()),
|
|
457
|
+
attributes: kwargs
|
|
458
|
+
.get(ruby.to_symbol("attributes"))
|
|
459
|
+
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok())
|
|
460
|
+
.unwrap_or_default(),
|
|
461
|
+
})
|
|
400
462
|
}
|
|
401
463
|
|
|
402
464
|
fn src(&self) -> String {
|
|
@@ -461,12 +523,24 @@ impl magnus::TryConvert for StructuredData {
|
|
|
461
523
|
unsafe impl TryConvertOwned for StructuredData {}
|
|
462
524
|
|
|
463
525
|
impl StructuredData {
|
|
464
|
-
fn new(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
526
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
527
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
528
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
529
|
+
let (kwargs_opt,) = args.optional;
|
|
530
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
531
|
+
Ok(Self {
|
|
532
|
+
data_type: kwargs
|
|
533
|
+
.get(ruby.to_symbol("data_type"))
|
|
534
|
+
.and_then(|v| StructuredDataType::try_convert(v).ok())
|
|
535
|
+
.unwrap_or(StructuredDataType::default()),
|
|
536
|
+
raw_json: kwargs
|
|
537
|
+
.get(ruby.to_symbol("raw_json"))
|
|
538
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
539
|
+
.unwrap_or_default(),
|
|
540
|
+
schema_type: kwargs
|
|
541
|
+
.get(ruby.to_symbol("schema_type"))
|
|
542
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
543
|
+
})
|
|
470
544
|
}
|
|
471
545
|
|
|
472
546
|
fn data_type(&self) -> StructuredDataType {
|
|
@@ -522,20 +596,33 @@ impl magnus::TryConvert for HtmlMetadata {
|
|
|
522
596
|
unsafe impl TryConvertOwned for HtmlMetadata {}
|
|
523
597
|
|
|
524
598
|
impl HtmlMetadata {
|
|
525
|
-
fn new(
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
599
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
600
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
601
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
602
|
+
let (kwargs_opt,) = args.optional;
|
|
603
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
604
|
+
Ok(Self {
|
|
605
|
+
document: kwargs
|
|
606
|
+
.get(ruby.to_symbol("document"))
|
|
607
|
+
.and_then(|v| DocumentMetadata::try_convert(v).ok())
|
|
608
|
+
.unwrap_or_default(),
|
|
609
|
+
headers: kwargs
|
|
610
|
+
.get(ruby.to_symbol("headers"))
|
|
611
|
+
.and_then(|v| <Vec<HeaderMetadata>>::try_convert(v).ok())
|
|
612
|
+
.unwrap_or_default(),
|
|
613
|
+
links: kwargs
|
|
614
|
+
.get(ruby.to_symbol("links"))
|
|
615
|
+
.and_then(|v| <Vec<LinkMetadata>>::try_convert(v).ok())
|
|
616
|
+
.unwrap_or_default(),
|
|
617
|
+
images: kwargs
|
|
618
|
+
.get(ruby.to_symbol("images"))
|
|
619
|
+
.and_then(|v| <Vec<ImageMetadata>>::try_convert(v).ok())
|
|
620
|
+
.unwrap_or_default(),
|
|
621
|
+
structured_data: kwargs
|
|
622
|
+
.get(ruby.to_symbol("structured_data"))
|
|
623
|
+
.and_then(|v| <Vec<StructuredData>>::try_convert(v).ok())
|
|
624
|
+
.unwrap_or_default(),
|
|
625
|
+
})
|
|
539
626
|
}
|
|
540
627
|
|
|
541
628
|
fn document(&self) -> DocumentMetadata {
|
|
@@ -1372,13 +1459,29 @@ impl magnus::TryConvert for PreprocessingOptions {
|
|
|
1372
1459
|
unsafe impl TryConvertOwned for PreprocessingOptions {}
|
|
1373
1460
|
|
|
1374
1461
|
impl PreprocessingOptions {
|
|
1375
|
-
fn new(
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1462
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1463
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
1464
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
1465
|
+
let (kwargs_opt,) = args.optional;
|
|
1466
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1467
|
+
Ok(Self {
|
|
1468
|
+
enabled: kwargs
|
|
1469
|
+
.get(ruby.to_symbol("enabled"))
|
|
1470
|
+
.and_then(|v| bool::try_convert(v).ok())
|
|
1471
|
+
.unwrap_or(true),
|
|
1472
|
+
preset: kwargs
|
|
1473
|
+
.get(ruby.to_symbol("preset"))
|
|
1474
|
+
.and_then(|v| PreprocessingPreset::try_convert(v).ok())
|
|
1475
|
+
.unwrap_or_default(),
|
|
1476
|
+
remove_navigation: kwargs
|
|
1477
|
+
.get(ruby.to_symbol("remove_navigation"))
|
|
1478
|
+
.and_then(|v| bool::try_convert(v).ok())
|
|
1479
|
+
.unwrap_or(true),
|
|
1480
|
+
remove_forms: kwargs
|
|
1481
|
+
.get(ruby.to_symbol("remove_forms"))
|
|
1482
|
+
.and_then(|v| bool::try_convert(v).ok())
|
|
1483
|
+
.unwrap_or(true),
|
|
1484
|
+
})
|
|
1382
1485
|
}
|
|
1383
1486
|
|
|
1384
1487
|
fn enabled(&self) -> bool {
|
|
@@ -1442,18 +1545,25 @@ impl magnus::TryConvert for PreprocessingOptionsUpdate {
|
|
|
1442
1545
|
unsafe impl TryConvertOwned for PreprocessingOptionsUpdate {}
|
|
1443
1546
|
|
|
1444
1547
|
impl PreprocessingOptionsUpdate {
|
|
1445
|
-
fn new(
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1548
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1549
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
1550
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
1551
|
+
let (kwargs_opt,) = args.optional;
|
|
1552
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1553
|
+
Ok(Self {
|
|
1554
|
+
enabled: kwargs
|
|
1555
|
+
.get(ruby.to_symbol("enabled"))
|
|
1556
|
+
.and_then(|v| bool::try_convert(v).ok()),
|
|
1557
|
+
preset: kwargs
|
|
1558
|
+
.get(ruby.to_symbol("preset"))
|
|
1559
|
+
.and_then(|v| PreprocessingPreset::try_convert(v).ok()),
|
|
1560
|
+
remove_navigation: kwargs
|
|
1561
|
+
.get(ruby.to_symbol("remove_navigation"))
|
|
1562
|
+
.and_then(|v| bool::try_convert(v).ok()),
|
|
1563
|
+
remove_forms: kwargs
|
|
1564
|
+
.get(ruby.to_symbol("remove_forms"))
|
|
1565
|
+
.and_then(|v| bool::try_convert(v).ok()),
|
|
1566
|
+
})
|
|
1457
1567
|
}
|
|
1458
1568
|
|
|
1459
1569
|
fn enabled(&self) -> Option<bool> {
|
|
@@ -1509,8 +1619,20 @@ impl magnus::TryConvert for DocumentStructure {
|
|
|
1509
1619
|
unsafe impl TryConvertOwned for DocumentStructure {}
|
|
1510
1620
|
|
|
1511
1621
|
impl DocumentStructure {
|
|
1512
|
-
fn new(
|
|
1513
|
-
|
|
1622
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1623
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
1624
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
1625
|
+
let (kwargs_opt,) = args.optional;
|
|
1626
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1627
|
+
Ok(Self {
|
|
1628
|
+
nodes: kwargs
|
|
1629
|
+
.get(ruby.to_symbol("nodes"))
|
|
1630
|
+
.and_then(|v| <Vec<DocumentNode>>::try_convert(v).ok())
|
|
1631
|
+
.unwrap_or_default(),
|
|
1632
|
+
source_format: kwargs
|
|
1633
|
+
.get(ruby.to_symbol("source_format"))
|
|
1634
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
1635
|
+
})
|
|
1514
1636
|
}
|
|
1515
1637
|
|
|
1516
1638
|
fn nodes(&self) -> Vec<DocumentNode> {
|
|
@@ -1562,22 +1684,35 @@ impl magnus::TryConvert for DocumentNode {
|
|
|
1562
1684
|
unsafe impl TryConvertOwned for DocumentNode {}
|
|
1563
1685
|
|
|
1564
1686
|
impl DocumentNode {
|
|
1565
|
-
fn new(
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
content
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1687
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1688
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
1689
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
1690
|
+
let (kwargs_opt,) = args.optional;
|
|
1691
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1692
|
+
Ok(Self {
|
|
1693
|
+
id: kwargs
|
|
1694
|
+
.get(ruby.to_symbol("id"))
|
|
1695
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
1696
|
+
.unwrap_or_default(),
|
|
1697
|
+
content: kwargs
|
|
1698
|
+
.get(ruby.to_symbol("content"))
|
|
1699
|
+
.and_then(|v| NodeContent::try_convert(v).ok())
|
|
1700
|
+
.unwrap_or(NodeContent::default()),
|
|
1701
|
+
parent: kwargs
|
|
1702
|
+
.get(ruby.to_symbol("parent"))
|
|
1703
|
+
.and_then(|v| u32::try_convert(v).ok()),
|
|
1704
|
+
children: kwargs
|
|
1705
|
+
.get(ruby.to_symbol("children"))
|
|
1706
|
+
.and_then(|v| <Vec<u32>>::try_convert(v).ok())
|
|
1707
|
+
.unwrap_or_default(),
|
|
1708
|
+
annotations: kwargs
|
|
1709
|
+
.get(ruby.to_symbol("annotations"))
|
|
1710
|
+
.and_then(|v| <Vec<TextAnnotation>>::try_convert(v).ok())
|
|
1711
|
+
.unwrap_or_default(),
|
|
1712
|
+
attributes: kwargs
|
|
1713
|
+
.get(ruby.to_symbol("attributes"))
|
|
1714
|
+
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok()),
|
|
1715
|
+
})
|
|
1581
1716
|
}
|
|
1582
1717
|
|
|
1583
1718
|
fn id(&self) -> String {
|
|
@@ -1642,8 +1777,25 @@ impl magnus::TryConvert for TextAnnotation {
|
|
|
1642
1777
|
unsafe impl TryConvertOwned for TextAnnotation {}
|
|
1643
1778
|
|
|
1644
1779
|
impl TextAnnotation {
|
|
1645
|
-
fn new(
|
|
1646
|
-
|
|
1780
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1781
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
1782
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
1783
|
+
let (kwargs_opt,) = args.optional;
|
|
1784
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1785
|
+
Ok(Self {
|
|
1786
|
+
start: kwargs
|
|
1787
|
+
.get(ruby.to_symbol("start"))
|
|
1788
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
1789
|
+
.unwrap_or_default(),
|
|
1790
|
+
end: kwargs
|
|
1791
|
+
.get(ruby.to_symbol("end"))
|
|
1792
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
1793
|
+
.unwrap_or_default(),
|
|
1794
|
+
kind: kwargs
|
|
1795
|
+
.get(ruby.to_symbol("kind"))
|
|
1796
|
+
.and_then(|v| AnnotationKind::try_convert(v).ok())
|
|
1797
|
+
.unwrap_or(AnnotationKind::default()),
|
|
1798
|
+
})
|
|
1647
1799
|
}
|
|
1648
1800
|
|
|
1649
1801
|
fn start(&self) -> u32 {
|
|
@@ -1700,22 +1852,35 @@ impl magnus::TryConvert for ConversionResult {
|
|
|
1700
1852
|
unsafe impl TryConvertOwned for ConversionResult {}
|
|
1701
1853
|
|
|
1702
1854
|
impl ConversionResult {
|
|
1703
|
-
fn new(
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1855
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1856
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
1857
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
1858
|
+
let (kwargs_opt,) = args.optional;
|
|
1859
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1860
|
+
Ok(Self {
|
|
1861
|
+
content: kwargs
|
|
1862
|
+
.get(ruby.to_symbol("content"))
|
|
1863
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
1864
|
+
document: kwargs
|
|
1865
|
+
.get(ruby.to_symbol("document"))
|
|
1866
|
+
.and_then(|v| DocumentStructure::try_convert(v).ok()),
|
|
1867
|
+
metadata: kwargs
|
|
1868
|
+
.get(ruby.to_symbol("metadata"))
|
|
1869
|
+
.and_then(|v| HtmlMetadata::try_convert(v).ok())
|
|
1870
|
+
.unwrap_or_default(),
|
|
1871
|
+
tables: kwargs
|
|
1872
|
+
.get(ruby.to_symbol("tables"))
|
|
1873
|
+
.and_then(|v| <Vec<TableData>>::try_convert(v).ok())
|
|
1874
|
+
.unwrap_or_default(),
|
|
1875
|
+
images: kwargs
|
|
1876
|
+
.get(ruby.to_symbol("images"))
|
|
1877
|
+
.and_then(|v| <Vec<String>>::try_convert(v).ok())
|
|
1878
|
+
.unwrap_or_default(),
|
|
1879
|
+
warnings: kwargs
|
|
1880
|
+
.get(ruby.to_symbol("warnings"))
|
|
1881
|
+
.and_then(|v| <Vec<ProcessingWarning>>::try_convert(v).ok())
|
|
1882
|
+
.unwrap_or_default(),
|
|
1883
|
+
})
|
|
1719
1884
|
}
|
|
1720
1885
|
|
|
1721
1886
|
fn content(&self) -> Option<String> {
|
|
@@ -1786,8 +1951,25 @@ impl magnus::TryConvert for TableGrid {
|
|
|
1786
1951
|
unsafe impl TryConvertOwned for TableGrid {}
|
|
1787
1952
|
|
|
1788
1953
|
impl TableGrid {
|
|
1789
|
-
fn new(
|
|
1790
|
-
|
|
1954
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1955
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
1956
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
1957
|
+
let (kwargs_opt,) = args.optional;
|
|
1958
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1959
|
+
Ok(Self {
|
|
1960
|
+
rows: kwargs
|
|
1961
|
+
.get(ruby.to_symbol("rows"))
|
|
1962
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
1963
|
+
.unwrap_or_default(),
|
|
1964
|
+
cols: kwargs
|
|
1965
|
+
.get(ruby.to_symbol("cols"))
|
|
1966
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
1967
|
+
.unwrap_or_default(),
|
|
1968
|
+
cells: kwargs
|
|
1969
|
+
.get(ruby.to_symbol("cells"))
|
|
1970
|
+
.and_then(|v| <Vec<GridCell>>::try_convert(v).ok())
|
|
1971
|
+
.unwrap_or_default(),
|
|
1972
|
+
})
|
|
1791
1973
|
}
|
|
1792
1974
|
|
|
1793
1975
|
fn rows(&self) -> u32 {
|
|
@@ -1843,15 +2025,37 @@ impl magnus::TryConvert for GridCell {
|
|
|
1843
2025
|
unsafe impl TryConvertOwned for GridCell {}
|
|
1844
2026
|
|
|
1845
2027
|
impl GridCell {
|
|
1846
|
-
fn new(
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
2028
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
2029
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2030
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
2031
|
+
let (kwargs_opt,) = args.optional;
|
|
2032
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2033
|
+
Ok(Self {
|
|
2034
|
+
content: kwargs
|
|
2035
|
+
.get(ruby.to_symbol("content"))
|
|
2036
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
2037
|
+
.unwrap_or_default(),
|
|
2038
|
+
row: kwargs
|
|
2039
|
+
.get(ruby.to_symbol("row"))
|
|
2040
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
2041
|
+
.unwrap_or_default(),
|
|
2042
|
+
col: kwargs
|
|
2043
|
+
.get(ruby.to_symbol("col"))
|
|
2044
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
2045
|
+
.unwrap_or_default(),
|
|
2046
|
+
row_span: kwargs
|
|
2047
|
+
.get(ruby.to_symbol("row_span"))
|
|
2048
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
2049
|
+
.unwrap_or_default(),
|
|
2050
|
+
col_span: kwargs
|
|
2051
|
+
.get(ruby.to_symbol("col_span"))
|
|
2052
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
2053
|
+
.unwrap_or_default(),
|
|
2054
|
+
is_header: kwargs
|
|
2055
|
+
.get(ruby.to_symbol("is_header"))
|
|
2056
|
+
.and_then(|v| bool::try_convert(v).ok())
|
|
2057
|
+
.unwrap_or_default(),
|
|
2058
|
+
})
|
|
1855
2059
|
}
|
|
1856
2060
|
|
|
1857
2061
|
fn content(&self) -> String {
|
|
@@ -1920,8 +2124,21 @@ impl magnus::TryConvert for TableData {
|
|
|
1920
2124
|
unsafe impl TryConvertOwned for TableData {}
|
|
1921
2125
|
|
|
1922
2126
|
impl TableData {
|
|
1923
|
-
fn new(
|
|
1924
|
-
|
|
2127
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
2128
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2129
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
2130
|
+
let (kwargs_opt,) = args.optional;
|
|
2131
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2132
|
+
Ok(Self {
|
|
2133
|
+
grid: kwargs
|
|
2134
|
+
.get(ruby.to_symbol("grid"))
|
|
2135
|
+
.and_then(|v| TableGrid::try_convert(v).ok())
|
|
2136
|
+
.unwrap_or(TableGrid::default()),
|
|
2137
|
+
markdown: kwargs
|
|
2138
|
+
.get(ruby.to_symbol("markdown"))
|
|
2139
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
2140
|
+
.unwrap_or_default(),
|
|
2141
|
+
})
|
|
1925
2142
|
}
|
|
1926
2143
|
|
|
1927
2144
|
fn grid(&self) -> TableGrid {
|
|
@@ -1969,8 +2186,21 @@ impl magnus::TryConvert for ProcessingWarning {
|
|
|
1969
2186
|
unsafe impl TryConvertOwned for ProcessingWarning {}
|
|
1970
2187
|
|
|
1971
2188
|
impl ProcessingWarning {
|
|
1972
|
-
fn new(
|
|
1973
|
-
|
|
2189
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
2190
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2191
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
2192
|
+
let (kwargs_opt,) = args.optional;
|
|
2193
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2194
|
+
Ok(Self {
|
|
2195
|
+
message: kwargs
|
|
2196
|
+
.get(ruby.to_symbol("message"))
|
|
2197
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
2198
|
+
.unwrap_or_default(),
|
|
2199
|
+
kind: kwargs
|
|
2200
|
+
.get(ruby.to_symbol("kind"))
|
|
2201
|
+
.and_then(|v| WarningKind::try_convert(v).ok())
|
|
2202
|
+
.unwrap_or(WarningKind::default()),
|
|
2203
|
+
})
|
|
1974
2204
|
}
|
|
1975
2205
|
|
|
1976
2206
|
fn message(&self) -> String {
|
|
@@ -2023,24 +2253,40 @@ impl magnus::TryConvert for NodeContext {
|
|
|
2023
2253
|
unsafe impl TryConvertOwned for NodeContext {}
|
|
2024
2254
|
|
|
2025
2255
|
impl NodeContext {
|
|
2026
|
-
fn new(
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2256
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
2257
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2258
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
2259
|
+
let (kwargs_opt,) = args.optional;
|
|
2260
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2261
|
+
Ok(Self {
|
|
2262
|
+
node_type: kwargs
|
|
2263
|
+
.get(ruby.to_symbol("node_type"))
|
|
2264
|
+
.and_then(|v| NodeType::try_convert(v).ok())
|
|
2265
|
+
.unwrap_or(NodeType::default()),
|
|
2266
|
+
tag_name: kwargs
|
|
2267
|
+
.get(ruby.to_symbol("tag_name"))
|
|
2268
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
2269
|
+
.unwrap_or_default(),
|
|
2270
|
+
attributes: kwargs
|
|
2271
|
+
.get(ruby.to_symbol("attributes"))
|
|
2272
|
+
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok())
|
|
2273
|
+
.unwrap_or_default(),
|
|
2274
|
+
depth: kwargs
|
|
2275
|
+
.get(ruby.to_symbol("depth"))
|
|
2276
|
+
.and_then(|v| usize::try_convert(v).ok())
|
|
2277
|
+
.unwrap_or_default(),
|
|
2278
|
+
index_in_parent: kwargs
|
|
2279
|
+
.get(ruby.to_symbol("index_in_parent"))
|
|
2280
|
+
.and_then(|v| usize::try_convert(v).ok())
|
|
2281
|
+
.unwrap_or_default(),
|
|
2282
|
+
parent_tag: kwargs
|
|
2283
|
+
.get(ruby.to_symbol("parent_tag"))
|
|
2284
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
2285
|
+
is_inline: kwargs
|
|
2286
|
+
.get(ruby.to_symbol("is_inline"))
|
|
2287
|
+
.and_then(|v| bool::try_convert(v).ok())
|
|
2288
|
+
.unwrap_or_default(),
|
|
2289
|
+
})
|
|
2044
2290
|
}
|
|
2045
2291
|
|
|
2046
2292
|
fn node_type(&self) -> NodeType {
|
|
@@ -2118,6 +2364,7 @@ unsafe impl IntoValueFromNative for TextDirection {}
|
|
|
2118
2364
|
unsafe impl TryConvertOwned for TextDirection {}
|
|
2119
2365
|
|
|
2120
2366
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
2367
|
+
#[serde(rename_all = "snake_case")]
|
|
2121
2368
|
pub enum LinkType {
|
|
2122
2369
|
Anchor,
|
|
2123
2370
|
Internal,
|
|
@@ -2169,6 +2416,7 @@ unsafe impl IntoValueFromNative for LinkType {}
|
|
|
2169
2416
|
unsafe impl TryConvertOwned for LinkType {}
|
|
2170
2417
|
|
|
2171
2418
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
2419
|
+
#[serde(rename_all = "snake_case")]
|
|
2172
2420
|
pub enum ImageType {
|
|
2173
2421
|
DataUri,
|
|
2174
2422
|
InlineSvg,
|
|
@@ -2214,6 +2462,7 @@ unsafe impl IntoValueFromNative for ImageType {}
|
|
|
2214
2462
|
unsafe impl TryConvertOwned for ImageType {}
|
|
2215
2463
|
|
|
2216
2464
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
2465
|
+
#[serde(rename_all = "snake_case")]
|
|
2217
2466
|
pub enum StructuredDataType {
|
|
2218
2467
|
#[serde(rename = "json_ld")]
|
|
2219
2468
|
JsonLd,
|
|
@@ -2628,6 +2877,7 @@ unsafe impl TryConvertOwned for OutputFormat {}
|
|
|
2628
2877
|
|
|
2629
2878
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
2630
2879
|
#[serde(tag = "node_type")]
|
|
2880
|
+
#[serde(rename_all = "snake_case")]
|
|
2631
2881
|
pub enum NodeContent {
|
|
2632
2882
|
Heading {
|
|
2633
2883
|
level: u8,
|
|
@@ -2695,48 +2945,29 @@ impl magnus::IntoValue for NodeContent {
|
|
|
2695
2945
|
impl magnus::TryConvert for NodeContent {
|
|
2696
2946
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2697
2947
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
2948
|
+
// Try deserializing as JSON first (handles JSON strings like "\"markdown\"")
|
|
2949
|
+
// If that fails, try treating it as a plain string value and wrap in quotes
|
|
2950
|
+
// If both fail, try as Custom variant (for untagged enum support)
|
|
2698
2951
|
serde_json::from_str(&s)
|
|
2952
|
+
.or_else(|_| serde_json::from_str(&format!("\"{s}\"")))
|
|
2953
|
+
.or_else(|_| {
|
|
2954
|
+
// Try as a JSON string for Custom variant (untagged enums accept any remaining value)
|
|
2955
|
+
match serde_json::to_value(&s) {
|
|
2956
|
+
Ok(val) => serde_json::from_value(val),
|
|
2957
|
+
Err(e) => Err(e),
|
|
2958
|
+
}
|
|
2959
|
+
})
|
|
2699
2960
|
.map_err(|e| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_type_error(), e.to_string()))
|
|
2700
2961
|
}
|
|
2701
2962
|
}
|
|
2702
2963
|
|
|
2703
2964
|
unsafe impl IntoValueFromNative for NodeContent {}
|
|
2704
2965
|
unsafe impl TryConvertOwned for NodeContent {}
|
|
2705
|
-
impl NodeContent {
|
|
2706
|
-
fn paragraph(&self) -> Option<String> {
|
|
2707
|
-
match self {
|
|
2708
|
-
Self::Paragraph { text } => Some(text.clone()),
|
|
2709
|
-
_ => None,
|
|
2710
|
-
}
|
|
2711
|
-
}
|
|
2712
|
-
fn list(&self) -> Option<bool> {
|
|
2713
|
-
match self {
|
|
2714
|
-
Self::List { ordered } => Some(ordered.clone()),
|
|
2715
|
-
_ => None,
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
fn list_item(&self) -> Option<String> {
|
|
2719
|
-
match self {
|
|
2720
|
-
Self::ListItem { text } => Some(text.clone()),
|
|
2721
|
-
_ => None,
|
|
2722
|
-
}
|
|
2723
|
-
}
|
|
2724
|
-
fn table(&self) -> Option<TableGrid> {
|
|
2725
|
-
match self {
|
|
2726
|
-
Self::Table { grid } => Some(grid.clone()),
|
|
2727
|
-
_ => None,
|
|
2728
|
-
}
|
|
2729
|
-
}
|
|
2730
|
-
fn metadata_block(&self) -> Option<Vec<String>> {
|
|
2731
|
-
match self {
|
|
2732
|
-
Self::MetadataBlock { entries } => Some(entries.clone()),
|
|
2733
|
-
_ => None,
|
|
2734
|
-
}
|
|
2735
|
-
}
|
|
2736
|
-
}
|
|
2966
|
+
impl NodeContent {}
|
|
2737
2967
|
|
|
2738
2968
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
2739
2969
|
#[serde(tag = "annotation_type")]
|
|
2970
|
+
#[serde(rename_all = "snake_case")]
|
|
2740
2971
|
pub enum AnnotationKind {
|
|
2741
2972
|
Bold,
|
|
2742
2973
|
Italic,
|
|
@@ -2767,7 +2998,18 @@ impl magnus::IntoValue for AnnotationKind {
|
|
|
2767
2998
|
impl magnus::TryConvert for AnnotationKind {
|
|
2768
2999
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2769
3000
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3001
|
+
// Try deserializing as JSON first (handles JSON strings like "\"markdown\"")
|
|
3002
|
+
// If that fails, try treating it as a plain string value and wrap in quotes
|
|
3003
|
+
// If both fail, try as Custom variant (for untagged enum support)
|
|
2770
3004
|
serde_json::from_str(&s)
|
|
3005
|
+
.or_else(|_| serde_json::from_str(&format!("\"{s}\"")))
|
|
3006
|
+
.or_else(|_| {
|
|
3007
|
+
// Try as a JSON string for Custom variant (untagged enums accept any remaining value)
|
|
3008
|
+
match serde_json::to_value(&s) {
|
|
3009
|
+
Ok(val) => serde_json::from_value(val),
|
|
3010
|
+
Err(e) => Err(e),
|
|
3011
|
+
}
|
|
3012
|
+
})
|
|
2771
3013
|
.map_err(|e| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_type_error(), e.to_string()))
|
|
2772
3014
|
}
|
|
2773
3015
|
}
|
|
@@ -2777,6 +3019,7 @@ unsafe impl TryConvertOwned for AnnotationKind {}
|
|
|
2777
3019
|
impl AnnotationKind {}
|
|
2778
3020
|
|
|
2779
3021
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
3022
|
+
#[serde(rename_all = "snake_case")]
|
|
2780
3023
|
pub enum WarningKind {
|
|
2781
3024
|
ImageExtractionFailed,
|
|
2782
3025
|
EncodingFallback,
|
|
@@ -3151,27 +3394,24 @@ impl magnus::IntoValue for VisitResult {
|
|
|
3151
3394
|
impl magnus::TryConvert for VisitResult {
|
|
3152
3395
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
3153
3396
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3397
|
+
// Try deserializing as JSON first (handles JSON strings like "\"markdown\"")
|
|
3398
|
+
// If that fails, try treating it as a plain string value and wrap in quotes
|
|
3399
|
+
// If both fail, try as Custom variant (for untagged enum support)
|
|
3154
3400
|
serde_json::from_str(&s)
|
|
3401
|
+
.or_else(|_| serde_json::from_str(&format!("\"{s}\"")))
|
|
3402
|
+
.or_else(|_| {
|
|
3403
|
+
// Try as a JSON string for Custom variant (untagged enums accept any remaining value)
|
|
3404
|
+
match serde_json::to_value(&s) {
|
|
3405
|
+
Ok(val) => serde_json::from_value(val),
|
|
3406
|
+
Err(e) => Err(e),
|
|
3407
|
+
}
|
|
3408
|
+
})
|
|
3155
3409
|
.map_err(|e| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_type_error(), e.to_string()))
|
|
3156
3410
|
}
|
|
3157
3411
|
}
|
|
3158
3412
|
|
|
3159
3413
|
unsafe impl IntoValueFromNative for VisitResult {}
|
|
3160
3414
|
unsafe impl TryConvertOwned for VisitResult {}
|
|
3161
|
-
impl VisitResult {
|
|
3162
|
-
fn custom(&self) -> Option<String> {
|
|
3163
|
-
match self {
|
|
3164
|
-
Self::Custom { _0 } => Some(_0.clone()),
|
|
3165
|
-
_ => None,
|
|
3166
|
-
}
|
|
3167
|
-
}
|
|
3168
|
-
fn error(&self) -> Option<String> {
|
|
3169
|
-
match self {
|
|
3170
|
-
Self::Error { _0 } => Some(_0.clone()),
|
|
3171
|
-
_ => None,
|
|
3172
|
-
}
|
|
3173
|
-
}
|
|
3174
|
-
}
|
|
3175
3415
|
|
|
3176
3416
|
#[allow(clippy::missing_errors_doc)]
|
|
3177
3417
|
#[allow(unused_variables)]
|
|
@@ -5912,7 +6152,7 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
5912
6152
|
let module = ruby.define_module("HtmlToMarkdownRs")?;
|
|
5913
6153
|
|
|
5914
6154
|
let class = module.define_class("DocumentMetadata", ruby.class_object())?;
|
|
5915
|
-
class.define_singleton_method("new", function!(DocumentMetadata::new,
|
|
6155
|
+
class.define_singleton_method("new", function!(DocumentMetadata::new, -1))?;
|
|
5916
6156
|
class.define_method("title", method!(DocumentMetadata::title, 0))?;
|
|
5917
6157
|
class.define_method("description", method!(DocumentMetadata::description, 0))?;
|
|
5918
6158
|
class.define_method("keywords", method!(DocumentMetadata::keywords, 0))?;
|
|
@@ -5926,7 +6166,7 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
5926
6166
|
class.define_method("meta_tags", method!(DocumentMetadata::meta_tags, 0))?;
|
|
5927
6167
|
|
|
5928
6168
|
let class = module.define_class("HeaderMetadata", ruby.class_object())?;
|
|
5929
|
-
class.define_singleton_method("new", function!(HeaderMetadata::new,
|
|
6169
|
+
class.define_singleton_method("new", function!(HeaderMetadata::new, -1))?;
|
|
5930
6170
|
class.define_method("level", method!(HeaderMetadata::level, 0))?;
|
|
5931
6171
|
class.define_method("text", method!(HeaderMetadata::text, 0))?;
|
|
5932
6172
|
class.define_method("id", method!(HeaderMetadata::id, 0))?;
|
|
@@ -5935,7 +6175,7 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
5935
6175
|
class.define_method("is_valid", method!(HeaderMetadata::is_valid, 0))?;
|
|
5936
6176
|
|
|
5937
6177
|
let class = module.define_class("LinkMetadata", ruby.class_object())?;
|
|
5938
|
-
class.define_singleton_method("new", function!(LinkMetadata::new,
|
|
6178
|
+
class.define_singleton_method("new", function!(LinkMetadata::new, -1))?;
|
|
5939
6179
|
class.define_method("href", method!(LinkMetadata::href, 0))?;
|
|
5940
6180
|
class.define_method("text", method!(LinkMetadata::text, 0))?;
|
|
5941
6181
|
class.define_method("title", method!(LinkMetadata::title, 0))?;
|
|
@@ -5944,7 +6184,7 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
5944
6184
|
class.define_method("attributes", method!(LinkMetadata::attributes, 0))?;
|
|
5945
6185
|
|
|
5946
6186
|
let class = module.define_class("ImageMetadata", ruby.class_object())?;
|
|
5947
|
-
class.define_singleton_method("new", function!(ImageMetadata::new,
|
|
6187
|
+
class.define_singleton_method("new", function!(ImageMetadata::new, -1))?;
|
|
5948
6188
|
class.define_method("src", method!(ImageMetadata::src, 0))?;
|
|
5949
6189
|
class.define_method("alt", method!(ImageMetadata::alt, 0))?;
|
|
5950
6190
|
class.define_method("title", method!(ImageMetadata::title, 0))?;
|
|
@@ -5953,13 +6193,13 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
5953
6193
|
class.define_method("attributes", method!(ImageMetadata::attributes, 0))?;
|
|
5954
6194
|
|
|
5955
6195
|
let class = module.define_class("StructuredData", ruby.class_object())?;
|
|
5956
|
-
class.define_singleton_method("new", function!(StructuredData::new,
|
|
6196
|
+
class.define_singleton_method("new", function!(StructuredData::new, -1))?;
|
|
5957
6197
|
class.define_method("data_type", method!(StructuredData::data_type, 0))?;
|
|
5958
6198
|
class.define_method("raw_json", method!(StructuredData::raw_json, 0))?;
|
|
5959
6199
|
class.define_method("schema_type", method!(StructuredData::schema_type, 0))?;
|
|
5960
6200
|
|
|
5961
6201
|
let class = module.define_class("HtmlMetadata", ruby.class_object())?;
|
|
5962
|
-
class.define_singleton_method("new", function!(HtmlMetadata::new,
|
|
6202
|
+
class.define_singleton_method("new", function!(HtmlMetadata::new, -1))?;
|
|
5963
6203
|
class.define_method("document", method!(HtmlMetadata::document, 0))?;
|
|
5964
6204
|
class.define_method("headers", method!(HtmlMetadata::headers, 0))?;
|
|
5965
6205
|
class.define_method("links", method!(HtmlMetadata::links, 0))?;
|
|
@@ -6095,14 +6335,14 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
6095
6335
|
)?;
|
|
6096
6336
|
|
|
6097
6337
|
let class = module.define_class("PreprocessingOptions", ruby.class_object())?;
|
|
6098
|
-
class.define_singleton_method("new", function!(PreprocessingOptions::new,
|
|
6338
|
+
class.define_singleton_method("new", function!(PreprocessingOptions::new, -1))?;
|
|
6099
6339
|
class.define_method("enabled", method!(PreprocessingOptions::enabled, 0))?;
|
|
6100
6340
|
class.define_method("preset", method!(PreprocessingOptions::preset, 0))?;
|
|
6101
6341
|
class.define_method("remove_navigation", method!(PreprocessingOptions::remove_navigation, 0))?;
|
|
6102
6342
|
class.define_method("remove_forms", method!(PreprocessingOptions::remove_forms, 0))?;
|
|
6103
6343
|
|
|
6104
6344
|
let class = module.define_class("PreprocessingOptionsUpdate", ruby.class_object())?;
|
|
6105
|
-
class.define_singleton_method("new", function!(PreprocessingOptionsUpdate::new,
|
|
6345
|
+
class.define_singleton_method("new", function!(PreprocessingOptionsUpdate::new, -1))?;
|
|
6106
6346
|
class.define_method("enabled", method!(PreprocessingOptionsUpdate::enabled, 0))?;
|
|
6107
6347
|
class.define_method("preset", method!(PreprocessingOptionsUpdate::preset, 0))?;
|
|
6108
6348
|
class.define_method(
|
|
@@ -6112,12 +6352,12 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
6112
6352
|
class.define_method("remove_forms", method!(PreprocessingOptionsUpdate::remove_forms, 0))?;
|
|
6113
6353
|
|
|
6114
6354
|
let class = module.define_class("DocumentStructure", ruby.class_object())?;
|
|
6115
|
-
class.define_singleton_method("new", function!(DocumentStructure::new,
|
|
6355
|
+
class.define_singleton_method("new", function!(DocumentStructure::new, -1))?;
|
|
6116
6356
|
class.define_method("nodes", method!(DocumentStructure::nodes, 0))?;
|
|
6117
6357
|
class.define_method("source_format", method!(DocumentStructure::source_format, 0))?;
|
|
6118
6358
|
|
|
6119
6359
|
let class = module.define_class("DocumentNode", ruby.class_object())?;
|
|
6120
|
-
class.define_singleton_method("new", function!(DocumentNode::new,
|
|
6360
|
+
class.define_singleton_method("new", function!(DocumentNode::new, -1))?;
|
|
6121
6361
|
class.define_method("id", method!(DocumentNode::id, 0))?;
|
|
6122
6362
|
class.define_method("content", method!(DocumentNode::content, 0))?;
|
|
6123
6363
|
class.define_method("parent", method!(DocumentNode::parent, 0))?;
|
|
@@ -6126,13 +6366,13 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
6126
6366
|
class.define_method("attributes", method!(DocumentNode::attributes, 0))?;
|
|
6127
6367
|
|
|
6128
6368
|
let class = module.define_class("TextAnnotation", ruby.class_object())?;
|
|
6129
|
-
class.define_singleton_method("new", function!(TextAnnotation::new,
|
|
6369
|
+
class.define_singleton_method("new", function!(TextAnnotation::new, -1))?;
|
|
6130
6370
|
class.define_method("start", method!(TextAnnotation::start, 0))?;
|
|
6131
6371
|
class.define_method("end", method!(TextAnnotation::end, 0))?;
|
|
6132
6372
|
class.define_method("kind", method!(TextAnnotation::kind, 0))?;
|
|
6133
6373
|
|
|
6134
6374
|
let class = module.define_class("ConversionResult", ruby.class_object())?;
|
|
6135
|
-
class.define_singleton_method("new", function!(ConversionResult::new,
|
|
6375
|
+
class.define_singleton_method("new", function!(ConversionResult::new, -1))?;
|
|
6136
6376
|
class.define_method("content", method!(ConversionResult::content, 0))?;
|
|
6137
6377
|
class.define_method("document", method!(ConversionResult::document, 0))?;
|
|
6138
6378
|
class.define_method("metadata", method!(ConversionResult::metadata, 0))?;
|
|
@@ -6142,13 +6382,13 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
6142
6382
|
class.define_method("to_s", method!(ConversionResult::to_s, 0))?;
|
|
6143
6383
|
|
|
6144
6384
|
let class = module.define_class("TableGrid", ruby.class_object())?;
|
|
6145
|
-
class.define_singleton_method("new", function!(TableGrid::new,
|
|
6385
|
+
class.define_singleton_method("new", function!(TableGrid::new, -1))?;
|
|
6146
6386
|
class.define_method("rows", method!(TableGrid::rows, 0))?;
|
|
6147
6387
|
class.define_method("cols", method!(TableGrid::cols, 0))?;
|
|
6148
6388
|
class.define_method("cells", method!(TableGrid::cells, 0))?;
|
|
6149
6389
|
|
|
6150
6390
|
let class = module.define_class("GridCell", ruby.class_object())?;
|
|
6151
|
-
class.define_singleton_method("new", function!(GridCell::new,
|
|
6391
|
+
class.define_singleton_method("new", function!(GridCell::new, -1))?;
|
|
6152
6392
|
class.define_method("content", method!(GridCell::content, 0))?;
|
|
6153
6393
|
class.define_method("row", method!(GridCell::row, 0))?;
|
|
6154
6394
|
class.define_method("col", method!(GridCell::col, 0))?;
|
|
@@ -6158,17 +6398,17 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
6158
6398
|
class.define_method("to_s", method!(GridCell::to_s, 0))?;
|
|
6159
6399
|
|
|
6160
6400
|
let class = module.define_class("TableData", ruby.class_object())?;
|
|
6161
|
-
class.define_singleton_method("new", function!(TableData::new,
|
|
6401
|
+
class.define_singleton_method("new", function!(TableData::new, -1))?;
|
|
6162
6402
|
class.define_method("grid", method!(TableData::grid, 0))?;
|
|
6163
6403
|
class.define_method("markdown", method!(TableData::markdown, 0))?;
|
|
6164
6404
|
|
|
6165
6405
|
let class = module.define_class("ProcessingWarning", ruby.class_object())?;
|
|
6166
|
-
class.define_singleton_method("new", function!(ProcessingWarning::new,
|
|
6406
|
+
class.define_singleton_method("new", function!(ProcessingWarning::new, -1))?;
|
|
6167
6407
|
class.define_method("message", method!(ProcessingWarning::message, 0))?;
|
|
6168
6408
|
class.define_method("kind", method!(ProcessingWarning::kind, 0))?;
|
|
6169
6409
|
|
|
6170
6410
|
let class = module.define_class("NodeContext", ruby.class_object())?;
|
|
6171
|
-
class.define_singleton_method("new", function!(NodeContext::new,
|
|
6411
|
+
class.define_singleton_method("new", function!(NodeContext::new, -1))?;
|
|
6172
6412
|
class.define_method("node_type", method!(NodeContext::node_type, 0))?;
|
|
6173
6413
|
class.define_method("tag_name", method!(NodeContext::tag_name, 0))?;
|
|
6174
6414
|
class.define_method("attributes", method!(NodeContext::attributes, 0))?;
|
data/lib/bin/html-to-markdown
CHANGED
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:1bd3c99db21c2ca078644f1e220656297c784bcca532f13d3b7efed3f45dbb0b
|
|
3
3
|
# To regenerate: alef generate
|
|
4
4
|
# To verify freshness: alef verify --exit-code
|
|
5
5
|
# Issues & docs: https://github.com/kreuzberg-dev/alef
|
|
@@ -18,3 +18,38 @@ module HtmlToMarkdown
|
|
|
18
18
|
const_set(c, HtmlToMarkdownRs.const_get(c)) unless const_defined?(c)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
# Add accessor methods to Hash-based internally-tagged enum instances
|
|
23
|
+
class Hash
|
|
24
|
+
# Support internally-tagged enum accessors like format.excel, format.email, etc.
|
|
25
|
+
# Also support direct field access like format.sheet_count
|
|
26
|
+
def method_missing(method_name, *args, &)
|
|
27
|
+
# Try symbol key first (how Magnus converts JSON keys)
|
|
28
|
+
return self[method_name] if key?(method_name)
|
|
29
|
+
|
|
30
|
+
# Try string key
|
|
31
|
+
return self[method_name.to_s] if key?(method_name.to_s)
|
|
32
|
+
|
|
33
|
+
# Check if this hash has a 'format_type' field (indicating an internally-tagged enum)
|
|
34
|
+
format_type = self[:format_type] || self['format_type']
|
|
35
|
+
return super unless format_type
|
|
36
|
+
|
|
37
|
+
# If the method name matches the format_type (snake_case), extract and return the variant's wrapped data
|
|
38
|
+
# Internally-tagged enums store variant data in the '_0' field (from alef's struct variant conversion)
|
|
39
|
+
# This allows format.excel to return the ExcelMetadata hash with sheet_count, sheet_names, etc.
|
|
40
|
+
snake_case_method = method_name.to_s.downcase
|
|
41
|
+
return self[:_0] || self['_0'] || self if snake_case_method == format_type.to_s.downcase
|
|
42
|
+
|
|
43
|
+
super
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def respond_to_missing?(method_name, include_private = false)
|
|
47
|
+
return true if key?(method_name) || key?(method_name.to_s)
|
|
48
|
+
|
|
49
|
+
format_type = self[:format_type] || self['format_type']
|
|
50
|
+
return false unless format_type
|
|
51
|
+
|
|
52
|
+
snake_case_method = method_name.to_s.downcase
|
|
53
|
+
snake_case_method == format_type.to_s.downcase || super
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:4ce3ba64cbea5c72b082111f57a04e219e555fda52859a9673edcec555031706
|
|
3
3
|
# To regenerate: alef generate
|
|
4
4
|
# To verify freshness: alef verify --exit-code
|
|
5
5
|
# Issues & docs: https://github.com/kreuzberg-dev/alef
|
|
6
6
|
# frozen_string_literal: true
|
|
7
7
|
|
|
8
8
|
module HtmlToMarkdown
|
|
9
|
-
VERSION = '3.4.0.pre.rc.
|
|
9
|
+
VERSION = '3.4.0.pre.rc.44'
|
|
10
10
|
end
|
data/vendor/Cargo.toml
CHANGED