html-to-markdown 3.4.0 → 3.6.0.pre.rc.23
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/LICENSE +21 -0
- data/README.md +347 -0
- data/Steepfile +10 -2
- data/ext/html_to_markdown_rb/Cargo.toml +3 -2
- data/ext/html_to_markdown_rb/extconf.rb +5 -5
- data/ext/html_to_markdown_rb/native/Cargo.lock +962 -0
- data/ext/html_to_markdown_rb/native/Cargo.toml +6 -11
- data/ext/html_to_markdown_rb/native/extconf.rb +14 -0
- data/ext/html_to_markdown_rb/src/lib.rs +1715 -646
- data/lib/html_to_markdown/native.rb +913 -37
- data/lib/html_to_markdown/version.rb +3 -3
- data/lib/html_to_markdown.rb +9 -4
- data/lib/html_to_markdown_rb.so +0 -0
- data/sig/types.rbs +59 -292
- metadata +32 -179
- data/ext/html_to_markdown_rb/Makefile +0 -592
- data/lib/bin/html-to-markdown +0 -0
- data/vendor/Cargo.toml +0 -33
- data/vendor/html-to-markdown-rs/Cargo.toml +0 -54
- data/vendor/html-to-markdown-rs/README.md +0 -278
- data/vendor/html-to-markdown-rs/examples/basic.rs +0 -24
- data/vendor/html-to-markdown-rs/examples/table.rs +0 -25
- data/vendor/html-to-markdown-rs/examples/test_deser.rs +0 -12
- data/vendor/html-to-markdown-rs/examples/test_escape.rs +0 -58
- data/vendor/html-to-markdown-rs/examples/test_inline_formatting.rs +0 -113
- data/vendor/html-to-markdown-rs/examples/test_lists.rs +0 -39
- data/vendor/html-to-markdown-rs/examples/test_semantic_tags.rs +0 -89
- data/vendor/html-to-markdown-rs/examples/test_tables.rs +0 -100
- data/vendor/html-to-markdown-rs/examples/test_task_lists.rs +0 -61
- data/vendor/html-to-markdown-rs/examples/test_whitespace.rs +0 -34
- data/vendor/html-to-markdown-rs/src/convert_api.rs +0 -349
- data/vendor/html-to-markdown-rs/src/converter/block/blockquote.rs +0 -178
- data/vendor/html-to-markdown-rs/src/converter/block/container.rs +0 -114
- data/vendor/html-to-markdown-rs/src/converter/block/div.rs +0 -149
- data/vendor/html-to-markdown-rs/src/converter/block/heading.rs +0 -428
- data/vendor/html-to-markdown-rs/src/converter/block/horizontal_rule.rs +0 -103
- data/vendor/html-to-markdown-rs/src/converter/block/line_break.rs +0 -89
- data/vendor/html-to-markdown-rs/src/converter/block/mod.rs +0 -10
- data/vendor/html-to-markdown-rs/src/converter/block/paragraph.rs +0 -140
- data/vendor/html-to-markdown-rs/src/converter/block/preformatted.rs +0 -298
- data/vendor/html-to-markdown-rs/src/converter/block/table/builder.rs +0 -453
- data/vendor/html-to-markdown-rs/src/converter/block/table/caption.rs +0 -44
- data/vendor/html-to-markdown-rs/src/converter/block/table/cell.rs +0 -276
- data/vendor/html-to-markdown-rs/src/converter/block/table/cells.rs +0 -336
- data/vendor/html-to-markdown-rs/src/converter/block/table/layout.rs +0 -58
- data/vendor/html-to-markdown-rs/src/converter/block/table/mod.rs +0 -266
- data/vendor/html-to-markdown-rs/src/converter/block/table/scanner.rs +0 -146
- data/vendor/html-to-markdown-rs/src/converter/block/table/utils.rs +0 -34
- data/vendor/html-to-markdown-rs/src/converter/block/unknown.rs +0 -138
- data/vendor/html-to-markdown-rs/src/converter/context.rs +0 -208
- data/vendor/html-to-markdown-rs/src/converter/dom_context.rs +0 -337
- data/vendor/html-to-markdown-rs/src/converter/form/elements.rs +0 -770
- data/vendor/html-to-markdown-rs/src/converter/form/mod.rs +0 -82
- data/vendor/html-to-markdown-rs/src/converter/format/djot.rs +0 -64
- data/vendor/html-to-markdown-rs/src/converter/format/markdown.rs +0 -59
- data/vendor/html-to-markdown-rs/src/converter/format/mod.rs +0 -43
- data/vendor/html-to-markdown-rs/src/converter/handlers/blockquote.rs +0 -173
- data/vendor/html-to-markdown-rs/src/converter/handlers/code_block.rs +0 -434
- data/vendor/html-to-markdown-rs/src/converter/handlers/graphic.rs +0 -234
- data/vendor/html-to-markdown-rs/src/converter/handlers/image.rs +0 -282
- data/vendor/html-to-markdown-rs/src/converter/handlers/link.rs +0 -316
- data/vendor/html-to-markdown-rs/src/converter/handlers/mod.rs +0 -26
- data/vendor/html-to-markdown-rs/src/converter/inline/code.rs +0 -306
- data/vendor/html-to-markdown-rs/src/converter/inline/emphasis.rs +0 -345
- data/vendor/html-to-markdown-rs/src/converter/inline/link.rs +0 -428
- data/vendor/html-to-markdown-rs/src/converter/inline/mod.rs +0 -237
- data/vendor/html-to-markdown-rs/src/converter/inline/ruby.rs +0 -337
- data/vendor/html-to-markdown-rs/src/converter/inline/semantic/marks.rs +0 -566
- data/vendor/html-to-markdown-rs/src/converter/inline/semantic/mod.rs +0 -86
- data/vendor/html-to-markdown-rs/src/converter/inline/semantic/typography.rs +0 -558
- data/vendor/html-to-markdown-rs/src/converter/list/definition.rs +0 -232
- data/vendor/html-to-markdown-rs/src/converter/list/item.rs +0 -332
- data/vendor/html-to-markdown-rs/src/converter/list/mod.rs +0 -70
- data/vendor/html-to-markdown-rs/src/converter/list/ordered.rs +0 -201
- data/vendor/html-to-markdown-rs/src/converter/list/unordered.rs +0 -195
- data/vendor/html-to-markdown-rs/src/converter/list/utils.rs +0 -314
- data/vendor/html-to-markdown-rs/src/converter/main.rs +0 -710
- data/vendor/html-to-markdown-rs/src/converter/main_helpers.rs +0 -452
- data/vendor/html-to-markdown-rs/src/converter/media/embedded.rs +0 -393
- data/vendor/html-to-markdown-rs/src/converter/media/graphic.rs +0 -4
- data/vendor/html-to-markdown-rs/src/converter/media/image.rs +0 -183
- data/vendor/html-to-markdown-rs/src/converter/media/mod.rs +0 -87
- data/vendor/html-to-markdown-rs/src/converter/media/svg.rs +0 -280
- data/vendor/html-to-markdown-rs/src/converter/metadata.rs +0 -220
- data/vendor/html-to-markdown-rs/src/converter/mod.rs +0 -156
- data/vendor/html-to-markdown-rs/src/converter/plain_text.rs +0 -516
- data/vendor/html-to-markdown-rs/src/converter/preprocessing_helpers.rs +0 -201
- data/vendor/html-to-markdown-rs/src/converter/reference_collector.rs +0 -69
- data/vendor/html-to-markdown-rs/src/converter/semantic/attributes.rs +0 -269
- data/vendor/html-to-markdown-rs/src/converter/semantic/definition_list.rs +0 -266
- data/vendor/html-to-markdown-rs/src/converter/semantic/figure.rs +0 -391
- data/vendor/html-to-markdown-rs/src/converter/semantic/mod.rs +0 -112
- data/vendor/html-to-markdown-rs/src/converter/semantic/sectioning.rs +0 -85
- data/vendor/html-to-markdown-rs/src/converter/semantic/summary.rs +0 -324
- data/vendor/html-to-markdown-rs/src/converter/text/mod.rs +0 -8
- data/vendor/html-to-markdown-rs/src/converter/text/processing.rs +0 -56
- data/vendor/html-to-markdown-rs/src/converter/text_node.rs +0 -269
- data/vendor/html-to-markdown-rs/src/converter/utility/attributes.rs +0 -151
- data/vendor/html-to-markdown-rs/src/converter/utility/caching.rs +0 -74
- data/vendor/html-to-markdown-rs/src/converter/utility/content.rs +0 -271
- data/vendor/html-to-markdown-rs/src/converter/utility/mod.rs +0 -17
- data/vendor/html-to-markdown-rs/src/converter/utility/preprocessing.rs +0 -1002
- data/vendor/html-to-markdown-rs/src/converter/utility/serialization.rs +0 -126
- data/vendor/html-to-markdown-rs/src/converter/utility/siblings.rs +0 -97
- data/vendor/html-to-markdown-rs/src/converter/visitor_hooks.rs +0 -189
- data/vendor/html-to-markdown-rs/src/error.rs +0 -43
- data/vendor/html-to-markdown-rs/src/exports.rs +0 -24
- data/vendor/html-to-markdown-rs/src/inline_images.rs +0 -336
- data/vendor/html-to-markdown-rs/src/lib.rs +0 -139
- data/vendor/html-to-markdown-rs/src/metadata/collector.rs +0 -457
- data/vendor/html-to-markdown-rs/src/metadata/config.rs +0 -394
- data/vendor/html-to-markdown-rs/src/metadata/extraction.rs +0 -398
- data/vendor/html-to-markdown-rs/src/metadata/mod.rs +0 -288
- data/vendor/html-to-markdown-rs/src/metadata/types.rs +0 -477
- data/vendor/html-to-markdown-rs/src/options/conversion.rs +0 -559
- data/vendor/html-to-markdown-rs/src/options/inline_image.rs +0 -111
- data/vendor/html-to-markdown-rs/src/options/mod.rs +0 -20
- data/vendor/html-to-markdown-rs/src/options/preprocessing.rs +0 -201
- data/vendor/html-to-markdown-rs/src/options/validation.rs +0 -416
- data/vendor/html-to-markdown-rs/src/prelude.rs +0 -1
- data/vendor/html-to-markdown-rs/src/rcdom.rs +0 -487
- data/vendor/html-to-markdown-rs/src/text.rs +0 -358
- data/vendor/html-to-markdown-rs/src/types/document.rs +0 -191
- data/vendor/html-to-markdown-rs/src/types/mod.rs +0 -17
- data/vendor/html-to-markdown-rs/src/types/result.rs +0 -54
- data/vendor/html-to-markdown-rs/src/types/structure_builder.rs +0 -791
- data/vendor/html-to-markdown-rs/src/types/structure_collector.rs +0 -483
- data/vendor/html-to-markdown-rs/src/types/tables.rs +0 -52
- data/vendor/html-to-markdown-rs/src/types/warnings.rs +0 -33
- data/vendor/html-to-markdown-rs/src/validation.rs +0 -158
- data/vendor/html-to-markdown-rs/src/visitor/default_impl.rs +0 -63
- data/vendor/html-to-markdown-rs/src/visitor/mod.rs +0 -41
- data/vendor/html-to-markdown-rs/src/visitor/traits.rs +0 -370
- data/vendor/html-to-markdown-rs/src/visitor/types.rs +0 -319
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/callbacks/mod.rs +0 -1
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/content.rs +0 -126
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/mod.rs +0 -27
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/state.rs +0 -110
- data/vendor/html-to-markdown-rs/src/visitor_helpers/helpers/traversal.rs +0 -250
- data/vendor/html-to-markdown-rs/src/visitor_helpers.rs +0 -597
- data/vendor/html-to-markdown-rs/src/wrapper/sync.rs +0 -413
- data/vendor/html-to-markdown-rs/src/wrapper/utils.rs +0 -290
- data/vendor/html-to-markdown-rs/src/wrapper.rs +0 -9
- data/vendor/html-to-markdown-rs/tests/br_in_inline_test.rs +0 -87
- data/vendor/html-to-markdown-rs/tests/commonmark_compliance_test.rs +0 -297
- data/vendor/html-to-markdown-rs/tests/djot_output_test.rs +0 -153
- data/vendor/html-to-markdown-rs/tests/exclude_selectors_test.rs +0 -132
- data/vendor/html-to-markdown-rs/tests/integration_test.rs +0 -631
- data/vendor/html-to-markdown-rs/tests/issue_121_regressions.rs +0 -49
- data/vendor/html-to-markdown-rs/tests/issue_127_regressions.rs +0 -58
- data/vendor/html-to-markdown-rs/tests/issue_128_regressions.rs +0 -17
- data/vendor/html-to-markdown-rs/tests/issue_131_regressions.rs +0 -41
- data/vendor/html-to-markdown-rs/tests/issue_134_regressions.rs +0 -40
- data/vendor/html-to-markdown-rs/tests/issue_139_regressions.rs +0 -26
- data/vendor/html-to-markdown-rs/tests/issue_140_regressions.rs +0 -185
- data/vendor/html-to-markdown-rs/tests/issue_143_regressions.rs +0 -100
- data/vendor/html-to-markdown-rs/tests/issue_145_regressions.rs +0 -133
- data/vendor/html-to-markdown-rs/tests/issue_146_regressions.rs +0 -144
- data/vendor/html-to-markdown-rs/tests/issue_176_regressions.rs +0 -62
- data/vendor/html-to-markdown-rs/tests/issue_190_regressions.rs +0 -128
- data/vendor/html-to-markdown-rs/tests/issue_199_regressions.rs +0 -20
- data/vendor/html-to-markdown-rs/tests/issue_200_regressions.rs +0 -62
- data/vendor/html-to-markdown-rs/tests/issue_212_regressions.rs +0 -68
- data/vendor/html-to-markdown-rs/tests/issue_216_217_regressions.rs +0 -87
- data/vendor/html-to-markdown-rs/tests/issue_336_regressions.rs +0 -74
- data/vendor/html-to-markdown-rs/tests/issue_339_regressions.rs +0 -92
- data/vendor/html-to-markdown-rs/tests/issue_347_regressions.rs +0 -154
- data/vendor/html-to-markdown-rs/tests/issue_348_visitor_plain.rs +0 -93
- data/vendor/html-to-markdown-rs/tests/json_ld_script_extraction.rs +0 -44
- data/vendor/html-to-markdown-rs/tests/lists_test.rs +0 -199
- data/vendor/html-to-markdown-rs/tests/plain_output_test.rs +0 -273
- data/vendor/html-to-markdown-rs/tests/preprocessing_tests.rs +0 -61
- data/vendor/html-to-markdown-rs/tests/reference_links_test.rs +0 -169
- data/vendor/html-to-markdown-rs/tests/sectioning_elements_test.rs +0 -137
- data/vendor/html-to-markdown-rs/tests/skip_images_test.rs +0 -522
- data/vendor/html-to-markdown-rs/tests/tables_test.rs +0 -743
- data/vendor/html-to-markdown-rs/tests/test_custom_elements.rs +0 -41
- data/vendor/html-to-markdown-rs/tests/test_issue_187.rs +0 -204
- data/vendor/html-to-markdown-rs/tests/test_issue_218.rs +0 -68
- data/vendor/html-to-markdown-rs/tests/test_issue_277.rs +0 -77
- data/vendor/html-to-markdown-rs/tests/test_max_depth.rs +0 -82
- data/vendor/html-to-markdown-rs/tests/test_nested_simple.rs +0 -45
- data/vendor/html-to-markdown-rs/tests/test_script_style_stripping.rs +0 -396
- data/vendor/html-to-markdown-rs/tests/test_spa_bisect.rs +0 -34
- data/vendor/html-to-markdown-rs/tests/visitor_code_integration_test.rs +0 -121
- data/vendor/html-to-markdown-rs/tests/visitor_integration_test.rs +0 -1190
- data/vendor/html-to-markdown-rs/tests/xml_tables_test.rs +0 -372
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is auto-generated by alef. DO NOT EDIT.
|
|
2
|
-
// alef:hash:
|
|
2
|
+
// alef:hash:fbc32dea2062047854006aa7a5d861ef8fc29be3d8b519a3e56646eb14f1b2e9
|
|
3
3
|
// Re-generate with: alef generate
|
|
4
4
|
#![allow(dead_code, unused_imports, unused_variables)]
|
|
5
5
|
#![allow(
|
|
@@ -13,12 +13,16 @@
|
|
|
13
13
|
clippy::unwrap_or_default,
|
|
14
14
|
clippy::derivable_impls,
|
|
15
15
|
clippy::needless_borrows_for_generic_args,
|
|
16
|
-
clippy::unnecessary_fallible_conversions
|
|
16
|
+
clippy::unnecessary_fallible_conversions,
|
|
17
|
+
clippy::type_complexity,
|
|
18
|
+
clippy::useless_conversion,
|
|
19
|
+
clippy::clone_on_copy
|
|
17
20
|
)]
|
|
18
21
|
|
|
19
22
|
use magnus::{Error, IntoValueFromNative, Ruby, function, method, prelude::*, try_convert::TryConvertOwned};
|
|
20
23
|
use std::collections::HashMap;
|
|
21
24
|
use std::sync::Arc;
|
|
25
|
+
use std::sync::Mutex;
|
|
22
26
|
|
|
23
27
|
fn json_to_ruby(handle: &Ruby, val: serde_json::Value) -> magnus::Value {
|
|
24
28
|
use magnus::IntoValue;
|
|
@@ -54,7 +58,7 @@ fn json_to_ruby(handle: &Ruby, val: serde_json::Value) -> magnus::Value {
|
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
61
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
58
62
|
#[serde(default)]
|
|
59
63
|
#[magnus::wrap(class = "HtmlToMarkdownRs::DocumentMetadata")]
|
|
60
64
|
pub struct DocumentMetadata {
|
|
@@ -99,6 +103,24 @@ impl magnus::TryConvert for DocumentMetadata {
|
|
|
99
103
|
|
|
100
104
|
unsafe impl TryConvertOwned for DocumentMetadata {}
|
|
101
105
|
|
|
106
|
+
impl Default for DocumentMetadata {
|
|
107
|
+
fn default() -> Self {
|
|
108
|
+
Self {
|
|
109
|
+
title: None,
|
|
110
|
+
description: None,
|
|
111
|
+
keywords: vec![],
|
|
112
|
+
author: None,
|
|
113
|
+
canonical_url: None,
|
|
114
|
+
base_href: None,
|
|
115
|
+
language: None,
|
|
116
|
+
text_direction: None,
|
|
117
|
+
open_graph: Default::default(),
|
|
118
|
+
twitter_card: Default::default(),
|
|
119
|
+
meta_tags: Default::default(),
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
102
124
|
impl DocumentMetadata {
|
|
103
125
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
104
126
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -191,7 +213,7 @@ impl DocumentMetadata {
|
|
|
191
213
|
}
|
|
192
214
|
}
|
|
193
215
|
|
|
194
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
216
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
195
217
|
#[magnus::wrap(class = "HtmlToMarkdownRs::HeaderMetadata")]
|
|
196
218
|
pub struct HeaderMetadata {
|
|
197
219
|
level: u8,
|
|
@@ -294,7 +316,7 @@ impl HeaderMetadata {
|
|
|
294
316
|
}
|
|
295
317
|
}
|
|
296
318
|
|
|
297
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
319
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
298
320
|
#[magnus::wrap(class = "HtmlToMarkdownRs::LinkMetadata")]
|
|
299
321
|
pub struct LinkMetadata {
|
|
300
322
|
href: String,
|
|
@@ -354,7 +376,12 @@ impl LinkMetadata {
|
|
|
354
376
|
link_type: kwargs
|
|
355
377
|
.get(ruby.to_symbol("link_type"))
|
|
356
378
|
.and_then(|v| LinkType::try_convert(v).ok())
|
|
357
|
-
.
|
|
379
|
+
.ok_or_else(|| {
|
|
380
|
+
magnus::Error::new(
|
|
381
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
382
|
+
"missing required field: link_type",
|
|
383
|
+
)
|
|
384
|
+
})?,
|
|
358
385
|
rel: kwargs
|
|
359
386
|
.get(ruby.to_symbol("rel"))
|
|
360
387
|
.and_then(|v| <Vec<String>>::try_convert(v).ok())
|
|
@@ -391,13 +418,13 @@ impl LinkMetadata {
|
|
|
391
418
|
}
|
|
392
419
|
}
|
|
393
420
|
|
|
394
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
421
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
395
422
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ImageMetadata")]
|
|
396
423
|
pub struct ImageMetadata {
|
|
397
424
|
src: String,
|
|
398
425
|
alt: Option<String>,
|
|
399
426
|
title: Option<String>,
|
|
400
|
-
dimensions: Option<
|
|
427
|
+
dimensions: Option<ImageDimensions>,
|
|
401
428
|
image_type: ImageType,
|
|
402
429
|
attributes: HashMap<String, String>,
|
|
403
430
|
}
|
|
@@ -449,11 +476,16 @@ impl ImageMetadata {
|
|
|
449
476
|
.and_then(|v| String::try_convert(v).ok()),
|
|
450
477
|
dimensions: kwargs
|
|
451
478
|
.get(ruby.to_symbol("dimensions"))
|
|
452
|
-
.and_then(|v|
|
|
479
|
+
.and_then(|v| ImageDimensions::try_convert(v).ok()),
|
|
453
480
|
image_type: kwargs
|
|
454
481
|
.get(ruby.to_symbol("image_type"))
|
|
455
482
|
.and_then(|v| ImageType::try_convert(v).ok())
|
|
456
|
-
.
|
|
483
|
+
.ok_or_else(|| {
|
|
484
|
+
magnus::Error::new(
|
|
485
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
486
|
+
"missing required field: image_type",
|
|
487
|
+
)
|
|
488
|
+
})?,
|
|
457
489
|
attributes: kwargs
|
|
458
490
|
.get(ruby.to_symbol("attributes"))
|
|
459
491
|
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok())
|
|
@@ -473,7 +505,7 @@ impl ImageMetadata {
|
|
|
473
505
|
self.title.clone()
|
|
474
506
|
}
|
|
475
507
|
|
|
476
|
-
fn dimensions(&self) -> Option<
|
|
508
|
+
fn dimensions(&self) -> Option<ImageDimensions> {
|
|
477
509
|
self.dimensions.clone()
|
|
478
510
|
}
|
|
479
511
|
|
|
@@ -486,7 +518,7 @@ impl ImageMetadata {
|
|
|
486
518
|
}
|
|
487
519
|
}
|
|
488
520
|
|
|
489
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
521
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
490
522
|
#[magnus::wrap(class = "HtmlToMarkdownRs::StructuredData")]
|
|
491
523
|
pub struct StructuredData {
|
|
492
524
|
data_type: StructuredDataType,
|
|
@@ -532,7 +564,12 @@ impl StructuredData {
|
|
|
532
564
|
data_type: kwargs
|
|
533
565
|
.get(ruby.to_symbol("data_type"))
|
|
534
566
|
.and_then(|v| StructuredDataType::try_convert(v).ok())
|
|
535
|
-
.
|
|
567
|
+
.ok_or_else(|| {
|
|
568
|
+
magnus::Error::new(
|
|
569
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
570
|
+
"missing required field: data_type",
|
|
571
|
+
)
|
|
572
|
+
})?,
|
|
536
573
|
raw_json: kwargs
|
|
537
574
|
.get(ruby.to_symbol("raw_json"))
|
|
538
575
|
.and_then(|v| String::try_convert(v).ok())
|
|
@@ -556,7 +593,7 @@ impl StructuredData {
|
|
|
556
593
|
}
|
|
557
594
|
}
|
|
558
595
|
|
|
559
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
596
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
560
597
|
#[serde(default)]
|
|
561
598
|
#[magnus::wrap(class = "HtmlToMarkdownRs::HtmlMetadata")]
|
|
562
599
|
pub struct HtmlMetadata {
|
|
@@ -595,6 +632,18 @@ impl magnus::TryConvert for HtmlMetadata {
|
|
|
595
632
|
|
|
596
633
|
unsafe impl TryConvertOwned for HtmlMetadata {}
|
|
597
634
|
|
|
635
|
+
impl Default for HtmlMetadata {
|
|
636
|
+
fn default() -> Self {
|
|
637
|
+
Self {
|
|
638
|
+
document: Default::default(),
|
|
639
|
+
headers: vec![],
|
|
640
|
+
links: vec![],
|
|
641
|
+
images: vec![],
|
|
642
|
+
structured_data: vec![],
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
598
647
|
impl HtmlMetadata {
|
|
599
648
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
600
649
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -646,7 +695,7 @@ impl HtmlMetadata {
|
|
|
646
695
|
}
|
|
647
696
|
}
|
|
648
697
|
|
|
649
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
698
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
650
699
|
#[serde(default)]
|
|
651
700
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ConversionOptions")]
|
|
652
701
|
pub struct ConversionOptions {
|
|
@@ -663,6 +712,7 @@ pub struct ConversionOptions {
|
|
|
663
712
|
autolinks: bool,
|
|
664
713
|
default_title: bool,
|
|
665
714
|
br_in_tables: bool,
|
|
715
|
+
compact_tables: bool,
|
|
666
716
|
highlight_style: HighlightStyle,
|
|
667
717
|
extract_metadata: bool,
|
|
668
718
|
whitespace_mode: WhitespaceMode,
|
|
@@ -681,6 +731,7 @@ pub struct ConversionOptions {
|
|
|
681
731
|
strip_tags: Vec<String>,
|
|
682
732
|
preserve_tags: Vec<String>,
|
|
683
733
|
skip_images: bool,
|
|
734
|
+
url_escape_style: UrlEscapeStyle,
|
|
684
735
|
link_style: LinkStyle,
|
|
685
736
|
output_format: OutputFormat,
|
|
686
737
|
include_document_structure: bool,
|
|
@@ -690,6 +741,7 @@ pub struct ConversionOptions {
|
|
|
690
741
|
infer_dimensions: bool,
|
|
691
742
|
max_depth: Option<usize>,
|
|
692
743
|
exclude_selectors: Vec<String>,
|
|
744
|
+
tier_strategy: TierStrategy,
|
|
693
745
|
}
|
|
694
746
|
|
|
695
747
|
unsafe impl IntoValueFromNative for ConversionOptions {}
|
|
@@ -720,6 +772,56 @@ impl magnus::TryConvert for ConversionOptions {
|
|
|
720
772
|
|
|
721
773
|
unsafe impl TryConvertOwned for ConversionOptions {}
|
|
722
774
|
|
|
775
|
+
impl Default for ConversionOptions {
|
|
776
|
+
fn default() -> Self {
|
|
777
|
+
Self {
|
|
778
|
+
heading_style: Default::default(),
|
|
779
|
+
list_indent_type: Default::default(),
|
|
780
|
+
list_indent_width: 2,
|
|
781
|
+
bullets: "-*+".to_string(),
|
|
782
|
+
strong_em_symbol: "*".to_string(),
|
|
783
|
+
escape_asterisks: false,
|
|
784
|
+
escape_underscores: false,
|
|
785
|
+
escape_misc: false,
|
|
786
|
+
escape_ascii: false,
|
|
787
|
+
code_language: "".to_string(),
|
|
788
|
+
autolinks: true,
|
|
789
|
+
default_title: false,
|
|
790
|
+
br_in_tables: false,
|
|
791
|
+
compact_tables: false,
|
|
792
|
+
highlight_style: Default::default(),
|
|
793
|
+
extract_metadata: true,
|
|
794
|
+
whitespace_mode: Default::default(),
|
|
795
|
+
strip_newlines: false,
|
|
796
|
+
wrap: false,
|
|
797
|
+
wrap_width: 80,
|
|
798
|
+
convert_as_inline: false,
|
|
799
|
+
sub_symbol: "".to_string(),
|
|
800
|
+
sup_symbol: "".to_string(),
|
|
801
|
+
newline_style: NewlineStyle::Spaces,
|
|
802
|
+
code_block_style: Default::default(),
|
|
803
|
+
keep_inline_images_in: vec![],
|
|
804
|
+
preprocessing: Default::default(),
|
|
805
|
+
encoding: "utf-8".to_string(),
|
|
806
|
+
debug: false,
|
|
807
|
+
strip_tags: vec![],
|
|
808
|
+
preserve_tags: vec![],
|
|
809
|
+
skip_images: false,
|
|
810
|
+
url_escape_style: Default::default(),
|
|
811
|
+
link_style: Default::default(),
|
|
812
|
+
output_format: Default::default(),
|
|
813
|
+
include_document_structure: false,
|
|
814
|
+
extract_images: false,
|
|
815
|
+
max_image_size: 5242880,
|
|
816
|
+
capture_svg: false,
|
|
817
|
+
infer_dimensions: true,
|
|
818
|
+
max_depth: None,
|
|
819
|
+
exclude_selectors: vec![],
|
|
820
|
+
tier_strategy: TierStrategy::Auto,
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
723
825
|
impl ConversionOptions {
|
|
724
826
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
725
827
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -779,6 +881,10 @@ impl ConversionOptions {
|
|
|
779
881
|
.get(ruby.to_symbol("br_in_tables"))
|
|
780
882
|
.and_then(|v| bool::try_convert(v).ok())
|
|
781
883
|
.unwrap_or(false),
|
|
884
|
+
compact_tables: kwargs
|
|
885
|
+
.get(ruby.to_symbol("compact_tables"))
|
|
886
|
+
.and_then(|v| bool::try_convert(v).ok())
|
|
887
|
+
.unwrap_or(false),
|
|
782
888
|
highlight_style: kwargs
|
|
783
889
|
.get(ruby.to_symbol("highlight_style"))
|
|
784
890
|
.and_then(|v| HighlightStyle::try_convert(v).ok())
|
|
@@ -851,6 +957,10 @@ impl ConversionOptions {
|
|
|
851
957
|
.get(ruby.to_symbol("skip_images"))
|
|
852
958
|
.and_then(|v| bool::try_convert(v).ok())
|
|
853
959
|
.unwrap_or(false),
|
|
960
|
+
url_escape_style: kwargs
|
|
961
|
+
.get(ruby.to_symbol("url_escape_style"))
|
|
962
|
+
.and_then(|v| UrlEscapeStyle::try_convert(v).ok())
|
|
963
|
+
.unwrap_or_default(),
|
|
854
964
|
link_style: kwargs
|
|
855
965
|
.get(ruby.to_symbol("link_style"))
|
|
856
966
|
.and_then(|v| LinkStyle::try_convert(v).ok())
|
|
@@ -886,6 +996,10 @@ impl ConversionOptions {
|
|
|
886
996
|
.get(ruby.to_symbol("exclude_selectors"))
|
|
887
997
|
.and_then(|v| <Vec<String>>::try_convert(v).ok())
|
|
888
998
|
.unwrap_or_default(),
|
|
999
|
+
tier_strategy: kwargs
|
|
1000
|
+
.get(ruby.to_symbol("tier_strategy"))
|
|
1001
|
+
.and_then(|v| TierStrategy::try_convert(v).ok())
|
|
1002
|
+
.unwrap_or(TierStrategy::Auto),
|
|
889
1003
|
})
|
|
890
1004
|
}
|
|
891
1005
|
|
|
@@ -941,6 +1055,10 @@ impl ConversionOptions {
|
|
|
941
1055
|
self.br_in_tables
|
|
942
1056
|
}
|
|
943
1057
|
|
|
1058
|
+
fn compact_tables(&self) -> bool {
|
|
1059
|
+
self.compact_tables
|
|
1060
|
+
}
|
|
1061
|
+
|
|
944
1062
|
fn highlight_style(&self) -> HighlightStyle {
|
|
945
1063
|
self.highlight_style.clone()
|
|
946
1064
|
}
|
|
@@ -1013,6 +1131,10 @@ impl ConversionOptions {
|
|
|
1013
1131
|
self.skip_images
|
|
1014
1132
|
}
|
|
1015
1133
|
|
|
1134
|
+
fn url_escape_style(&self) -> UrlEscapeStyle {
|
|
1135
|
+
self.url_escape_style.clone()
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1016
1138
|
fn link_style(&self) -> LinkStyle {
|
|
1017
1139
|
self.link_style.clone()
|
|
1018
1140
|
}
|
|
@@ -1049,13 +1171,12 @@ impl ConversionOptions {
|
|
|
1049
1171
|
self.exclude_selectors.clone()
|
|
1050
1172
|
}
|
|
1051
1173
|
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
()
|
|
1174
|
+
fn tier_strategy(&self) -> TierStrategy {
|
|
1175
|
+
self.tier_strategy.clone()
|
|
1055
1176
|
}
|
|
1056
1177
|
}
|
|
1057
1178
|
|
|
1058
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
1179
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1059
1180
|
#[serde(default)]
|
|
1060
1181
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ConversionOptionsUpdate")]
|
|
1061
1182
|
pub struct ConversionOptionsUpdate {
|
|
@@ -1072,6 +1193,7 @@ pub struct ConversionOptionsUpdate {
|
|
|
1072
1193
|
autolinks: Option<bool>,
|
|
1073
1194
|
default_title: Option<bool>,
|
|
1074
1195
|
br_in_tables: Option<bool>,
|
|
1196
|
+
compact_tables: Option<bool>,
|
|
1075
1197
|
highlight_style: Option<HighlightStyle>,
|
|
1076
1198
|
extract_metadata: Option<bool>,
|
|
1077
1199
|
whitespace_mode: Option<WhitespaceMode>,
|
|
@@ -1090,6 +1212,7 @@ pub struct ConversionOptionsUpdate {
|
|
|
1090
1212
|
strip_tags: Option<Vec<String>>,
|
|
1091
1213
|
preserve_tags: Option<Vec<String>>,
|
|
1092
1214
|
skip_images: Option<bool>,
|
|
1215
|
+
url_escape_style: Option<UrlEscapeStyle>,
|
|
1093
1216
|
link_style: Option<LinkStyle>,
|
|
1094
1217
|
output_format: Option<OutputFormat>,
|
|
1095
1218
|
include_document_structure: Option<bool>,
|
|
@@ -1099,6 +1222,7 @@ pub struct ConversionOptionsUpdate {
|
|
|
1099
1222
|
infer_dimensions: Option<bool>,
|
|
1100
1223
|
max_depth: Option<usize>,
|
|
1101
1224
|
exclude_selectors: Option<Vec<String>>,
|
|
1225
|
+
tier_strategy: Option<TierStrategy>,
|
|
1102
1226
|
}
|
|
1103
1227
|
|
|
1104
1228
|
unsafe impl IntoValueFromNative for ConversionOptionsUpdate {}
|
|
@@ -1129,6 +1253,56 @@ impl magnus::TryConvert for ConversionOptionsUpdate {
|
|
|
1129
1253
|
|
|
1130
1254
|
unsafe impl TryConvertOwned for ConversionOptionsUpdate {}
|
|
1131
1255
|
|
|
1256
|
+
impl Default for ConversionOptionsUpdate {
|
|
1257
|
+
fn default() -> Self {
|
|
1258
|
+
Self {
|
|
1259
|
+
heading_style: None,
|
|
1260
|
+
list_indent_type: None,
|
|
1261
|
+
list_indent_width: None,
|
|
1262
|
+
bullets: None,
|
|
1263
|
+
strong_em_symbol: None,
|
|
1264
|
+
escape_asterisks: None,
|
|
1265
|
+
escape_underscores: None,
|
|
1266
|
+
escape_misc: None,
|
|
1267
|
+
escape_ascii: None,
|
|
1268
|
+
code_language: None,
|
|
1269
|
+
autolinks: None,
|
|
1270
|
+
default_title: None,
|
|
1271
|
+
br_in_tables: None,
|
|
1272
|
+
compact_tables: None,
|
|
1273
|
+
highlight_style: None,
|
|
1274
|
+
extract_metadata: None,
|
|
1275
|
+
whitespace_mode: None,
|
|
1276
|
+
strip_newlines: None,
|
|
1277
|
+
wrap: None,
|
|
1278
|
+
wrap_width: None,
|
|
1279
|
+
convert_as_inline: None,
|
|
1280
|
+
sub_symbol: None,
|
|
1281
|
+
sup_symbol: None,
|
|
1282
|
+
newline_style: None,
|
|
1283
|
+
code_block_style: None,
|
|
1284
|
+
keep_inline_images_in: None,
|
|
1285
|
+
preprocessing: None,
|
|
1286
|
+
encoding: None,
|
|
1287
|
+
debug: None,
|
|
1288
|
+
strip_tags: None,
|
|
1289
|
+
preserve_tags: None,
|
|
1290
|
+
skip_images: None,
|
|
1291
|
+
url_escape_style: None,
|
|
1292
|
+
link_style: None,
|
|
1293
|
+
output_format: None,
|
|
1294
|
+
include_document_structure: None,
|
|
1295
|
+
extract_images: None,
|
|
1296
|
+
max_image_size: None,
|
|
1297
|
+
capture_svg: None,
|
|
1298
|
+
infer_dimensions: None,
|
|
1299
|
+
max_depth: None,
|
|
1300
|
+
exclude_selectors: None,
|
|
1301
|
+
tier_strategy: None,
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1132
1306
|
impl ConversionOptionsUpdate {
|
|
1133
1307
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1134
1308
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1175,6 +1349,9 @@ impl ConversionOptionsUpdate {
|
|
|
1175
1349
|
br_in_tables: kwargs
|
|
1176
1350
|
.get(ruby.to_symbol("br_in_tables"))
|
|
1177
1351
|
.and_then(|v| bool::try_convert(v).ok()),
|
|
1352
|
+
compact_tables: kwargs
|
|
1353
|
+
.get(ruby.to_symbol("compact_tables"))
|
|
1354
|
+
.and_then(|v| bool::try_convert(v).ok()),
|
|
1178
1355
|
highlight_style: kwargs
|
|
1179
1356
|
.get(ruby.to_symbol("highlight_style"))
|
|
1180
1357
|
.and_then(|v| HighlightStyle::try_convert(v).ok()),
|
|
@@ -1229,6 +1406,9 @@ impl ConversionOptionsUpdate {
|
|
|
1229
1406
|
skip_images: kwargs
|
|
1230
1407
|
.get(ruby.to_symbol("skip_images"))
|
|
1231
1408
|
.and_then(|v| bool::try_convert(v).ok()),
|
|
1409
|
+
url_escape_style: kwargs
|
|
1410
|
+
.get(ruby.to_symbol("url_escape_style"))
|
|
1411
|
+
.and_then(|v| UrlEscapeStyle::try_convert(v).ok()),
|
|
1232
1412
|
link_style: kwargs
|
|
1233
1413
|
.get(ruby.to_symbol("link_style"))
|
|
1234
1414
|
.and_then(|v| LinkStyle::try_convert(v).ok()),
|
|
@@ -1256,6 +1436,9 @@ impl ConversionOptionsUpdate {
|
|
|
1256
1436
|
exclude_selectors: kwargs
|
|
1257
1437
|
.get(ruby.to_symbol("exclude_selectors"))
|
|
1258
1438
|
.and_then(|v| <Vec<String>>::try_convert(v).ok()),
|
|
1439
|
+
tier_strategy: kwargs
|
|
1440
|
+
.get(ruby.to_symbol("tier_strategy"))
|
|
1441
|
+
.and_then(|v| TierStrategy::try_convert(v).ok()),
|
|
1259
1442
|
})
|
|
1260
1443
|
}
|
|
1261
1444
|
|
|
@@ -1311,6 +1494,10 @@ impl ConversionOptionsUpdate {
|
|
|
1311
1494
|
self.br_in_tables
|
|
1312
1495
|
}
|
|
1313
1496
|
|
|
1497
|
+
fn compact_tables(&self) -> Option<bool> {
|
|
1498
|
+
self.compact_tables
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1314
1501
|
fn highlight_style(&self) -> Option<HighlightStyle> {
|
|
1315
1502
|
self.highlight_style.clone()
|
|
1316
1503
|
}
|
|
@@ -1383,6 +1570,10 @@ impl ConversionOptionsUpdate {
|
|
|
1383
1570
|
self.skip_images
|
|
1384
1571
|
}
|
|
1385
1572
|
|
|
1573
|
+
fn url_escape_style(&self) -> Option<UrlEscapeStyle> {
|
|
1574
|
+
self.url_escape_style.clone()
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1386
1577
|
fn link_style(&self) -> Option<LinkStyle> {
|
|
1387
1578
|
self.link_style.clone()
|
|
1388
1579
|
}
|
|
@@ -1418,9 +1609,13 @@ impl ConversionOptionsUpdate {
|
|
|
1418
1609
|
fn exclude_selectors(&self) -> Option<Vec<String>> {
|
|
1419
1610
|
self.exclude_selectors.clone()
|
|
1420
1611
|
}
|
|
1612
|
+
|
|
1613
|
+
fn tier_strategy(&self) -> Option<TierStrategy> {
|
|
1614
|
+
self.tier_strategy.clone()
|
|
1615
|
+
}
|
|
1421
1616
|
}
|
|
1422
1617
|
|
|
1423
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
1618
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1424
1619
|
#[serde(default)]
|
|
1425
1620
|
#[magnus::wrap(class = "HtmlToMarkdownRs::PreprocessingOptions")]
|
|
1426
1621
|
pub struct PreprocessingOptions {
|
|
@@ -1458,6 +1653,17 @@ impl magnus::TryConvert for PreprocessingOptions {
|
|
|
1458
1653
|
|
|
1459
1654
|
unsafe impl TryConvertOwned for PreprocessingOptions {}
|
|
1460
1655
|
|
|
1656
|
+
impl Default for PreprocessingOptions {
|
|
1657
|
+
fn default() -> Self {
|
|
1658
|
+
Self {
|
|
1659
|
+
enabled: true,
|
|
1660
|
+
preset: Default::default(),
|
|
1661
|
+
remove_navigation: true,
|
|
1662
|
+
remove_forms: true,
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1461
1667
|
impl PreprocessingOptions {
|
|
1462
1668
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1463
1669
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1499,14 +1705,9 @@ impl PreprocessingOptions {
|
|
|
1499
1705
|
fn remove_forms(&self) -> bool {
|
|
1500
1706
|
self.remove_forms
|
|
1501
1707
|
}
|
|
1502
|
-
|
|
1503
|
-
#[allow(unused_variables)]
|
|
1504
|
-
fn apply_update(&mut self, update: PreprocessingOptionsUpdate) -> () {
|
|
1505
|
-
()
|
|
1506
|
-
}
|
|
1507
1708
|
}
|
|
1508
1709
|
|
|
1509
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
1710
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1510
1711
|
#[serde(default)]
|
|
1511
1712
|
#[magnus::wrap(class = "HtmlToMarkdownRs::PreprocessingOptionsUpdate")]
|
|
1512
1713
|
pub struct PreprocessingOptionsUpdate {
|
|
@@ -1544,6 +1745,17 @@ impl magnus::TryConvert for PreprocessingOptionsUpdate {
|
|
|
1544
1745
|
|
|
1545
1746
|
unsafe impl TryConvertOwned for PreprocessingOptionsUpdate {}
|
|
1546
1747
|
|
|
1748
|
+
impl Default for PreprocessingOptionsUpdate {
|
|
1749
|
+
fn default() -> Self {
|
|
1750
|
+
Self {
|
|
1751
|
+
enabled: None,
|
|
1752
|
+
preset: None,
|
|
1753
|
+
remove_navigation: None,
|
|
1754
|
+
remove_forms: None,
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1547
1759
|
impl PreprocessingOptionsUpdate {
|
|
1548
1760
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1549
1761
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1583,7 +1795,69 @@ impl PreprocessingOptionsUpdate {
|
|
|
1583
1795
|
}
|
|
1584
1796
|
}
|
|
1585
1797
|
|
|
1586
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
1798
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1799
|
+
#[magnus::wrap(class = "HtmlToMarkdownRs::ImageDimensions")]
|
|
1800
|
+
pub struct ImageDimensions {
|
|
1801
|
+
width: u32,
|
|
1802
|
+
height: u32,
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
unsafe impl IntoValueFromNative for ImageDimensions {}
|
|
1806
|
+
|
|
1807
|
+
impl magnus::TryConvert for ImageDimensions {
|
|
1808
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
1809
|
+
if let Ok(r) = <&ImageDimensions as magnus::TryConvert>::try_convert(val) {
|
|
1810
|
+
return Ok(r.clone());
|
|
1811
|
+
}
|
|
1812
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
1813
|
+
s
|
|
1814
|
+
} else {
|
|
1815
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
1816
|
+
magnus::Error::new(
|
|
1817
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1818
|
+
format!("no implicit conversion into ImageDimensions: {}", e),
|
|
1819
|
+
)
|
|
1820
|
+
})?
|
|
1821
|
+
};
|
|
1822
|
+
serde_json::from_str::<ImageDimensions>(&json_str).map_err(|e| {
|
|
1823
|
+
magnus::Error::new(
|
|
1824
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
1825
|
+
format!("failed to deserialize ImageDimensions: {}", e),
|
|
1826
|
+
)
|
|
1827
|
+
})
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
unsafe impl TryConvertOwned for ImageDimensions {}
|
|
1832
|
+
|
|
1833
|
+
impl ImageDimensions {
|
|
1834
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1835
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
1836
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
1837
|
+
let (kwargs_opt,) = args.optional;
|
|
1838
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
1839
|
+
Ok(Self {
|
|
1840
|
+
width: kwargs
|
|
1841
|
+
.get(ruby.to_symbol("width"))
|
|
1842
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
1843
|
+
.unwrap_or_default(),
|
|
1844
|
+
height: kwargs
|
|
1845
|
+
.get(ruby.to_symbol("height"))
|
|
1846
|
+
.and_then(|v| u32::try_convert(v).ok())
|
|
1847
|
+
.unwrap_or_default(),
|
|
1848
|
+
})
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
fn width(&self) -> u32 {
|
|
1852
|
+
self.width
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
fn height(&self) -> u32 {
|
|
1856
|
+
self.height
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1587
1861
|
#[magnus::wrap(class = "HtmlToMarkdownRs::DocumentStructure")]
|
|
1588
1862
|
pub struct DocumentStructure {
|
|
1589
1863
|
nodes: Vec<DocumentNode>,
|
|
@@ -1644,7 +1918,7 @@ impl DocumentStructure {
|
|
|
1644
1918
|
}
|
|
1645
1919
|
}
|
|
1646
1920
|
|
|
1647
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
1921
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1648
1922
|
#[magnus::wrap(class = "HtmlToMarkdownRs::DocumentNode")]
|
|
1649
1923
|
pub struct DocumentNode {
|
|
1650
1924
|
id: String,
|
|
@@ -1683,6 +1957,19 @@ impl magnus::TryConvert for DocumentNode {
|
|
|
1683
1957
|
|
|
1684
1958
|
unsafe impl TryConvertOwned for DocumentNode {}
|
|
1685
1959
|
|
|
1960
|
+
impl Default for DocumentNode {
|
|
1961
|
+
fn default() -> Self {
|
|
1962
|
+
Self {
|
|
1963
|
+
id: String::new(),
|
|
1964
|
+
content: NodeContent::default(),
|
|
1965
|
+
parent: None,
|
|
1966
|
+
children: vec![],
|
|
1967
|
+
annotations: vec![],
|
|
1968
|
+
attributes: None,
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1686
1973
|
impl DocumentNode {
|
|
1687
1974
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1688
1975
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1697,18 +1984,23 @@ impl DocumentNode {
|
|
|
1697
1984
|
content: kwargs
|
|
1698
1985
|
.get(ruby.to_symbol("content"))
|
|
1699
1986
|
.and_then(|v| NodeContent::try_convert(v).ok())
|
|
1700
|
-
.
|
|
1987
|
+
.ok_or_else(|| {
|
|
1988
|
+
magnus::Error::new(
|
|
1989
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
1990
|
+
"missing required field: content",
|
|
1991
|
+
)
|
|
1992
|
+
})?,
|
|
1701
1993
|
parent: kwargs
|
|
1702
1994
|
.get(ruby.to_symbol("parent"))
|
|
1703
1995
|
.and_then(|v| u32::try_convert(v).ok()),
|
|
1704
1996
|
children: kwargs
|
|
1705
1997
|
.get(ruby.to_symbol("children"))
|
|
1706
1998
|
.and_then(|v| <Vec<u32>>::try_convert(v).ok())
|
|
1707
|
-
.
|
|
1999
|
+
.unwrap_or(vec![]),
|
|
1708
2000
|
annotations: kwargs
|
|
1709
2001
|
.get(ruby.to_symbol("annotations"))
|
|
1710
2002
|
.and_then(|v| <Vec<TextAnnotation>>::try_convert(v).ok())
|
|
1711
|
-
.
|
|
2003
|
+
.unwrap_or(vec![]),
|
|
1712
2004
|
attributes: kwargs
|
|
1713
2005
|
.get(ruby.to_symbol("attributes"))
|
|
1714
2006
|
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok()),
|
|
@@ -1740,7 +2032,7 @@ impl DocumentNode {
|
|
|
1740
2032
|
}
|
|
1741
2033
|
}
|
|
1742
2034
|
|
|
1743
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
2035
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1744
2036
|
#[magnus::wrap(class = "HtmlToMarkdownRs::TextAnnotation")]
|
|
1745
2037
|
pub struct TextAnnotation {
|
|
1746
2038
|
start: u32,
|
|
@@ -1794,7 +2086,12 @@ impl TextAnnotation {
|
|
|
1794
2086
|
kind: kwargs
|
|
1795
2087
|
.get(ruby.to_symbol("kind"))
|
|
1796
2088
|
.and_then(|v| AnnotationKind::try_convert(v).ok())
|
|
1797
|
-
.
|
|
2089
|
+
.ok_or_else(|| {
|
|
2090
|
+
magnus::Error::new(
|
|
2091
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
2092
|
+
"missing required field: kind",
|
|
2093
|
+
)
|
|
2094
|
+
})?,
|
|
1798
2095
|
})
|
|
1799
2096
|
}
|
|
1800
2097
|
|
|
@@ -1811,7 +2108,69 @@ impl TextAnnotation {
|
|
|
1811
2108
|
}
|
|
1812
2109
|
}
|
|
1813
2110
|
|
|
1814
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
2111
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
2112
|
+
#[magnus::wrap(class = "HtmlToMarkdownRs::MetadataEntry")]
|
|
2113
|
+
pub struct MetadataEntry {
|
|
2114
|
+
key: String,
|
|
2115
|
+
value: String,
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
unsafe impl IntoValueFromNative for MetadataEntry {}
|
|
2119
|
+
|
|
2120
|
+
impl magnus::TryConvert for MetadataEntry {
|
|
2121
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2122
|
+
if let Ok(r) = <&MetadataEntry as magnus::TryConvert>::try_convert(val) {
|
|
2123
|
+
return Ok(r.clone());
|
|
2124
|
+
}
|
|
2125
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
2126
|
+
s
|
|
2127
|
+
} else {
|
|
2128
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
2129
|
+
magnus::Error::new(
|
|
2130
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2131
|
+
format!("no implicit conversion into MetadataEntry: {}", e),
|
|
2132
|
+
)
|
|
2133
|
+
})?
|
|
2134
|
+
};
|
|
2135
|
+
serde_json::from_str::<MetadataEntry>(&json_str).map_err(|e| {
|
|
2136
|
+
magnus::Error::new(
|
|
2137
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2138
|
+
format!("failed to deserialize MetadataEntry: {}", e),
|
|
2139
|
+
)
|
|
2140
|
+
})
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
unsafe impl TryConvertOwned for MetadataEntry {}
|
|
2145
|
+
|
|
2146
|
+
impl MetadataEntry {
|
|
2147
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
2148
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2149
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
2150
|
+
let (kwargs_opt,) = args.optional;
|
|
2151
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2152
|
+
Ok(Self {
|
|
2153
|
+
key: kwargs
|
|
2154
|
+
.get(ruby.to_symbol("key"))
|
|
2155
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
2156
|
+
.unwrap_or_default(),
|
|
2157
|
+
value: kwargs
|
|
2158
|
+
.get(ruby.to_symbol("value"))
|
|
2159
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
2160
|
+
.unwrap_or_default(),
|
|
2161
|
+
})
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
fn key(&self) -> String {
|
|
2165
|
+
self.key.clone()
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
fn value(&self) -> String {
|
|
2169
|
+
self.value.clone()
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1815
2174
|
#[serde(default)]
|
|
1816
2175
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ConversionResult")]
|
|
1817
2176
|
pub struct ConversionResult {
|
|
@@ -1819,7 +2178,6 @@ pub struct ConversionResult {
|
|
|
1819
2178
|
document: Option<DocumentStructure>,
|
|
1820
2179
|
metadata: HtmlMetadata,
|
|
1821
2180
|
tables: Vec<TableData>,
|
|
1822
|
-
images: Vec<String>,
|
|
1823
2181
|
warnings: Vec<ProcessingWarning>,
|
|
1824
2182
|
}
|
|
1825
2183
|
|
|
@@ -1851,6 +2209,18 @@ impl magnus::TryConvert for ConversionResult {
|
|
|
1851
2209
|
|
|
1852
2210
|
unsafe impl TryConvertOwned for ConversionResult {}
|
|
1853
2211
|
|
|
2212
|
+
impl Default for ConversionResult {
|
|
2213
|
+
fn default() -> Self {
|
|
2214
|
+
Self {
|
|
2215
|
+
content: None,
|
|
2216
|
+
document: None,
|
|
2217
|
+
metadata: Default::default(),
|
|
2218
|
+
tables: vec![],
|
|
2219
|
+
warnings: vec![],
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
|
|
1854
2224
|
impl ConversionResult {
|
|
1855
2225
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1856
2226
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1872,10 +2242,6 @@ impl ConversionResult {
|
|
|
1872
2242
|
.get(ruby.to_symbol("tables"))
|
|
1873
2243
|
.and_then(|v| <Vec<TableData>>::try_convert(v).ok())
|
|
1874
2244
|
.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
2245
|
warnings: kwargs
|
|
1880
2246
|
.get(ruby.to_symbol("warnings"))
|
|
1881
2247
|
.and_then(|v| <Vec<ProcessingWarning>>::try_convert(v).ok())
|
|
@@ -1899,10 +2265,6 @@ impl ConversionResult {
|
|
|
1899
2265
|
self.tables.clone()
|
|
1900
2266
|
}
|
|
1901
2267
|
|
|
1902
|
-
fn images(&self) -> Vec<String> {
|
|
1903
|
-
self.images.clone()
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
2268
|
fn warnings(&self) -> Vec<ProcessingWarning> {
|
|
1907
2269
|
self.warnings.clone()
|
|
1908
2270
|
}
|
|
@@ -1913,7 +2275,7 @@ impl ConversionResult {
|
|
|
1913
2275
|
}
|
|
1914
2276
|
}
|
|
1915
2277
|
|
|
1916
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
2278
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1917
2279
|
#[serde(default)]
|
|
1918
2280
|
#[magnus::wrap(class = "HtmlToMarkdownRs::TableGrid")]
|
|
1919
2281
|
pub struct TableGrid {
|
|
@@ -1950,6 +2312,16 @@ impl magnus::TryConvert for TableGrid {
|
|
|
1950
2312
|
|
|
1951
2313
|
unsafe impl TryConvertOwned for TableGrid {}
|
|
1952
2314
|
|
|
2315
|
+
impl Default for TableGrid {
|
|
2316
|
+
fn default() -> Self {
|
|
2317
|
+
Self {
|
|
2318
|
+
rows: 0,
|
|
2319
|
+
cols: 0,
|
|
2320
|
+
cells: vec![],
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
|
|
1953
2325
|
impl TableGrid {
|
|
1954
2326
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
1955
2327
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -1985,7 +2357,7 @@ impl TableGrid {
|
|
|
1985
2357
|
}
|
|
1986
2358
|
}
|
|
1987
2359
|
|
|
1988
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
2360
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1989
2361
|
#[magnus::wrap(class = "HtmlToMarkdownRs::GridCell")]
|
|
1990
2362
|
pub struct GridCell {
|
|
1991
2363
|
content: String,
|
|
@@ -2024,6 +2396,19 @@ impl magnus::TryConvert for GridCell {
|
|
|
2024
2396
|
|
|
2025
2397
|
unsafe impl TryConvertOwned for GridCell {}
|
|
2026
2398
|
|
|
2399
|
+
impl Default for GridCell {
|
|
2400
|
+
fn default() -> Self {
|
|
2401
|
+
Self {
|
|
2402
|
+
content: String::new(),
|
|
2403
|
+
row: 0,
|
|
2404
|
+
col: 0,
|
|
2405
|
+
row_span: 0,
|
|
2406
|
+
col_span: 0,
|
|
2407
|
+
is_header: false,
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2027
2412
|
impl GridCell {
|
|
2028
2413
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
2029
2414
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
@@ -2046,15 +2431,15 @@ impl GridCell {
|
|
|
2046
2431
|
row_span: kwargs
|
|
2047
2432
|
.get(ruby.to_symbol("row_span"))
|
|
2048
2433
|
.and_then(|v| u32::try_convert(v).ok())
|
|
2049
|
-
.
|
|
2434
|
+
.unwrap_or(0),
|
|
2050
2435
|
col_span: kwargs
|
|
2051
2436
|
.get(ruby.to_symbol("col_span"))
|
|
2052
2437
|
.and_then(|v| u32::try_convert(v).ok())
|
|
2053
|
-
.
|
|
2438
|
+
.unwrap_or(0),
|
|
2054
2439
|
is_header: kwargs
|
|
2055
2440
|
.get(ruby.to_symbol("is_header"))
|
|
2056
2441
|
.and_then(|v| bool::try_convert(v).ok())
|
|
2057
|
-
.
|
|
2442
|
+
.unwrap_or(false),
|
|
2058
2443
|
})
|
|
2059
2444
|
}
|
|
2060
2445
|
|
|
@@ -2088,7 +2473,7 @@ impl GridCell {
|
|
|
2088
2473
|
}
|
|
2089
2474
|
}
|
|
2090
2475
|
|
|
2091
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
2476
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
2092
2477
|
#[magnus::wrap(class = "HtmlToMarkdownRs::TableData")]
|
|
2093
2478
|
pub struct TableData {
|
|
2094
2479
|
grid: TableGrid,
|
|
@@ -2133,7 +2518,12 @@ impl TableData {
|
|
|
2133
2518
|
grid: kwargs
|
|
2134
2519
|
.get(ruby.to_symbol("grid"))
|
|
2135
2520
|
.and_then(|v| TableGrid::try_convert(v).ok())
|
|
2136
|
-
.
|
|
2521
|
+
.ok_or_else(|| {
|
|
2522
|
+
magnus::Error::new(
|
|
2523
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
2524
|
+
"missing required field: grid",
|
|
2525
|
+
)
|
|
2526
|
+
})?,
|
|
2137
2527
|
markdown: kwargs
|
|
2138
2528
|
.get(ruby.to_symbol("markdown"))
|
|
2139
2529
|
.and_then(|v| String::try_convert(v).ok())
|
|
@@ -2150,7 +2540,7 @@ impl TableData {
|
|
|
2150
2540
|
}
|
|
2151
2541
|
}
|
|
2152
2542
|
|
|
2153
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
2543
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
2154
2544
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ProcessingWarning")]
|
|
2155
2545
|
pub struct ProcessingWarning {
|
|
2156
2546
|
message: String,
|
|
@@ -2199,7 +2589,12 @@ impl ProcessingWarning {
|
|
|
2199
2589
|
kind: kwargs
|
|
2200
2590
|
.get(ruby.to_symbol("kind"))
|
|
2201
2591
|
.and_then(|v| WarningKind::try_convert(v).ok())
|
|
2202
|
-
.
|
|
2592
|
+
.ok_or_else(|| {
|
|
2593
|
+
magnus::Error::new(
|
|
2594
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
2595
|
+
"missing required field: kind",
|
|
2596
|
+
)
|
|
2597
|
+
})?,
|
|
2203
2598
|
})
|
|
2204
2599
|
}
|
|
2205
2600
|
|
|
@@ -2212,12 +2607,30 @@ impl ProcessingWarning {
|
|
|
2212
2607
|
}
|
|
2213
2608
|
}
|
|
2214
2609
|
|
|
2215
|
-
#[derive(Clone
|
|
2610
|
+
#[derive(Clone)]
|
|
2611
|
+
#[magnus::wrap(class = "HtmlToMarkdownRs::VisitorHandle")]
|
|
2612
|
+
pub struct VisitorHandle {
|
|
2613
|
+
inner: Arc<html_to_markdown_rs::VisitorHandle>,
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
unsafe impl IntoValueFromNative for VisitorHandle {}
|
|
2617
|
+
|
|
2618
|
+
impl magnus::TryConvert for VisitorHandle {
|
|
2619
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2620
|
+
let r: &VisitorHandle = magnus::TryConvert::try_convert(val)?;
|
|
2621
|
+
Ok(r.clone())
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
unsafe impl TryConvertOwned for VisitorHandle {}
|
|
2626
|
+
|
|
2627
|
+
impl VisitorHandle {}
|
|
2628
|
+
|
|
2629
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
2216
2630
|
#[magnus::wrap(class = "HtmlToMarkdownRs::NodeContext")]
|
|
2217
2631
|
pub struct NodeContext {
|
|
2218
2632
|
node_type: NodeType,
|
|
2219
2633
|
tag_name: String,
|
|
2220
|
-
attributes: HashMap<String, String>,
|
|
2221
2634
|
depth: usize,
|
|
2222
2635
|
index_in_parent: usize,
|
|
2223
2636
|
parent_tag: Option<String>,
|
|
@@ -2262,15 +2675,16 @@ impl NodeContext {
|
|
|
2262
2675
|
node_type: kwargs
|
|
2263
2676
|
.get(ruby.to_symbol("node_type"))
|
|
2264
2677
|
.and_then(|v| NodeType::try_convert(v).ok())
|
|
2265
|
-
.
|
|
2678
|
+
.ok_or_else(|| {
|
|
2679
|
+
magnus::Error::new(
|
|
2680
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
|
|
2681
|
+
"missing required field: node_type",
|
|
2682
|
+
)
|
|
2683
|
+
})?,
|
|
2266
2684
|
tag_name: kwargs
|
|
2267
2685
|
.get(ruby.to_symbol("tag_name"))
|
|
2268
2686
|
.and_then(|v| String::try_convert(v).ok())
|
|
2269
2687
|
.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
2688
|
depth: kwargs
|
|
2275
2689
|
.get(ruby.to_symbol("depth"))
|
|
2276
2690
|
.and_then(|v| usize::try_convert(v).ok())
|
|
@@ -2297,10 +2711,6 @@ impl NodeContext {
|
|
|
2297
2711
|
self.tag_name.clone()
|
|
2298
2712
|
}
|
|
2299
2713
|
|
|
2300
|
-
fn attributes(&self) -> HashMap<String, String> {
|
|
2301
|
-
self.attributes.clone()
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
2714
|
fn depth(&self) -> usize {
|
|
2305
2715
|
self.depth
|
|
2306
2716
|
}
|
|
@@ -2316,6 +2726,20 @@ impl NodeContext {
|
|
|
2316
2726
|
fn is_inline(&self) -> bool {
|
|
2317
2727
|
self.is_inline
|
|
2318
2728
|
}
|
|
2729
|
+
|
|
2730
|
+
fn attributes(&self) -> HashMap<String, String> {
|
|
2731
|
+
let core_self = html_to_markdown_rs::NodeContext::from(self.clone());
|
|
2732
|
+
core_self
|
|
2733
|
+
.attributes()
|
|
2734
|
+
.iter()
|
|
2735
|
+
.map(|(k, v)| (k.clone(), v.clone()))
|
|
2736
|
+
.collect()
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
fn into_owned(&self) -> NodeContext {
|
|
2740
|
+
let core_self = html_to_markdown_rs::NodeContext::from(self.clone());
|
|
2741
|
+
core_self.into_owned().into()
|
|
2742
|
+
}
|
|
2319
2743
|
}
|
|
2320
2744
|
|
|
2321
2745
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
@@ -2348,10 +2772,12 @@ impl magnus::IntoValue for TextDirection {
|
|
|
2348
2772
|
impl magnus::TryConvert for TextDirection {
|
|
2349
2773
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2350
2774
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
2775
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
2776
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2351
2777
|
match s.as_str() {
|
|
2352
|
-
"left_to_right" => Ok(TextDirection::LeftToRight),
|
|
2353
|
-
"right_to_left" => Ok(TextDirection::RightToLeft),
|
|
2354
|
-
"auto" => Ok(TextDirection::Auto),
|
|
2778
|
+
"left_to_right" | "LeftToRight" => Ok(TextDirection::LeftToRight),
|
|
2779
|
+
"right_to_left" | "RightToLeft" => Ok(TextDirection::RightToLeft),
|
|
2780
|
+
"auto" | "Auto" => Ok(TextDirection::Auto),
|
|
2355
2781
|
other => Err(magnus::Error::new(
|
|
2356
2782
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2357
2783
|
format!("invalid TextDirection value: {other}"),
|
|
@@ -2397,13 +2823,15 @@ impl magnus::IntoValue for LinkType {
|
|
|
2397
2823
|
impl magnus::TryConvert for LinkType {
|
|
2398
2824
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2399
2825
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
2826
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
2827
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2400
2828
|
match s.as_str() {
|
|
2401
|
-
"anchor" => Ok(LinkType::Anchor),
|
|
2402
|
-
"internal" => Ok(LinkType::Internal),
|
|
2403
|
-
"external" => Ok(LinkType::External),
|
|
2404
|
-
"email" => Ok(LinkType::Email),
|
|
2405
|
-
"phone" => Ok(LinkType::Phone),
|
|
2406
|
-
"other" => Ok(LinkType::Other),
|
|
2829
|
+
"anchor" | "Anchor" => Ok(LinkType::Anchor),
|
|
2830
|
+
"internal" | "Internal" => Ok(LinkType::Internal),
|
|
2831
|
+
"external" | "External" => Ok(LinkType::External),
|
|
2832
|
+
"email" | "Email" => Ok(LinkType::Email),
|
|
2833
|
+
"phone" | "Phone" => Ok(LinkType::Phone),
|
|
2834
|
+
"other" | "Other" => Ok(LinkType::Other),
|
|
2407
2835
|
other => Err(magnus::Error::new(
|
|
2408
2836
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2409
2837
|
format!("invalid LinkType value: {other}"),
|
|
@@ -2445,11 +2873,13 @@ impl magnus::IntoValue for ImageType {
|
|
|
2445
2873
|
impl magnus::TryConvert for ImageType {
|
|
2446
2874
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2447
2875
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
2876
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
2877
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2448
2878
|
match s.as_str() {
|
|
2449
|
-
"data_uri" => Ok(ImageType::DataUri),
|
|
2450
|
-
"inline_svg" => Ok(ImageType::InlineSvg),
|
|
2451
|
-
"external" => Ok(ImageType::External),
|
|
2452
|
-
"relative" => Ok(ImageType::Relative),
|
|
2879
|
+
"data_uri" | "DataUri" => Ok(ImageType::DataUri),
|
|
2880
|
+
"inline_svg" | "InlineSvg" => Ok(ImageType::InlineSvg),
|
|
2881
|
+
"external" | "External" => Ok(ImageType::External),
|
|
2882
|
+
"relative" | "Relative" => Ok(ImageType::Relative),
|
|
2453
2883
|
other => Err(magnus::Error::new(
|
|
2454
2884
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2455
2885
|
format!("invalid ImageType value: {other}"),
|
|
@@ -2482,7 +2912,7 @@ impl magnus::IntoValue for StructuredDataType {
|
|
|
2482
2912
|
let sym = match self {
|
|
2483
2913
|
StructuredDataType::JsonLd => "json_ld",
|
|
2484
2914
|
StructuredDataType::Microdata => "microdata",
|
|
2485
|
-
StructuredDataType::RDFa => "
|
|
2915
|
+
StructuredDataType::RDFa => "rd_fa",
|
|
2486
2916
|
};
|
|
2487
2917
|
handle.to_symbol(sym).into_value_with(handle)
|
|
2488
2918
|
}
|
|
@@ -2491,10 +2921,12 @@ impl magnus::IntoValue for StructuredDataType {
|
|
|
2491
2921
|
impl magnus::TryConvert for StructuredDataType {
|
|
2492
2922
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2493
2923
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
2924
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
2925
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2494
2926
|
match s.as_str() {
|
|
2495
|
-
"json_ld" => Ok(StructuredDataType::JsonLd),
|
|
2496
|
-
"microdata" => Ok(StructuredDataType::Microdata),
|
|
2497
|
-
"
|
|
2927
|
+
"json_ld" | "JsonLd" => Ok(StructuredDataType::JsonLd),
|
|
2928
|
+
"microdata" | "Microdata" => Ok(StructuredDataType::Microdata),
|
|
2929
|
+
"rd_fa" | "RDFa" => Ok(StructuredDataType::RDFa),
|
|
2498
2930
|
other => Err(magnus::Error::new(
|
|
2499
2931
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2500
2932
|
format!("invalid StructuredDataType value: {other}"),
|
|
@@ -2506,6 +2938,50 @@ impl magnus::TryConvert for StructuredDataType {
|
|
|
2506
2938
|
unsafe impl IntoValueFromNative for StructuredDataType {}
|
|
2507
2939
|
unsafe impl TryConvertOwned for StructuredDataType {}
|
|
2508
2940
|
|
|
2941
|
+
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
2942
|
+
pub enum TierStrategy {
|
|
2943
|
+
Auto,
|
|
2944
|
+
Tier2,
|
|
2945
|
+
Tier1,
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
impl Default for TierStrategy {
|
|
2949
|
+
fn default() -> Self {
|
|
2950
|
+
Self::Auto
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
impl magnus::IntoValue for TierStrategy {
|
|
2955
|
+
fn into_value_with(self, handle: &Ruby) -> magnus::Value {
|
|
2956
|
+
let sym = match self {
|
|
2957
|
+
TierStrategy::Auto => "auto",
|
|
2958
|
+
TierStrategy::Tier2 => "tier2",
|
|
2959
|
+
TierStrategy::Tier1 => "tier1",
|
|
2960
|
+
};
|
|
2961
|
+
handle.to_symbol(sym).into_value_with(handle)
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2965
|
+
impl magnus::TryConvert for TierStrategy {
|
|
2966
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2967
|
+
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
2968
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
2969
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2970
|
+
match s.as_str() {
|
|
2971
|
+
"auto" | "Auto" => Ok(TierStrategy::Auto),
|
|
2972
|
+
"tier2" | "Tier2" => Ok(TierStrategy::Tier2),
|
|
2973
|
+
"tier1" | "Tier1" => Ok(TierStrategy::Tier1),
|
|
2974
|
+
other => Err(magnus::Error::new(
|
|
2975
|
+
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2976
|
+
format!("invalid TierStrategy value: {other}"),
|
|
2977
|
+
)),
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
unsafe impl IntoValueFromNative for TierStrategy {}
|
|
2983
|
+
unsafe impl TryConvertOwned for TierStrategy {}
|
|
2984
|
+
|
|
2509
2985
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
2510
2986
|
pub enum PreprocessingPreset {
|
|
2511
2987
|
Minimal,
|
|
@@ -2515,7 +2991,7 @@ pub enum PreprocessingPreset {
|
|
|
2515
2991
|
|
|
2516
2992
|
impl Default for PreprocessingPreset {
|
|
2517
2993
|
fn default() -> Self {
|
|
2518
|
-
Self::
|
|
2994
|
+
Self::Standard
|
|
2519
2995
|
}
|
|
2520
2996
|
}
|
|
2521
2997
|
|
|
@@ -2533,10 +3009,12 @@ impl magnus::IntoValue for PreprocessingPreset {
|
|
|
2533
3009
|
impl magnus::TryConvert for PreprocessingPreset {
|
|
2534
3010
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2535
3011
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3012
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3013
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2536
3014
|
match s.as_str() {
|
|
2537
|
-
"minimal" => Ok(PreprocessingPreset::Minimal),
|
|
2538
|
-
"standard" => Ok(PreprocessingPreset::Standard),
|
|
2539
|
-
"aggressive" => Ok(PreprocessingPreset::Aggressive),
|
|
3015
|
+
"minimal" | "Minimal" => Ok(PreprocessingPreset::Minimal),
|
|
3016
|
+
"standard" | "Standard" => Ok(PreprocessingPreset::Standard),
|
|
3017
|
+
"aggressive" | "Aggressive" => Ok(PreprocessingPreset::Aggressive),
|
|
2540
3018
|
other => Err(magnus::Error::new(
|
|
2541
3019
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2542
3020
|
format!("invalid PreprocessingPreset value: {other}"),
|
|
@@ -2557,7 +3035,7 @@ pub enum HeadingStyle {
|
|
|
2557
3035
|
|
|
2558
3036
|
impl Default for HeadingStyle {
|
|
2559
3037
|
fn default() -> Self {
|
|
2560
|
-
Self::
|
|
3038
|
+
Self::Atx
|
|
2561
3039
|
}
|
|
2562
3040
|
}
|
|
2563
3041
|
|
|
@@ -2575,10 +3053,12 @@ impl magnus::IntoValue for HeadingStyle {
|
|
|
2575
3053
|
impl magnus::TryConvert for HeadingStyle {
|
|
2576
3054
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2577
3055
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3056
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3057
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2578
3058
|
match s.as_str() {
|
|
2579
|
-
"underlined" => Ok(HeadingStyle::Underlined),
|
|
2580
|
-
"atx" => Ok(HeadingStyle::Atx),
|
|
2581
|
-
"atx_closed" => Ok(HeadingStyle::AtxClosed),
|
|
3059
|
+
"underlined" | "Underlined" => Ok(HeadingStyle::Underlined),
|
|
3060
|
+
"atx" | "Atx" => Ok(HeadingStyle::Atx),
|
|
3061
|
+
"atx_closed" | "AtxClosed" => Ok(HeadingStyle::AtxClosed),
|
|
2582
3062
|
other => Err(magnus::Error::new(
|
|
2583
3063
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2584
3064
|
format!("invalid HeadingStyle value: {other}"),
|
|
@@ -2615,9 +3095,11 @@ impl magnus::IntoValue for ListIndentType {
|
|
|
2615
3095
|
impl magnus::TryConvert for ListIndentType {
|
|
2616
3096
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2617
3097
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3098
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3099
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2618
3100
|
match s.as_str() {
|
|
2619
|
-
"spaces" => Ok(ListIndentType::Spaces),
|
|
2620
|
-
"tabs" => Ok(ListIndentType::Tabs),
|
|
3101
|
+
"spaces" | "Spaces" => Ok(ListIndentType::Spaces),
|
|
3102
|
+
"tabs" | "Tabs" => Ok(ListIndentType::Tabs),
|
|
2621
3103
|
other => Err(magnus::Error::new(
|
|
2622
3104
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2623
3105
|
format!("invalid ListIndentType value: {other}"),
|
|
@@ -2654,9 +3136,11 @@ impl magnus::IntoValue for WhitespaceMode {
|
|
|
2654
3136
|
impl magnus::TryConvert for WhitespaceMode {
|
|
2655
3137
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2656
3138
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3139
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3140
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2657
3141
|
match s.as_str() {
|
|
2658
|
-
"normalized" => Ok(WhitespaceMode::Normalized),
|
|
2659
|
-
"strict" => Ok(WhitespaceMode::Strict),
|
|
3142
|
+
"normalized" | "Normalized" => Ok(WhitespaceMode::Normalized),
|
|
3143
|
+
"strict" | "Strict" => Ok(WhitespaceMode::Strict),
|
|
2660
3144
|
other => Err(magnus::Error::new(
|
|
2661
3145
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2662
3146
|
format!("invalid WhitespaceMode value: {other}"),
|
|
@@ -2693,9 +3177,11 @@ impl magnus::IntoValue for NewlineStyle {
|
|
|
2693
3177
|
impl magnus::TryConvert for NewlineStyle {
|
|
2694
3178
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2695
3179
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3180
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3181
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2696
3182
|
match s.as_str() {
|
|
2697
|
-
"spaces" => Ok(NewlineStyle::Spaces),
|
|
2698
|
-
"backslash" => Ok(NewlineStyle::Backslash),
|
|
3183
|
+
"spaces" | "Spaces" => Ok(NewlineStyle::Spaces),
|
|
3184
|
+
"backslash" | "Backslash" => Ok(NewlineStyle::Backslash),
|
|
2699
3185
|
other => Err(magnus::Error::new(
|
|
2700
3186
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2701
3187
|
format!("invalid NewlineStyle value: {other}"),
|
|
@@ -2716,7 +3202,7 @@ pub enum CodeBlockStyle {
|
|
|
2716
3202
|
|
|
2717
3203
|
impl Default for CodeBlockStyle {
|
|
2718
3204
|
fn default() -> Self {
|
|
2719
|
-
Self::
|
|
3205
|
+
Self::Backticks
|
|
2720
3206
|
}
|
|
2721
3207
|
}
|
|
2722
3208
|
|
|
@@ -2734,10 +3220,12 @@ impl magnus::IntoValue for CodeBlockStyle {
|
|
|
2734
3220
|
impl magnus::TryConvert for CodeBlockStyle {
|
|
2735
3221
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2736
3222
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3223
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3224
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2737
3225
|
match s.as_str() {
|
|
2738
|
-
"indented" => Ok(CodeBlockStyle::Indented),
|
|
2739
|
-
"backticks" => Ok(CodeBlockStyle::Backticks),
|
|
2740
|
-
"tildes" => Ok(CodeBlockStyle::Tildes),
|
|
3226
|
+
"indented" | "Indented" => Ok(CodeBlockStyle::Indented),
|
|
3227
|
+
"backticks" | "Backticks" => Ok(CodeBlockStyle::Backticks),
|
|
3228
|
+
"tildes" | "Tildes" => Ok(CodeBlockStyle::Tildes),
|
|
2741
3229
|
other => Err(magnus::Error::new(
|
|
2742
3230
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2743
3231
|
format!("invalid CodeBlockStyle value: {other}"),
|
|
@@ -2778,11 +3266,13 @@ impl magnus::IntoValue for HighlightStyle {
|
|
|
2778
3266
|
impl magnus::TryConvert for HighlightStyle {
|
|
2779
3267
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2780
3268
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3269
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3270
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2781
3271
|
match s.as_str() {
|
|
2782
|
-
"double_equal" => Ok(HighlightStyle::DoubleEqual),
|
|
2783
|
-
"html" => Ok(HighlightStyle::Html),
|
|
2784
|
-
"bold" => Ok(HighlightStyle::Bold),
|
|
2785
|
-
"none" => Ok(HighlightStyle::None),
|
|
3272
|
+
"double_equal" | "DoubleEqual" => Ok(HighlightStyle::DoubleEqual),
|
|
3273
|
+
"html" | "Html" => Ok(HighlightStyle::Html),
|
|
3274
|
+
"bold" | "Bold" => Ok(HighlightStyle::Bold),
|
|
3275
|
+
"none" | "None" => Ok(HighlightStyle::None),
|
|
2786
3276
|
other => Err(magnus::Error::new(
|
|
2787
3277
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2788
3278
|
format!("invalid HighlightStyle value: {other}"),
|
|
@@ -2819,9 +3309,11 @@ impl magnus::IntoValue for LinkStyle {
|
|
|
2819
3309
|
impl magnus::TryConvert for LinkStyle {
|
|
2820
3310
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2821
3311
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3312
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3313
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2822
3314
|
match s.as_str() {
|
|
2823
|
-
"inline" => Ok(LinkStyle::Inline),
|
|
2824
|
-
"reference" => Ok(LinkStyle::Reference),
|
|
3315
|
+
"inline" | "Inline" => Ok(LinkStyle::Inline),
|
|
3316
|
+
"reference" | "Reference" => Ok(LinkStyle::Reference),
|
|
2825
3317
|
other => Err(magnus::Error::new(
|
|
2826
3318
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2827
3319
|
format!("invalid LinkStyle value: {other}"),
|
|
@@ -2834,48 +3326,91 @@ unsafe impl IntoValueFromNative for LinkStyle {}
|
|
|
2834
3326
|
unsafe impl TryConvertOwned for LinkStyle {}
|
|
2835
3327
|
|
|
2836
3328
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
2837
|
-
pub enum
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
Plain,
|
|
3329
|
+
pub enum UrlEscapeStyle {
|
|
3330
|
+
Angle,
|
|
3331
|
+
Percent,
|
|
2841
3332
|
}
|
|
2842
3333
|
|
|
2843
|
-
impl Default for
|
|
3334
|
+
impl Default for UrlEscapeStyle {
|
|
2844
3335
|
fn default() -> Self {
|
|
2845
|
-
Self::
|
|
3336
|
+
Self::Angle
|
|
2846
3337
|
}
|
|
2847
3338
|
}
|
|
2848
3339
|
|
|
2849
|
-
impl magnus::IntoValue for
|
|
3340
|
+
impl magnus::IntoValue for UrlEscapeStyle {
|
|
2850
3341
|
fn into_value_with(self, handle: &Ruby) -> magnus::Value {
|
|
2851
3342
|
let sym = match self {
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
OutputFormat::Plain => "plain",
|
|
3343
|
+
UrlEscapeStyle::Angle => "angle",
|
|
3344
|
+
UrlEscapeStyle::Percent => "percent",
|
|
2855
3345
|
};
|
|
2856
3346
|
handle.to_symbol(sym).into_value_with(handle)
|
|
2857
3347
|
}
|
|
2858
3348
|
}
|
|
2859
3349
|
|
|
2860
|
-
impl magnus::TryConvert for
|
|
3350
|
+
impl magnus::TryConvert for UrlEscapeStyle {
|
|
2861
3351
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2862
3352
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3353
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3354
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
2863
3355
|
match s.as_str() {
|
|
2864
|
-
"
|
|
2865
|
-
"
|
|
2866
|
-
"plain" => Ok(OutputFormat::Plain),
|
|
3356
|
+
"angle" | "Angle" => Ok(UrlEscapeStyle::Angle),
|
|
3357
|
+
"percent" | "Percent" => Ok(UrlEscapeStyle::Percent),
|
|
2867
3358
|
other => Err(magnus::Error::new(
|
|
2868
3359
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2869
|
-
format!("invalid
|
|
3360
|
+
format!("invalid UrlEscapeStyle value: {other}"),
|
|
2870
3361
|
)),
|
|
2871
3362
|
}
|
|
2872
3363
|
}
|
|
2873
3364
|
}
|
|
2874
3365
|
|
|
2875
|
-
unsafe impl IntoValueFromNative for
|
|
2876
|
-
unsafe impl TryConvertOwned for
|
|
3366
|
+
unsafe impl IntoValueFromNative for UrlEscapeStyle {}
|
|
3367
|
+
unsafe impl TryConvertOwned for UrlEscapeStyle {}
|
|
2877
3368
|
|
|
2878
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
3369
|
+
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
3370
|
+
pub enum OutputFormat {
|
|
3371
|
+
Markdown,
|
|
3372
|
+
Djot,
|
|
3373
|
+
Plain,
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
impl Default for OutputFormat {
|
|
3377
|
+
fn default() -> Self {
|
|
3378
|
+
Self::Markdown
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
impl magnus::IntoValue for OutputFormat {
|
|
3383
|
+
fn into_value_with(self, handle: &Ruby) -> magnus::Value {
|
|
3384
|
+
let sym = match self {
|
|
3385
|
+
OutputFormat::Markdown => "markdown",
|
|
3386
|
+
OutputFormat::Djot => "djot",
|
|
3387
|
+
OutputFormat::Plain => "plain",
|
|
3388
|
+
};
|
|
3389
|
+
handle.to_symbol(sym).into_value_with(handle)
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
impl magnus::TryConvert for OutputFormat {
|
|
3394
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
3395
|
+
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3396
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3397
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
3398
|
+
match s.as_str() {
|
|
3399
|
+
"markdown" | "Markdown" => Ok(OutputFormat::Markdown),
|
|
3400
|
+
"djot" | "Djot" => Ok(OutputFormat::Djot),
|
|
3401
|
+
"plain" | "Plain" => Ok(OutputFormat::Plain),
|
|
3402
|
+
other => Err(magnus::Error::new(
|
|
3403
|
+
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
3404
|
+
format!("invalid OutputFormat value: {other}"),
|
|
3405
|
+
)),
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3410
|
+
unsafe impl IntoValueFromNative for OutputFormat {}
|
|
3411
|
+
unsafe impl TryConvertOwned for OutputFormat {}
|
|
3412
|
+
|
|
3413
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
2879
3414
|
#[serde(tag = "node_type")]
|
|
2880
3415
|
#[serde(rename_all = "snake_case")]
|
|
2881
3416
|
pub enum NodeContent {
|
|
@@ -2915,7 +3450,7 @@ pub enum NodeContent {
|
|
|
2915
3450
|
content: String,
|
|
2916
3451
|
},
|
|
2917
3452
|
MetadataBlock {
|
|
2918
|
-
entries: Vec<
|
|
3453
|
+
entries: Vec<MetadataEntry>,
|
|
2919
3454
|
},
|
|
2920
3455
|
Group {
|
|
2921
3456
|
label: Option<String>,
|
|
@@ -2944,15 +3479,26 @@ impl magnus::IntoValue for NodeContent {
|
|
|
2944
3479
|
|
|
2945
3480
|
impl magnus::TryConvert for NodeContent {
|
|
2946
3481
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2947
|
-
|
|
2948
|
-
//
|
|
3482
|
+
// For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
|
|
3483
|
+
// For unit enums or when passed as a string, fall back to string-based conversion.
|
|
3484
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
3485
|
+
s
|
|
3486
|
+
} else {
|
|
3487
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
3488
|
+
magnus::Error::new(
|
|
3489
|
+
unsafe { Ruby::get_unchecked() }.exception_type_error(),
|
|
3490
|
+
format!("no implicit conversion into NodeContent: {}", e),
|
|
3491
|
+
)
|
|
3492
|
+
})?
|
|
3493
|
+
};
|
|
3494
|
+
// Try deserializing as JSON first (handles JSON strings like "\"markdown\"" or "{\"click\":{\"selector\":\"...\"}}\"")
|
|
2949
3495
|
// If that fails, try treating it as a plain string value and wrap in quotes
|
|
2950
3496
|
// If both fail, try as Custom variant (for untagged enum support)
|
|
2951
|
-
serde_json::from_str(&
|
|
2952
|
-
.or_else(|_| serde_json::from_str(&format!("\"{
|
|
3497
|
+
serde_json::from_str(&json_str)
|
|
3498
|
+
.or_else(|_| serde_json::from_str(&format!("\"{json_str}\"")))
|
|
2953
3499
|
.or_else(|_| {
|
|
2954
3500
|
// Try as a JSON string for Custom variant (untagged enums accept any remaining value)
|
|
2955
|
-
match serde_json::to_value(&
|
|
3501
|
+
match serde_json::to_value(&json_str) {
|
|
2956
3502
|
Ok(val) => serde_json::from_value(val),
|
|
2957
3503
|
Err(e) => Err(e),
|
|
2958
3504
|
}
|
|
@@ -2997,15 +3543,26 @@ impl magnus::IntoValue for AnnotationKind {
|
|
|
2997
3543
|
|
|
2998
3544
|
impl magnus::TryConvert for AnnotationKind {
|
|
2999
3545
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
3000
|
-
|
|
3001
|
-
//
|
|
3546
|
+
// For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
|
|
3547
|
+
// For unit enums or when passed as a string, fall back to string-based conversion.
|
|
3548
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
3549
|
+
s
|
|
3550
|
+
} else {
|
|
3551
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
3552
|
+
magnus::Error::new(
|
|
3553
|
+
unsafe { Ruby::get_unchecked() }.exception_type_error(),
|
|
3554
|
+
format!("no implicit conversion into AnnotationKind: {}", e),
|
|
3555
|
+
)
|
|
3556
|
+
})?
|
|
3557
|
+
};
|
|
3558
|
+
// Try deserializing as JSON first (handles JSON strings like "\"markdown\"" or "{\"click\":{\"selector\":\"...\"}}\"")
|
|
3002
3559
|
// If that fails, try treating it as a plain string value and wrap in quotes
|
|
3003
3560
|
// If both fail, try as Custom variant (for untagged enum support)
|
|
3004
|
-
serde_json::from_str(&
|
|
3005
|
-
.or_else(|_| serde_json::from_str(&format!("\"{
|
|
3561
|
+
serde_json::from_str(&json_str)
|
|
3562
|
+
.or_else(|_| serde_json::from_str(&format!("\"{json_str}\"")))
|
|
3006
3563
|
.or_else(|_| {
|
|
3007
3564
|
// Try as a JSON string for Custom variant (untagged enums accept any remaining value)
|
|
3008
|
-
match serde_json::to_value(&
|
|
3565
|
+
match serde_json::to_value(&json_str) {
|
|
3009
3566
|
Ok(val) => serde_json::from_value(val),
|
|
3010
3567
|
Err(e) => Err(e),
|
|
3011
3568
|
}
|
|
@@ -3052,13 +3609,15 @@ impl magnus::IntoValue for WarningKind {
|
|
|
3052
3609
|
impl magnus::TryConvert for WarningKind {
|
|
3053
3610
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
3054
3611
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3612
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3613
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
3055
3614
|
match s.as_str() {
|
|
3056
|
-
"image_extraction_failed" => Ok(WarningKind::ImageExtractionFailed),
|
|
3057
|
-
"encoding_fallback" => Ok(WarningKind::EncodingFallback),
|
|
3058
|
-
"truncated_input" => Ok(WarningKind::TruncatedInput),
|
|
3059
|
-
"malformed_html" => Ok(WarningKind::MalformedHtml),
|
|
3060
|
-
"sanitization_applied" => Ok(WarningKind::SanitizationApplied),
|
|
3061
|
-
"depth_limit_exceeded" => Ok(WarningKind::DepthLimitExceeded),
|
|
3615
|
+
"image_extraction_failed" | "ImageExtractionFailed" => Ok(WarningKind::ImageExtractionFailed),
|
|
3616
|
+
"encoding_fallback" | "EncodingFallback" => Ok(WarningKind::EncodingFallback),
|
|
3617
|
+
"truncated_input" | "TruncatedInput" => Ok(WarningKind::TruncatedInput),
|
|
3618
|
+
"malformed_html" | "MalformedHtml" => Ok(WarningKind::MalformedHtml),
|
|
3619
|
+
"sanitization_applied" | "SanitizationApplied" => Ok(WarningKind::SanitizationApplied),
|
|
3620
|
+
"depth_limit_exceeded" | "DepthLimitExceeded" => Ok(WarningKind::DepthLimitExceeded),
|
|
3062
3621
|
other => Err(magnus::Error::new(
|
|
3063
3622
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
3064
3623
|
format!("invalid WarningKind value: {other}"),
|
|
@@ -3267,95 +3826,97 @@ impl magnus::IntoValue for NodeType {
|
|
|
3267
3826
|
impl magnus::TryConvert for NodeType {
|
|
3268
3827
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
3269
3828
|
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
3829
|
+
// Accept the serde wire name (snake_case), the PascalCase Rust variant name,
|
|
3830
|
+
// and a lowercase fallback so fixtures written in any of those styles work.
|
|
3270
3831
|
match s.as_str() {
|
|
3271
|
-
"text" => Ok(NodeType::Text),
|
|
3272
|
-
"element" => Ok(NodeType::Element),
|
|
3273
|
-
"heading" => Ok(NodeType::Heading),
|
|
3274
|
-
"paragraph" => Ok(NodeType::Paragraph),
|
|
3275
|
-
"div" => Ok(NodeType::Div),
|
|
3276
|
-
"blockquote" => Ok(NodeType::Blockquote),
|
|
3277
|
-
"pre" => Ok(NodeType::Pre),
|
|
3278
|
-
"hr" => Ok(NodeType::Hr),
|
|
3279
|
-
"list" => Ok(NodeType::List),
|
|
3280
|
-
"list_item" => Ok(NodeType::ListItem),
|
|
3281
|
-
"definition_list" => Ok(NodeType::DefinitionList),
|
|
3282
|
-
"definition_term" => Ok(NodeType::DefinitionTerm),
|
|
3283
|
-
"definition_description" => Ok(NodeType::DefinitionDescription),
|
|
3284
|
-
"table" => Ok(NodeType::Table),
|
|
3285
|
-
"table_row" => Ok(NodeType::TableRow),
|
|
3286
|
-
"table_cell" => Ok(NodeType::TableCell),
|
|
3287
|
-
"table_header" => Ok(NodeType::TableHeader),
|
|
3288
|
-
"table_body" => Ok(NodeType::TableBody),
|
|
3289
|
-
"table_head" => Ok(NodeType::TableHead),
|
|
3290
|
-
"table_foot" => Ok(NodeType::TableFoot),
|
|
3291
|
-
"link" => Ok(NodeType::Link),
|
|
3292
|
-
"image" => Ok(NodeType::Image),
|
|
3293
|
-
"strong" => Ok(NodeType::Strong),
|
|
3294
|
-
"em" => Ok(NodeType::Em),
|
|
3295
|
-
"code" => Ok(NodeType::Code),
|
|
3296
|
-
"strikethrough" => Ok(NodeType::Strikethrough),
|
|
3297
|
-
"underline" => Ok(NodeType::Underline),
|
|
3298
|
-
"subscript" => Ok(NodeType::Subscript),
|
|
3299
|
-
"superscript" => Ok(NodeType::Superscript),
|
|
3300
|
-
"mark" => Ok(NodeType::Mark),
|
|
3301
|
-
"small" => Ok(NodeType::Small),
|
|
3302
|
-
"br" => Ok(NodeType::Br),
|
|
3303
|
-
"span" => Ok(NodeType::Span),
|
|
3304
|
-
"article" => Ok(NodeType::Article),
|
|
3305
|
-
"section" => Ok(NodeType::Section),
|
|
3306
|
-
"nav" => Ok(NodeType::Nav),
|
|
3307
|
-
"aside" => Ok(NodeType::Aside),
|
|
3308
|
-
"header" => Ok(NodeType::Header),
|
|
3309
|
-
"footer" => Ok(NodeType::Footer),
|
|
3310
|
-
"main" => Ok(NodeType::Main),
|
|
3311
|
-
"figure" => Ok(NodeType::Figure),
|
|
3312
|
-
"figcaption" => Ok(NodeType::Figcaption),
|
|
3313
|
-
"time" => Ok(NodeType::Time),
|
|
3314
|
-
"details" => Ok(NodeType::Details),
|
|
3315
|
-
"summary" => Ok(NodeType::Summary),
|
|
3316
|
-
"form" => Ok(NodeType::Form),
|
|
3317
|
-
"input" => Ok(NodeType::Input),
|
|
3318
|
-
"select" => Ok(NodeType::Select),
|
|
3319
|
-
"option" => Ok(NodeType::Option),
|
|
3320
|
-
"button" => Ok(NodeType::Button),
|
|
3321
|
-
"textarea" => Ok(NodeType::Textarea),
|
|
3322
|
-
"label" => Ok(NodeType::Label),
|
|
3323
|
-
"fieldset" => Ok(NodeType::Fieldset),
|
|
3324
|
-
"legend" => Ok(NodeType::Legend),
|
|
3325
|
-
"audio" => Ok(NodeType::Audio),
|
|
3326
|
-
"video" => Ok(NodeType::Video),
|
|
3327
|
-
"picture" => Ok(NodeType::Picture),
|
|
3328
|
-
"source" => Ok(NodeType::Source),
|
|
3329
|
-
"iframe" => Ok(NodeType::Iframe),
|
|
3330
|
-
"svg" => Ok(NodeType::Svg),
|
|
3331
|
-
"canvas" => Ok(NodeType::Canvas),
|
|
3332
|
-
"ruby" => Ok(NodeType::Ruby),
|
|
3333
|
-
"rt" => Ok(NodeType::Rt),
|
|
3334
|
-
"rp" => Ok(NodeType::Rp),
|
|
3335
|
-
"abbr" => Ok(NodeType::Abbr),
|
|
3336
|
-
"kbd" => Ok(NodeType::Kbd),
|
|
3337
|
-
"samp" => Ok(NodeType::Samp),
|
|
3338
|
-
"var" => Ok(NodeType::Var),
|
|
3339
|
-
"cite" => Ok(NodeType::Cite),
|
|
3340
|
-
"q" => Ok(NodeType::Q),
|
|
3341
|
-
"del" => Ok(NodeType::Del),
|
|
3342
|
-
"ins" => Ok(NodeType::Ins),
|
|
3343
|
-
"data" => Ok(NodeType::Data),
|
|
3344
|
-
"meter" => Ok(NodeType::Meter),
|
|
3345
|
-
"progress" => Ok(NodeType::Progress),
|
|
3346
|
-
"output" => Ok(NodeType::Output),
|
|
3347
|
-
"template" => Ok(NodeType::Template),
|
|
3348
|
-
"slot" => Ok(NodeType::Slot),
|
|
3349
|
-
"html" => Ok(NodeType::Html),
|
|
3350
|
-
"head" => Ok(NodeType::Head),
|
|
3351
|
-
"body" => Ok(NodeType::Body),
|
|
3352
|
-
"title" => Ok(NodeType::Title),
|
|
3353
|
-
"meta" => Ok(NodeType::Meta),
|
|
3354
|
-
"link_tag" => Ok(NodeType::LinkTag),
|
|
3355
|
-
"style" => Ok(NodeType::Style),
|
|
3356
|
-
"script" => Ok(NodeType::Script),
|
|
3357
|
-
"base" => Ok(NodeType::Base),
|
|
3358
|
-
"custom" => Ok(NodeType::Custom),
|
|
3832
|
+
"text" | "Text" => Ok(NodeType::Text),
|
|
3833
|
+
"element" | "Element" => Ok(NodeType::Element),
|
|
3834
|
+
"heading" | "Heading" => Ok(NodeType::Heading),
|
|
3835
|
+
"paragraph" | "Paragraph" => Ok(NodeType::Paragraph),
|
|
3836
|
+
"div" | "Div" => Ok(NodeType::Div),
|
|
3837
|
+
"blockquote" | "Blockquote" => Ok(NodeType::Blockquote),
|
|
3838
|
+
"pre" | "Pre" => Ok(NodeType::Pre),
|
|
3839
|
+
"hr" | "Hr" => Ok(NodeType::Hr),
|
|
3840
|
+
"list" | "List" => Ok(NodeType::List),
|
|
3841
|
+
"list_item" | "ListItem" => Ok(NodeType::ListItem),
|
|
3842
|
+
"definition_list" | "DefinitionList" => Ok(NodeType::DefinitionList),
|
|
3843
|
+
"definition_term" | "DefinitionTerm" => Ok(NodeType::DefinitionTerm),
|
|
3844
|
+
"definition_description" | "DefinitionDescription" => Ok(NodeType::DefinitionDescription),
|
|
3845
|
+
"table" | "Table" => Ok(NodeType::Table),
|
|
3846
|
+
"table_row" | "TableRow" => Ok(NodeType::TableRow),
|
|
3847
|
+
"table_cell" | "TableCell" => Ok(NodeType::TableCell),
|
|
3848
|
+
"table_header" | "TableHeader" => Ok(NodeType::TableHeader),
|
|
3849
|
+
"table_body" | "TableBody" => Ok(NodeType::TableBody),
|
|
3850
|
+
"table_head" | "TableHead" => Ok(NodeType::TableHead),
|
|
3851
|
+
"table_foot" | "TableFoot" => Ok(NodeType::TableFoot),
|
|
3852
|
+
"link" | "Link" => Ok(NodeType::Link),
|
|
3853
|
+
"image" | "Image" => Ok(NodeType::Image),
|
|
3854
|
+
"strong" | "Strong" => Ok(NodeType::Strong),
|
|
3855
|
+
"em" | "Em" => Ok(NodeType::Em),
|
|
3856
|
+
"code" | "Code" => Ok(NodeType::Code),
|
|
3857
|
+
"strikethrough" | "Strikethrough" => Ok(NodeType::Strikethrough),
|
|
3858
|
+
"underline" | "Underline" => Ok(NodeType::Underline),
|
|
3859
|
+
"subscript" | "Subscript" => Ok(NodeType::Subscript),
|
|
3860
|
+
"superscript" | "Superscript" => Ok(NodeType::Superscript),
|
|
3861
|
+
"mark" | "Mark" => Ok(NodeType::Mark),
|
|
3862
|
+
"small" | "Small" => Ok(NodeType::Small),
|
|
3863
|
+
"br" | "Br" => Ok(NodeType::Br),
|
|
3864
|
+
"span" | "Span" => Ok(NodeType::Span),
|
|
3865
|
+
"article" | "Article" => Ok(NodeType::Article),
|
|
3866
|
+
"section" | "Section" => Ok(NodeType::Section),
|
|
3867
|
+
"nav" | "Nav" => Ok(NodeType::Nav),
|
|
3868
|
+
"aside" | "Aside" => Ok(NodeType::Aside),
|
|
3869
|
+
"header" | "Header" => Ok(NodeType::Header),
|
|
3870
|
+
"footer" | "Footer" => Ok(NodeType::Footer),
|
|
3871
|
+
"main" | "Main" => Ok(NodeType::Main),
|
|
3872
|
+
"figure" | "Figure" => Ok(NodeType::Figure),
|
|
3873
|
+
"figcaption" | "Figcaption" => Ok(NodeType::Figcaption),
|
|
3874
|
+
"time" | "Time" => Ok(NodeType::Time),
|
|
3875
|
+
"details" | "Details" => Ok(NodeType::Details),
|
|
3876
|
+
"summary" | "Summary" => Ok(NodeType::Summary),
|
|
3877
|
+
"form" | "Form" => Ok(NodeType::Form),
|
|
3878
|
+
"input" | "Input" => Ok(NodeType::Input),
|
|
3879
|
+
"select" | "Select" => Ok(NodeType::Select),
|
|
3880
|
+
"option" | "Option" => Ok(NodeType::Option),
|
|
3881
|
+
"button" | "Button" => Ok(NodeType::Button),
|
|
3882
|
+
"textarea" | "Textarea" => Ok(NodeType::Textarea),
|
|
3883
|
+
"label" | "Label" => Ok(NodeType::Label),
|
|
3884
|
+
"fieldset" | "Fieldset" => Ok(NodeType::Fieldset),
|
|
3885
|
+
"legend" | "Legend" => Ok(NodeType::Legend),
|
|
3886
|
+
"audio" | "Audio" => Ok(NodeType::Audio),
|
|
3887
|
+
"video" | "Video" => Ok(NodeType::Video),
|
|
3888
|
+
"picture" | "Picture" => Ok(NodeType::Picture),
|
|
3889
|
+
"source" | "Source" => Ok(NodeType::Source),
|
|
3890
|
+
"iframe" | "Iframe" => Ok(NodeType::Iframe),
|
|
3891
|
+
"svg" | "Svg" => Ok(NodeType::Svg),
|
|
3892
|
+
"canvas" | "Canvas" => Ok(NodeType::Canvas),
|
|
3893
|
+
"ruby" | "Ruby" => Ok(NodeType::Ruby),
|
|
3894
|
+
"rt" | "Rt" => Ok(NodeType::Rt),
|
|
3895
|
+
"rp" | "Rp" => Ok(NodeType::Rp),
|
|
3896
|
+
"abbr" | "Abbr" => Ok(NodeType::Abbr),
|
|
3897
|
+
"kbd" | "Kbd" => Ok(NodeType::Kbd),
|
|
3898
|
+
"samp" | "Samp" => Ok(NodeType::Samp),
|
|
3899
|
+
"var" | "Var" => Ok(NodeType::Var),
|
|
3900
|
+
"cite" | "Cite" => Ok(NodeType::Cite),
|
|
3901
|
+
"q" | "Q" => Ok(NodeType::Q),
|
|
3902
|
+
"del" | "Del" => Ok(NodeType::Del),
|
|
3903
|
+
"ins" | "Ins" => Ok(NodeType::Ins),
|
|
3904
|
+
"data" | "Data" => Ok(NodeType::Data),
|
|
3905
|
+
"meter" | "Meter" => Ok(NodeType::Meter),
|
|
3906
|
+
"progress" | "Progress" => Ok(NodeType::Progress),
|
|
3907
|
+
"output" | "Output" => Ok(NodeType::Output),
|
|
3908
|
+
"template" | "Template" => Ok(NodeType::Template),
|
|
3909
|
+
"slot" | "Slot" => Ok(NodeType::Slot),
|
|
3910
|
+
"html" | "Html" => Ok(NodeType::Html),
|
|
3911
|
+
"head" | "Head" => Ok(NodeType::Head),
|
|
3912
|
+
"body" | "Body" => Ok(NodeType::Body),
|
|
3913
|
+
"title" | "Title" => Ok(NodeType::Title),
|
|
3914
|
+
"meta" | "Meta" => Ok(NodeType::Meta),
|
|
3915
|
+
"link_tag" | "LinkTag" => Ok(NodeType::LinkTag),
|
|
3916
|
+
"style" | "Style" => Ok(NodeType::Style),
|
|
3917
|
+
"script" | "Script" => Ok(NodeType::Script),
|
|
3918
|
+
"base" | "Base" => Ok(NodeType::Base),
|
|
3919
|
+
"custom" | "Custom" => Ok(NodeType::Custom),
|
|
3359
3920
|
other => Err(magnus::Error::new(
|
|
3360
3921
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
3361
3922
|
format!("invalid NodeType value: {other}"),
|
|
@@ -3393,15 +3954,26 @@ impl magnus::IntoValue for VisitResult {
|
|
|
3393
3954
|
|
|
3394
3955
|
impl magnus::TryConvert for VisitResult {
|
|
3395
3956
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
3396
|
-
|
|
3397
|
-
//
|
|
3957
|
+
// For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
|
|
3958
|
+
// For unit enums or when passed as a string, fall back to string-based conversion.
|
|
3959
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
3960
|
+
s
|
|
3961
|
+
} else {
|
|
3962
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
3963
|
+
magnus::Error::new(
|
|
3964
|
+
unsafe { Ruby::get_unchecked() }.exception_type_error(),
|
|
3965
|
+
format!("no implicit conversion into VisitResult: {}", e),
|
|
3966
|
+
)
|
|
3967
|
+
})?
|
|
3968
|
+
};
|
|
3969
|
+
// Try deserializing as JSON first (handles JSON strings like "\"markdown\"" or "{\"click\":{\"selector\":\"...\"}}\"")
|
|
3398
3970
|
// If that fails, try treating it as a plain string value and wrap in quotes
|
|
3399
3971
|
// If both fail, try as Custom variant (for untagged enum support)
|
|
3400
|
-
serde_json::from_str(&
|
|
3401
|
-
.or_else(|_| serde_json::from_str(&format!("\"{
|
|
3972
|
+
serde_json::from_str(&json_str)
|
|
3973
|
+
.or_else(|_| serde_json::from_str(&format!("\"{json_str}\"")))
|
|
3402
3974
|
.or_else(|_| {
|
|
3403
3975
|
// Try as a JSON string for Custom variant (untagged enums accept any remaining value)
|
|
3404
|
-
match serde_json::to_value(&
|
|
3976
|
+
match serde_json::to_value(&json_str) {
|
|
3405
3977
|
Ok(val) => serde_json::from_value(val),
|
|
3406
3978
|
Err(e) => Err(e),
|
|
3407
3979
|
}
|
|
@@ -3422,12 +3994,23 @@ pub fn convert(args: &[magnus::Value]) -> Result<ConversionResult, Error> {
|
|
|
3422
3994
|
let options_core = match visitor {
|
|
3423
3995
|
Some(v) if !v.is_nil() => {
|
|
3424
3996
|
if magnus::RHash::from_value(v).is_some() {
|
|
3425
|
-
let json = v.funcall::<_, _, String>("to_json", ()).
|
|
3426
|
-
|
|
3997
|
+
let json = v.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
3998
|
+
magnus::Error::new(
|
|
3999
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_runtime_error(),
|
|
4000
|
+
format!("failed to serialize Ruby options to JSON: {}", e),
|
|
4001
|
+
)
|
|
4002
|
+
})?;
|
|
4003
|
+
serde_json::from_str::<html_to_markdown_rs::ConversionOptions>(&json).map_err(|e| {
|
|
4004
|
+
magnus::Error::new(
|
|
4005
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_runtime_error(),
|
|
4006
|
+
format!("failed to deserialize options JSON: {}", e),
|
|
4007
|
+
)
|
|
4008
|
+
})?
|
|
4009
|
+
} else if let Ok(opts_binding) = <&ConversionOptions as magnus::TryConvert>::try_convert(v) {
|
|
4010
|
+
opts_binding.clone().into()
|
|
3427
4011
|
} else {
|
|
3428
4012
|
let bridge = RbHtmlVisitorBridge::new(v);
|
|
3429
|
-
let handle =
|
|
3430
|
-
std::rc::Rc::new(std::cell::RefCell::new(bridge)) as html_to_markdown_rs::visitor::VisitorHandle;
|
|
4013
|
+
let handle = std::sync::Arc::new(std::sync::Mutex::new(bridge)) as html_to_markdown_rs::VisitorHandle;
|
|
3431
4014
|
let mut opts = html_to_markdown_rs::ConversionOptions::default();
|
|
3432
4015
|
opts.visitor = Some(handle);
|
|
3433
4016
|
opts
|
|
@@ -3445,25 +4028,21 @@ pub fn convert(args: &[magnus::Value]) -> Result<ConversionResult, Error> {
|
|
|
3445
4028
|
})
|
|
3446
4029
|
}
|
|
3447
4030
|
|
|
3448
|
-
fn nodecontext_to_rb_hash(ctx: &html_to_markdown_rs::
|
|
4031
|
+
fn nodecontext_to_rb_hash(ctx: &html_to_markdown_rs::NodeContext) -> magnus::RHash {
|
|
3449
4032
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3450
4033
|
let h = ruby.hash_new();
|
|
3451
4034
|
h.aset(ruby.to_symbol("node_type"), format!("{:?}", ctx.node_type)).ok();
|
|
3452
|
-
h.aset(ruby.to_symbol("tag_name"), ctx.tag_name
|
|
4035
|
+
h.aset(ruby.to_symbol("tag_name"), AsRef::<str>::as_ref(&ctx.tag_name))
|
|
4036
|
+
.ok();
|
|
3453
4037
|
h.aset(ruby.to_symbol("depth"), ctx.depth as i64).ok();
|
|
3454
4038
|
h.aset(ruby.to_symbol("index_in_parent"), ctx.index_in_parent as i64)
|
|
3455
4039
|
.ok();
|
|
3456
|
-
h.aset(ruby.to_symbol("is_inline"), ctx.is_inline).ok();
|
|
3457
4040
|
h.aset(
|
|
3458
4041
|
ruby.to_symbol("parent_tag"),
|
|
3459
|
-
ctx.parent_tag.as_deref().map(|
|
|
4042
|
+
ctx.parent_tag.as_deref().map(|value| ruby.str_new(value).as_value()),
|
|
3460
4043
|
)
|
|
3461
4044
|
.ok();
|
|
3462
|
-
|
|
3463
|
-
for (k, v) in &ctx.attributes {
|
|
3464
|
-
attrs.aset(ruby.str_new(k), ruby.str_new(v)).ok();
|
|
3465
|
-
}
|
|
3466
|
-
h.aset(ruby.to_symbol("attributes"), attrs).ok();
|
|
4045
|
+
h.aset(ruby.to_symbol("is_inline"), ctx.is_inline).ok();
|
|
3467
4046
|
h
|
|
3468
4047
|
}
|
|
3469
4048
|
|
|
@@ -3483,81 +4062,96 @@ impl RbHtmlVisitorBridge {
|
|
|
3483
4062
|
}
|
|
3484
4063
|
}
|
|
3485
4064
|
|
|
4065
|
+
// SAFETY: `magnus::Value` wraps a `VALUE` (a GC-managed Ruby object pointer).
|
|
4066
|
+
// Ruby is effectively single-threaded (GIL/GVL); the bridge is only invoked
|
|
4067
|
+
// synchronously from the Ruby thread that constructed it. The `Arc<Mutex>`
|
|
4068
|
+
// outer wrapper ensures exclusive access. Sending the bridge across threads
|
|
4069
|
+
// would cause undefined behaviour in the Ruby runtime — callers must not do so.
|
|
4070
|
+
unsafe impl Send for RbHtmlVisitorBridge {}
|
|
4071
|
+
// SAFETY: see Send impl above.
|
|
4072
|
+
unsafe impl Sync for RbHtmlVisitorBridge {}
|
|
4073
|
+
|
|
3486
4074
|
impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
3487
|
-
fn
|
|
3488
|
-
let responds = self.rb_obj.respond_to("
|
|
4075
|
+
fn visit_text(&mut self, _ctx: &html_to_markdown_rs::NodeContext, _text: &str) -> html_to_markdown_rs::VisitResult {
|
|
4076
|
+
let responds = self.rb_obj.respond_to("visit_text", false).unwrap_or(false);
|
|
3489
4077
|
if !responds {
|
|
3490
4078
|
return html_to_markdown_rs::VisitResult::Continue;
|
|
3491
4079
|
}
|
|
3492
|
-
let result: Result<magnus::Value, magnus::Error> = self
|
|
3493
|
-
|
|
3494
|
-
|
|
4080
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
4081
|
+
"visit_text",
|
|
4082
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
4083
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4084
|
+
ruby.str_new(_text)
|
|
4085
|
+
}),
|
|
4086
|
+
);
|
|
3495
4087
|
match result {
|
|
3496
4088
|
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3497
4089
|
Ok(val) => {
|
|
3498
4090
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3499
4091
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3500
4092
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3501
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4093
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3502
4094
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3503
4095
|
}
|
|
4096
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4097
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4098
|
+
}
|
|
3504
4099
|
}
|
|
3505
4100
|
let s: String = val.to_string();
|
|
3506
|
-
match s.
|
|
3507
|
-
"
|
|
3508
|
-
"
|
|
3509
|
-
"
|
|
3510
|
-
|
|
4101
|
+
match s.as_str() {
|
|
4102
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4103
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4104
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4105
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3511
4106
|
}
|
|
3512
4107
|
}
|
|
3513
4108
|
}
|
|
3514
4109
|
}
|
|
3515
|
-
fn
|
|
3516
|
-
|
|
3517
|
-
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3518
|
-
_output: &str,
|
|
3519
|
-
) -> html_to_markdown_rs::VisitResult {
|
|
3520
|
-
let responds = self.rb_obj.respond_to("visit_element_end", false).unwrap_or(false);
|
|
4110
|
+
fn visit_element_start(&mut self, _ctx: &html_to_markdown_rs::NodeContext) -> html_to_markdown_rs::VisitResult {
|
|
4111
|
+
let responds = self.rb_obj.respond_to("visit_element_start", false).unwrap_or(false);
|
|
3521
4112
|
if !responds {
|
|
3522
4113
|
return html_to_markdown_rs::VisitResult::Continue;
|
|
3523
4114
|
}
|
|
3524
|
-
let result: Result<magnus::Value, magnus::Error> = self
|
|
3525
|
-
|
|
3526
|
-
(nodecontext_to_rb_hash(_ctx),
|
|
3527
|
-
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3528
|
-
ruby.str_new(_output)
|
|
3529
|
-
}),
|
|
3530
|
-
);
|
|
4115
|
+
let result: Result<magnus::Value, magnus::Error> = self
|
|
4116
|
+
.rb_obj
|
|
4117
|
+
.funcall("visit_element_start", (nodecontext_to_rb_hash(_ctx),));
|
|
3531
4118
|
match result {
|
|
3532
4119
|
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3533
4120
|
Ok(val) => {
|
|
3534
4121
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3535
4122
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3536
4123
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3537
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4124
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3538
4125
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3539
4126
|
}
|
|
4127
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4128
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4129
|
+
}
|
|
3540
4130
|
}
|
|
3541
4131
|
let s: String = val.to_string();
|
|
3542
|
-
match s.
|
|
3543
|
-
"
|
|
3544
|
-
"
|
|
3545
|
-
"
|
|
3546
|
-
|
|
4132
|
+
match s.as_str() {
|
|
4133
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4134
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4135
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4136
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3547
4137
|
}
|
|
3548
4138
|
}
|
|
3549
4139
|
}
|
|
3550
4140
|
}
|
|
3551
|
-
fn
|
|
3552
|
-
|
|
4141
|
+
fn visit_element_end(
|
|
4142
|
+
&mut self,
|
|
4143
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
4144
|
+
_output: &str,
|
|
4145
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
4146
|
+
let responds = self.rb_obj.respond_to("visit_element_end", false).unwrap_or(false);
|
|
3553
4147
|
if !responds {
|
|
3554
4148
|
return html_to_markdown_rs::VisitResult::Continue;
|
|
3555
4149
|
}
|
|
3556
4150
|
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3557
|
-
"
|
|
4151
|
+
"visit_element_end",
|
|
3558
4152
|
(nodecontext_to_rb_hash(_ctx), {
|
|
3559
4153
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3560
|
-
ruby.str_new(
|
|
4154
|
+
ruby.str_new(_output)
|
|
3561
4155
|
}),
|
|
3562
4156
|
);
|
|
3563
4157
|
match result {
|
|
@@ -3566,16 +4160,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3566
4160
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3567
4161
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3568
4162
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3569
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4163
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3570
4164
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3571
4165
|
}
|
|
4166
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4167
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4168
|
+
}
|
|
3572
4169
|
}
|
|
3573
4170
|
let s: String = val.to_string();
|
|
3574
|
-
match s.
|
|
3575
|
-
"
|
|
3576
|
-
"
|
|
3577
|
-
"
|
|
3578
|
-
|
|
4171
|
+
match s.as_str() {
|
|
4172
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4173
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4174
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4175
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3579
4176
|
}
|
|
3580
4177
|
}
|
|
3581
4178
|
}
|
|
@@ -3618,16 +4215,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3618
4215
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3619
4216
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3620
4217
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3621
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4218
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3622
4219
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3623
4220
|
}
|
|
4221
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4222
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4223
|
+
}
|
|
3624
4224
|
}
|
|
3625
4225
|
let s: String = val.to_string();
|
|
3626
|
-
match s.
|
|
3627
|
-
"
|
|
3628
|
-
"
|
|
3629
|
-
"
|
|
3630
|
-
|
|
4226
|
+
match s.as_str() {
|
|
4227
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4228
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4229
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4230
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3631
4231
|
}
|
|
3632
4232
|
}
|
|
3633
4233
|
}
|
|
@@ -3670,16 +4270,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3670
4270
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3671
4271
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3672
4272
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3673
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4273
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3674
4274
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3675
4275
|
}
|
|
4276
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4277
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4278
|
+
}
|
|
3676
4279
|
}
|
|
3677
4280
|
let s: String = val.to_string();
|
|
3678
|
-
match s.
|
|
3679
|
-
"
|
|
3680
|
-
"
|
|
3681
|
-
"
|
|
3682
|
-
|
|
4281
|
+
match s.as_str() {
|
|
4282
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4283
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4284
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4285
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3683
4286
|
}
|
|
3684
4287
|
}
|
|
3685
4288
|
}
|
|
@@ -3719,16 +4322,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3719
4322
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3720
4323
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3721
4324
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3722
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4325
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3723
4326
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3724
4327
|
}
|
|
4328
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4329
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4330
|
+
}
|
|
3725
4331
|
}
|
|
3726
4332
|
let s: String = val.to_string();
|
|
3727
|
-
match s.
|
|
3728
|
-
"
|
|
3729
|
-
"
|
|
3730
|
-
"
|
|
3731
|
-
|
|
4333
|
+
match s.as_str() {
|
|
4334
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4335
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4336
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4337
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3732
4338
|
}
|
|
3733
4339
|
}
|
|
3734
4340
|
}
|
|
@@ -3766,16 +4372,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3766
4372
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3767
4373
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3768
4374
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3769
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4375
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3770
4376
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3771
4377
|
}
|
|
4378
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4379
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4380
|
+
}
|
|
3772
4381
|
}
|
|
3773
4382
|
let s: String = val.to_string();
|
|
3774
|
-
match s.
|
|
3775
|
-
"
|
|
3776
|
-
"
|
|
3777
|
-
"
|
|
3778
|
-
|
|
4383
|
+
match s.as_str() {
|
|
4384
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4385
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4386
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4387
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3779
4388
|
}
|
|
3780
4389
|
}
|
|
3781
4390
|
}
|
|
@@ -3802,16 +4411,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3802
4411
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3803
4412
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3804
4413
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3805
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4414
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3806
4415
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3807
4416
|
}
|
|
4417
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4418
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4419
|
+
}
|
|
3808
4420
|
}
|
|
3809
4421
|
let s: String = val.to_string();
|
|
3810
|
-
match s.
|
|
3811
|
-
"
|
|
3812
|
-
"
|
|
3813
|
-
"
|
|
3814
|
-
|
|
4422
|
+
match s.as_str() {
|
|
4423
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4424
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4425
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4426
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3815
4427
|
}
|
|
3816
4428
|
}
|
|
3817
4429
|
}
|
|
@@ -3848,16 +4460,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3848
4460
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3849
4461
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3850
4462
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3851
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4463
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3852
4464
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3853
4465
|
}
|
|
4466
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4467
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4468
|
+
}
|
|
3854
4469
|
}
|
|
3855
4470
|
let s: String = val.to_string();
|
|
3856
|
-
match s.
|
|
3857
|
-
"
|
|
3858
|
-
"
|
|
3859
|
-
"
|
|
3860
|
-
|
|
4471
|
+
match s.as_str() {
|
|
4472
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4473
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4474
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4475
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3861
4476
|
}
|
|
3862
4477
|
}
|
|
3863
4478
|
}
|
|
@@ -3880,16 +4495,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3880
4495
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3881
4496
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3882
4497
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3883
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4498
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3884
4499
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3885
4500
|
}
|
|
4501
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4502
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4503
|
+
}
|
|
3886
4504
|
}
|
|
3887
4505
|
let s: String = val.to_string();
|
|
3888
|
-
match s.
|
|
3889
|
-
"
|
|
3890
|
-
"
|
|
3891
|
-
"
|
|
3892
|
-
|
|
4506
|
+
match s.as_str() {
|
|
4507
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4508
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4509
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4510
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3893
4511
|
}
|
|
3894
4512
|
}
|
|
3895
4513
|
}
|
|
@@ -3917,16 +4535,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3917
4535
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3918
4536
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3919
4537
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3920
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4538
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3921
4539
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3922
4540
|
}
|
|
4541
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4542
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4543
|
+
}
|
|
3923
4544
|
}
|
|
3924
4545
|
let s: String = val.to_string();
|
|
3925
|
-
match s.
|
|
3926
|
-
"
|
|
3927
|
-
"
|
|
3928
|
-
"
|
|
3929
|
-
|
|
4546
|
+
match s.as_str() {
|
|
4547
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4548
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4549
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4550
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3930
4551
|
}
|
|
3931
4552
|
}
|
|
3932
4553
|
}
|
|
@@ -3945,16 +4566,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3945
4566
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3946
4567
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3947
4568
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3948
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4569
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3949
4570
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3950
4571
|
}
|
|
4572
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4573
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4574
|
+
}
|
|
3951
4575
|
}
|
|
3952
4576
|
let s: String = val.to_string();
|
|
3953
|
-
match s.
|
|
3954
|
-
"
|
|
3955
|
-
"
|
|
3956
|
-
"
|
|
3957
|
-
|
|
4577
|
+
match s.as_str() {
|
|
4578
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4579
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4580
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4581
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
3958
4582
|
}
|
|
3959
4583
|
}
|
|
3960
4584
|
}
|
|
@@ -3989,16 +4613,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
3989
4613
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
3990
4614
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
3991
4615
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3992
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4616
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
3993
4617
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
3994
4618
|
}
|
|
4619
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4620
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4621
|
+
}
|
|
3995
4622
|
}
|
|
3996
4623
|
let s: String = val.to_string();
|
|
3997
|
-
match s.
|
|
3998
|
-
"
|
|
3999
|
-
"
|
|
4000
|
-
"
|
|
4001
|
-
|
|
4624
|
+
match s.as_str() {
|
|
4625
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4626
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4627
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4628
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4002
4629
|
}
|
|
4003
4630
|
}
|
|
4004
4631
|
}
|
|
@@ -4025,16 +4652,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4025
4652
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4026
4653
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4027
4654
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4028
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4655
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4029
4656
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4030
4657
|
}
|
|
4658
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4659
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4660
|
+
}
|
|
4031
4661
|
}
|
|
4032
4662
|
let s: String = val.to_string();
|
|
4033
|
-
match s.
|
|
4034
|
-
"
|
|
4035
|
-
"
|
|
4036
|
-
"
|
|
4037
|
-
|
|
4663
|
+
match s.as_str() {
|
|
4664
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4665
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4666
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4667
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4038
4668
|
}
|
|
4039
4669
|
}
|
|
4040
4670
|
}
|
|
@@ -4066,16 +4696,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4066
4696
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4067
4697
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4068
4698
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4069
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4699
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4070
4700
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4071
4701
|
}
|
|
4702
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4703
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4704
|
+
}
|
|
4072
4705
|
}
|
|
4073
4706
|
let s: String = val.to_string();
|
|
4074
|
-
match s.
|
|
4075
|
-
"
|
|
4076
|
-
"
|
|
4077
|
-
"
|
|
4078
|
-
|
|
4707
|
+
match s.as_str() {
|
|
4708
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4709
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4710
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4711
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4079
4712
|
}
|
|
4080
4713
|
}
|
|
4081
4714
|
}
|
|
@@ -4102,16 +4735,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4102
4735
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4103
4736
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4104
4737
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4105
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4738
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4106
4739
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4107
4740
|
}
|
|
4741
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4742
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4743
|
+
}
|
|
4108
4744
|
}
|
|
4109
4745
|
let s: String = val.to_string();
|
|
4110
|
-
match s.
|
|
4111
|
-
"
|
|
4112
|
-
"
|
|
4113
|
-
"
|
|
4114
|
-
|
|
4746
|
+
match s.as_str() {
|
|
4747
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4748
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4749
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4750
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4115
4751
|
}
|
|
4116
4752
|
}
|
|
4117
4753
|
}
|
|
@@ -4138,16 +4774,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4138
4774
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4139
4775
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4140
4776
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4141
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4777
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4142
4778
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4143
4779
|
}
|
|
4780
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4781
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4782
|
+
}
|
|
4144
4783
|
}
|
|
4145
4784
|
let s: String = val.to_string();
|
|
4146
|
-
match s.
|
|
4147
|
-
"
|
|
4148
|
-
"
|
|
4149
|
-
"
|
|
4150
|
-
|
|
4785
|
+
match s.as_str() {
|
|
4786
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4787
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4788
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4789
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4151
4790
|
}
|
|
4152
4791
|
}
|
|
4153
4792
|
}
|
|
@@ -4174,16 +4813,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4174
4813
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4175
4814
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4176
4815
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4177
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4816
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4178
4817
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4179
4818
|
}
|
|
4819
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4820
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4821
|
+
}
|
|
4180
4822
|
}
|
|
4181
4823
|
let s: String = val.to_string();
|
|
4182
|
-
match s.
|
|
4183
|
-
"
|
|
4184
|
-
"
|
|
4185
|
-
"
|
|
4186
|
-
|
|
4824
|
+
match s.as_str() {
|
|
4825
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4826
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4827
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4828
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4187
4829
|
}
|
|
4188
4830
|
}
|
|
4189
4831
|
}
|
|
@@ -4210,16 +4852,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4210
4852
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4211
4853
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4212
4854
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4213
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4855
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4214
4856
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4215
4857
|
}
|
|
4858
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4859
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4860
|
+
}
|
|
4216
4861
|
}
|
|
4217
4862
|
let s: String = val.to_string();
|
|
4218
|
-
match s.
|
|
4219
|
-
"
|
|
4220
|
-
"
|
|
4221
|
-
"
|
|
4222
|
-
|
|
4863
|
+
match s.as_str() {
|
|
4864
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4865
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4866
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4867
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4223
4868
|
}
|
|
4224
4869
|
}
|
|
4225
4870
|
}
|
|
@@ -4246,16 +4891,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4246
4891
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4247
4892
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4248
4893
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4249
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4894
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4250
4895
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4251
4896
|
}
|
|
4897
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4898
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4899
|
+
}
|
|
4252
4900
|
}
|
|
4253
4901
|
let s: String = val.to_string();
|
|
4254
|
-
match s.
|
|
4255
|
-
"
|
|
4256
|
-
"
|
|
4257
|
-
"
|
|
4258
|
-
|
|
4902
|
+
match s.as_str() {
|
|
4903
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4904
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4905
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4906
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4259
4907
|
}
|
|
4260
4908
|
}
|
|
4261
4909
|
}
|
|
@@ -4282,16 +4930,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4282
4930
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4283
4931
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4284
4932
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4285
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4933
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4286
4934
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4287
4935
|
}
|
|
4936
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4937
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4938
|
+
}
|
|
4288
4939
|
}
|
|
4289
4940
|
let s: String = val.to_string();
|
|
4290
|
-
match s.
|
|
4291
|
-
"
|
|
4292
|
-
"
|
|
4293
|
-
"
|
|
4294
|
-
|
|
4941
|
+
match s.as_str() {
|
|
4942
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4943
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4944
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4945
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4295
4946
|
}
|
|
4296
4947
|
}
|
|
4297
4948
|
}
|
|
@@ -4314,16 +4965,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4314
4965
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4315
4966
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4316
4967
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4317
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4968
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4318
4969
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4319
4970
|
}
|
|
4971
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
4972
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
4973
|
+
}
|
|
4320
4974
|
}
|
|
4321
4975
|
let s: String = val.to_string();
|
|
4322
|
-
match s.
|
|
4323
|
-
"
|
|
4324
|
-
"
|
|
4325
|
-
"
|
|
4326
|
-
|
|
4976
|
+
match s.as_str() {
|
|
4977
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4978
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4979
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4980
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4327
4981
|
}
|
|
4328
4982
|
}
|
|
4329
4983
|
}
|
|
@@ -4341,16 +4995,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4341
4995
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4342
4996
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4343
4997
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4344
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
4998
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4345
4999
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4346
5000
|
}
|
|
5001
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5002
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5003
|
+
}
|
|
4347
5004
|
}
|
|
4348
5005
|
let s: String = val.to_string();
|
|
4349
|
-
match s.
|
|
4350
|
-
"
|
|
4351
|
-
"
|
|
4352
|
-
"
|
|
4353
|
-
|
|
5006
|
+
match s.as_str() {
|
|
5007
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5008
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5009
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5010
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4354
5011
|
}
|
|
4355
5012
|
}
|
|
4356
5013
|
}
|
|
@@ -4369,16 +5026,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4369
5026
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4370
5027
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4371
5028
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4372
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5029
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4373
5030
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4374
5031
|
}
|
|
5032
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5033
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5034
|
+
}
|
|
4375
5035
|
}
|
|
4376
5036
|
let s: String = val.to_string();
|
|
4377
|
-
match s.
|
|
4378
|
-
"
|
|
4379
|
-
"
|
|
4380
|
-
"
|
|
4381
|
-
|
|
5037
|
+
match s.as_str() {
|
|
5038
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5039
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5040
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5041
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4382
5042
|
}
|
|
4383
5043
|
}
|
|
4384
5044
|
}
|
|
@@ -4413,16 +5073,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4413
5073
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4414
5074
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4415
5075
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4416
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5076
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4417
5077
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4418
5078
|
}
|
|
5079
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5080
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5081
|
+
}
|
|
4419
5082
|
}
|
|
4420
5083
|
let s: String = val.to_string();
|
|
4421
|
-
match s.
|
|
4422
|
-
"
|
|
4423
|
-
"
|
|
4424
|
-
"
|
|
4425
|
-
|
|
5084
|
+
match s.as_str() {
|
|
5085
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5086
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5087
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5088
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4426
5089
|
}
|
|
4427
5090
|
}
|
|
4428
5091
|
}
|
|
@@ -4447,16 +5110,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4447
5110
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4448
5111
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4449
5112
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4450
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5113
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4451
5114
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4452
5115
|
}
|
|
5116
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5117
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5118
|
+
}
|
|
4453
5119
|
}
|
|
4454
5120
|
let s: String = val.to_string();
|
|
4455
|
-
match s.
|
|
4456
|
-
"
|
|
4457
|
-
"
|
|
4458
|
-
"
|
|
4459
|
-
|
|
5121
|
+
match s.as_str() {
|
|
5122
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5123
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5124
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5125
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4460
5126
|
}
|
|
4461
5127
|
}
|
|
4462
5128
|
}
|
|
@@ -4483,16 +5149,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4483
5149
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4484
5150
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4485
5151
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4486
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5152
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4487
5153
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4488
5154
|
}
|
|
5155
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5156
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5157
|
+
}
|
|
4489
5158
|
}
|
|
4490
5159
|
let s: String = val.to_string();
|
|
4491
|
-
match s.
|
|
4492
|
-
"
|
|
4493
|
-
"
|
|
4494
|
-
"
|
|
4495
|
-
|
|
5160
|
+
match s.as_str() {
|
|
5161
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5162
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5163
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5164
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4496
5165
|
}
|
|
4497
5166
|
}
|
|
4498
5167
|
}
|
|
@@ -4522,16 +5191,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4522
5191
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4523
5192
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4524
5193
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4525
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5194
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4526
5195
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4527
5196
|
}
|
|
5197
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5198
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5199
|
+
}
|
|
4528
5200
|
}
|
|
4529
5201
|
let s: String = val.to_string();
|
|
4530
|
-
match s.
|
|
4531
|
-
"
|
|
4532
|
-
"
|
|
4533
|
-
"
|
|
4534
|
-
|
|
5202
|
+
match s.as_str() {
|
|
5203
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5204
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5205
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5206
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4535
5207
|
}
|
|
4536
5208
|
}
|
|
4537
5209
|
}
|
|
@@ -4561,16 +5233,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4561
5233
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4562
5234
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4563
5235
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4564
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5236
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4565
5237
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4566
5238
|
}
|
|
5239
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5240
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5241
|
+
}
|
|
4567
5242
|
}
|
|
4568
5243
|
let s: String = val.to_string();
|
|
4569
|
-
match s.
|
|
4570
|
-
"
|
|
4571
|
-
"
|
|
4572
|
-
"
|
|
4573
|
-
|
|
5244
|
+
match s.as_str() {
|
|
5245
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5246
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5247
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5248
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4574
5249
|
}
|
|
4575
5250
|
}
|
|
4576
5251
|
}
|
|
@@ -4611,16 +5286,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4611
5286
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4612
5287
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4613
5288
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4614
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5289
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4615
5290
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4616
5291
|
}
|
|
5292
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5293
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5294
|
+
}
|
|
4617
5295
|
}
|
|
4618
5296
|
let s: String = val.to_string();
|
|
4619
|
-
match s.
|
|
4620
|
-
"
|
|
4621
|
-
"
|
|
4622
|
-
"
|
|
4623
|
-
|
|
5297
|
+
match s.as_str() {
|
|
5298
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5299
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5300
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5301
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4624
5302
|
}
|
|
4625
5303
|
}
|
|
4626
5304
|
}
|
|
@@ -4666,16 +5344,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4666
5344
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4667
5345
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4668
5346
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4669
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5347
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4670
5348
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4671
5349
|
}
|
|
5350
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5351
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5352
|
+
}
|
|
4672
5353
|
}
|
|
4673
5354
|
let s: String = val.to_string();
|
|
4674
|
-
match s.
|
|
4675
|
-
"
|
|
4676
|
-
"
|
|
4677
|
-
"
|
|
4678
|
-
|
|
5355
|
+
match s.as_str() {
|
|
5356
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5357
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5358
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5359
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4679
5360
|
}
|
|
4680
5361
|
}
|
|
4681
5362
|
}
|
|
@@ -4702,16 +5383,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4702
5383
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4703
5384
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4704
5385
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4705
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5386
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4706
5387
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4707
5388
|
}
|
|
5389
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5390
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5391
|
+
}
|
|
4708
5392
|
}
|
|
4709
5393
|
let s: String = val.to_string();
|
|
4710
|
-
match s.
|
|
4711
|
-
"
|
|
4712
|
-
"
|
|
4713
|
-
"
|
|
4714
|
-
|
|
5394
|
+
match s.as_str() {
|
|
5395
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5396
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5397
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5398
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4715
5399
|
}
|
|
4716
5400
|
}
|
|
4717
5401
|
}
|
|
@@ -4741,16 +5425,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4741
5425
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4742
5426
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4743
5427
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4744
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5428
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4745
5429
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4746
5430
|
}
|
|
5431
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5432
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5433
|
+
}
|
|
4747
5434
|
}
|
|
4748
5435
|
let s: String = val.to_string();
|
|
4749
|
-
match s.
|
|
4750
|
-
"
|
|
4751
|
-
"
|
|
4752
|
-
"
|
|
4753
|
-
|
|
5436
|
+
match s.as_str() {
|
|
5437
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5438
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5439
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5440
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4754
5441
|
}
|
|
4755
5442
|
}
|
|
4756
5443
|
}
|
|
@@ -4780,16 +5467,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4780
5467
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4781
5468
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4782
5469
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4783
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5470
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4784
5471
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4785
5472
|
}
|
|
5473
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5474
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5475
|
+
}
|
|
4786
5476
|
}
|
|
4787
5477
|
let s: String = val.to_string();
|
|
4788
|
-
match s.
|
|
4789
|
-
"
|
|
4790
|
-
"
|
|
4791
|
-
"
|
|
4792
|
-
|
|
5478
|
+
match s.as_str() {
|
|
5479
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5480
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5481
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5482
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4793
5483
|
}
|
|
4794
5484
|
}
|
|
4795
5485
|
}
|
|
@@ -4819,16 +5509,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4819
5509
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4820
5510
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4821
5511
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4822
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5512
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4823
5513
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4824
5514
|
}
|
|
5515
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5516
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5517
|
+
}
|
|
4825
5518
|
}
|
|
4826
5519
|
let s: String = val.to_string();
|
|
4827
|
-
match s.
|
|
4828
|
-
"
|
|
4829
|
-
"
|
|
4830
|
-
"
|
|
4831
|
-
|
|
5520
|
+
match s.as_str() {
|
|
5521
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5522
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5523
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5524
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4832
5525
|
}
|
|
4833
5526
|
}
|
|
4834
5527
|
}
|
|
@@ -4851,16 +5544,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4851
5544
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4852
5545
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4853
5546
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4854
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5547
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4855
5548
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4856
5549
|
}
|
|
5550
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5551
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5552
|
+
}
|
|
4857
5553
|
}
|
|
4858
5554
|
let s: String = val.to_string();
|
|
4859
|
-
match s.
|
|
4860
|
-
"
|
|
4861
|
-
"
|
|
4862
|
-
"
|
|
4863
|
-
|
|
5555
|
+
match s.as_str() {
|
|
5556
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5557
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5558
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5559
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4864
5560
|
}
|
|
4865
5561
|
}
|
|
4866
5562
|
}
|
|
@@ -4887,16 +5583,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4887
5583
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4888
5584
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4889
5585
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4890
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5586
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4891
5587
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4892
5588
|
}
|
|
5589
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5590
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5591
|
+
}
|
|
4893
5592
|
}
|
|
4894
5593
|
let s: String = val.to_string();
|
|
4895
|
-
match s.
|
|
4896
|
-
"
|
|
4897
|
-
"
|
|
4898
|
-
"
|
|
4899
|
-
|
|
5594
|
+
match s.as_str() {
|
|
5595
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5596
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5597
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5598
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4900
5599
|
}
|
|
4901
5600
|
}
|
|
4902
5601
|
}
|
|
@@ -4915,16 +5614,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4915
5614
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4916
5615
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4917
5616
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4918
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5617
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4919
5618
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4920
5619
|
}
|
|
5620
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5621
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5622
|
+
}
|
|
4921
5623
|
}
|
|
4922
5624
|
let s: String = val.to_string();
|
|
4923
|
-
match s.
|
|
4924
|
-
"
|
|
4925
|
-
"
|
|
4926
|
-
"
|
|
4927
|
-
|
|
5625
|
+
match s.as_str() {
|
|
5626
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5627
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5628
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5629
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4928
5630
|
}
|
|
4929
5631
|
}
|
|
4930
5632
|
}
|
|
@@ -4951,16 +5653,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4951
5653
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4952
5654
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4953
5655
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4954
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5656
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4955
5657
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4956
5658
|
}
|
|
5659
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5660
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5661
|
+
}
|
|
4957
5662
|
}
|
|
4958
5663
|
let s: String = val.to_string();
|
|
4959
|
-
match s.
|
|
4960
|
-
"
|
|
4961
|
-
"
|
|
4962
|
-
"
|
|
4963
|
-
|
|
5664
|
+
match s.as_str() {
|
|
5665
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5666
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5667
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5668
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
4964
5669
|
}
|
|
4965
5670
|
}
|
|
4966
5671
|
}
|
|
@@ -4987,16 +5692,19 @@ impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
|
4987
5692
|
// Hash with :custom key — e.g. { custom: '--- {text} ---' }
|
|
4988
5693
|
if let Some(hash) = magnus::RHash::from_value(val) {
|
|
4989
5694
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4990
|
-
if let Some(custom_val) = hash.get(ruby.to_symbol("
|
|
5695
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Custom")) {
|
|
4991
5696
|
return html_to_markdown_rs::VisitResult::Custom(custom_val.to_string());
|
|
4992
5697
|
}
|
|
5698
|
+
if let Some(custom_val) = hash.get(ruby.to_symbol("Error")) {
|
|
5699
|
+
return html_to_markdown_rs::VisitResult::Error(custom_val.to_string());
|
|
5700
|
+
}
|
|
4993
5701
|
}
|
|
4994
5702
|
let s: String = val.to_string();
|
|
4995
|
-
match s.
|
|
4996
|
-
"
|
|
4997
|
-
"
|
|
4998
|
-
"
|
|
4999
|
-
|
|
5703
|
+
match s.as_str() {
|
|
5704
|
+
"Continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
5705
|
+
"Skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
5706
|
+
"PreserveHtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
5707
|
+
_ => html_to_markdown_rs::VisitResult::Continue,
|
|
5000
5708
|
}
|
|
5001
5709
|
}
|
|
5002
5710
|
}
|
|
@@ -5009,7 +5717,7 @@ impl From<DocumentMetadata> for html_to_markdown_rs::metadata::DocumentMetadata
|
|
|
5009
5717
|
Self {
|
|
5010
5718
|
title: val.title,
|
|
5011
5719
|
description: val.description,
|
|
5012
|
-
keywords: val.keywords,
|
|
5720
|
+
keywords: val.keywords.into_iter().collect(),
|
|
5013
5721
|
author: val.author,
|
|
5014
5722
|
canonical_url: val.canonical_url,
|
|
5015
5723
|
base_href: val.base_href,
|
|
@@ -5030,13 +5738,13 @@ impl From<DocumentMetadata> for html_to_markdown_rs::metadata::DocumentMetadata
|
|
|
5030
5738
|
impl From<html_to_markdown_rs::metadata::DocumentMetadata> for DocumentMetadata {
|
|
5031
5739
|
fn from(val: html_to_markdown_rs::metadata::DocumentMetadata) -> Self {
|
|
5032
5740
|
Self {
|
|
5033
|
-
title: val.title,
|
|
5034
|
-
description: val.description,
|
|
5035
|
-
keywords: val.keywords,
|
|
5036
|
-
author: val.author,
|
|
5037
|
-
canonical_url: val.canonical_url,
|
|
5038
|
-
base_href: val.base_href,
|
|
5039
|
-
language: val.language,
|
|
5741
|
+
title: val.title.map(|v| v.to_string()),
|
|
5742
|
+
description: val.description.map(|v| v.to_string()),
|
|
5743
|
+
keywords: val.keywords.into_iter().collect(),
|
|
5744
|
+
author: val.author.map(|v| v.to_string()),
|
|
5745
|
+
canonical_url: val.canonical_url.map(|v| v.to_string()),
|
|
5746
|
+
base_href: val.base_href.map(|v| v.to_string()),
|
|
5747
|
+
language: val.language.map(|v| v.to_string()),
|
|
5040
5748
|
text_direction: val.text_direction.map(Into::into),
|
|
5041
5749
|
open_graph: val.open_graph.into_iter().map(|(k, v)| (k.into(), v.into())).collect(),
|
|
5042
5750
|
twitter_card: val
|
|
@@ -5067,8 +5775,8 @@ impl From<html_to_markdown_rs::metadata::HeaderMetadata> for HeaderMetadata {
|
|
|
5067
5775
|
fn from(val: html_to_markdown_rs::metadata::HeaderMetadata) -> Self {
|
|
5068
5776
|
Self {
|
|
5069
5777
|
level: val.level,
|
|
5070
|
-
text: val.text,
|
|
5071
|
-
id: val.id,
|
|
5778
|
+
text: val.text.to_string(),
|
|
5779
|
+
id: val.id.map(|v| v.to_string()),
|
|
5072
5780
|
depth: val.depth,
|
|
5073
5781
|
html_offset: val.html_offset,
|
|
5074
5782
|
}
|
|
@@ -5083,7 +5791,7 @@ impl From<LinkMetadata> for html_to_markdown_rs::metadata::LinkMetadata {
|
|
|
5083
5791
|
text: val.text,
|
|
5084
5792
|
title: val.title,
|
|
5085
5793
|
link_type: val.link_type.into(),
|
|
5086
|
-
rel: val.rel,
|
|
5794
|
+
rel: val.rel.into_iter().collect(),
|
|
5087
5795
|
attributes: val.attributes.into_iter().map(|(k, v)| (k.into(), v.into())).collect(),
|
|
5088
5796
|
}
|
|
5089
5797
|
}
|
|
@@ -5093,11 +5801,11 @@ impl From<LinkMetadata> for html_to_markdown_rs::metadata::LinkMetadata {
|
|
|
5093
5801
|
impl From<html_to_markdown_rs::metadata::LinkMetadata> for LinkMetadata {
|
|
5094
5802
|
fn from(val: html_to_markdown_rs::metadata::LinkMetadata) -> Self {
|
|
5095
5803
|
Self {
|
|
5096
|
-
href: val.href,
|
|
5097
|
-
text: val.text,
|
|
5098
|
-
title: val.title,
|
|
5804
|
+
href: val.href.to_string(),
|
|
5805
|
+
text: val.text.to_string(),
|
|
5806
|
+
title: val.title.map(|v| v.to_string()),
|
|
5099
5807
|
link_type: val.link_type.into(),
|
|
5100
|
-
rel: val.rel,
|
|
5808
|
+
rel: val.rel.into_iter().collect(),
|
|
5101
5809
|
attributes: val.attributes.into_iter().map(|(k, v)| (k.into(), v.into())).collect(),
|
|
5102
5810
|
}
|
|
5103
5811
|
}
|
|
@@ -5110,7 +5818,7 @@ impl From<ImageMetadata> for html_to_markdown_rs::metadata::ImageMetadata {
|
|
|
5110
5818
|
src: val.src,
|
|
5111
5819
|
alt: val.alt,
|
|
5112
5820
|
title: val.title,
|
|
5113
|
-
dimensions:
|
|
5821
|
+
dimensions: val.dimensions.map(Into::into),
|
|
5114
5822
|
image_type: val.image_type.into(),
|
|
5115
5823
|
attributes: val.attributes.into_iter().map(|(k, v)| (k.into(), v.into())).collect(),
|
|
5116
5824
|
}
|
|
@@ -5121,13 +5829,10 @@ impl From<ImageMetadata> for html_to_markdown_rs::metadata::ImageMetadata {
|
|
|
5121
5829
|
impl From<html_to_markdown_rs::metadata::ImageMetadata> for ImageMetadata {
|
|
5122
5830
|
fn from(val: html_to_markdown_rs::metadata::ImageMetadata) -> Self {
|
|
5123
5831
|
Self {
|
|
5124
|
-
src: val.src,
|
|
5125
|
-
alt: val.alt,
|
|
5126
|
-
title: val.title,
|
|
5127
|
-
dimensions: val.dimensions.map(
|
|
5128
|
-
let arr: Vec<_> = [t.0, t.1].into_iter().map(|v| v as _).collect();
|
|
5129
|
-
arr
|
|
5130
|
-
}),
|
|
5832
|
+
src: val.src.to_string(),
|
|
5833
|
+
alt: val.alt.map(|v| v.to_string()),
|
|
5834
|
+
title: val.title.map(|v| v.to_string()),
|
|
5835
|
+
dimensions: val.dimensions.map(Into::into),
|
|
5131
5836
|
image_type: val.image_type.into(),
|
|
5132
5837
|
attributes: val.attributes.into_iter().map(|(k, v)| (k.into(), v.into())).collect(),
|
|
5133
5838
|
}
|
|
@@ -5150,8 +5855,8 @@ impl From<html_to_markdown_rs::metadata::StructuredData> for StructuredData {
|
|
|
5150
5855
|
fn from(val: html_to_markdown_rs::metadata::StructuredData) -> Self {
|
|
5151
5856
|
Self {
|
|
5152
5857
|
data_type: val.data_type.into(),
|
|
5153
|
-
raw_json: val.raw_json,
|
|
5154
|
-
schema_type: val.schema_type,
|
|
5858
|
+
raw_json: val.raw_json.to_string(),
|
|
5859
|
+
schema_type: val.schema_type.map(|v| v.to_string()),
|
|
5155
5860
|
}
|
|
5156
5861
|
}
|
|
5157
5862
|
}
|
|
@@ -5200,6 +5905,7 @@ impl From<ConversionOptions> for html_to_markdown_rs::options::ConversionOptions
|
|
|
5200
5905
|
autolinks: val.autolinks,
|
|
5201
5906
|
default_title: val.default_title,
|
|
5202
5907
|
br_in_tables: val.br_in_tables,
|
|
5908
|
+
compact_tables: val.compact_tables,
|
|
5203
5909
|
highlight_style: val.highlight_style.into(),
|
|
5204
5910
|
extract_metadata: val.extract_metadata,
|
|
5205
5911
|
whitespace_mode: val.whitespace_mode.into(),
|
|
@@ -5211,13 +5917,14 @@ impl From<ConversionOptions> for html_to_markdown_rs::options::ConversionOptions
|
|
|
5211
5917
|
sup_symbol: val.sup_symbol,
|
|
5212
5918
|
newline_style: val.newline_style.into(),
|
|
5213
5919
|
code_block_style: val.code_block_style.into(),
|
|
5214
|
-
keep_inline_images_in: val.keep_inline_images_in,
|
|
5920
|
+
keep_inline_images_in: val.keep_inline_images_in.into_iter().collect(),
|
|
5215
5921
|
preprocessing: val.preprocessing.into(),
|
|
5216
5922
|
encoding: val.encoding,
|
|
5217
5923
|
debug: val.debug,
|
|
5218
|
-
strip_tags: val.strip_tags,
|
|
5219
|
-
preserve_tags: val.preserve_tags,
|
|
5924
|
+
strip_tags: val.strip_tags.into_iter().collect(),
|
|
5925
|
+
preserve_tags: val.preserve_tags.into_iter().collect(),
|
|
5220
5926
|
skip_images: val.skip_images,
|
|
5927
|
+
url_escape_style: val.url_escape_style.into(),
|
|
5221
5928
|
link_style: val.link_style.into(),
|
|
5222
5929
|
output_format: val.output_format.into(),
|
|
5223
5930
|
include_document_structure: val.include_document_structure,
|
|
@@ -5226,7 +5933,8 @@ impl From<ConversionOptions> for html_to_markdown_rs::options::ConversionOptions
|
|
|
5226
5933
|
capture_svg: val.capture_svg,
|
|
5227
5934
|
infer_dimensions: val.infer_dimensions,
|
|
5228
5935
|
max_depth: val.max_depth,
|
|
5229
|
-
exclude_selectors: val.exclude_selectors,
|
|
5936
|
+
exclude_selectors: val.exclude_selectors.into_iter().collect(),
|
|
5937
|
+
tier_strategy: val.tier_strategy.into(),
|
|
5230
5938
|
..Default::default()
|
|
5231
5939
|
}
|
|
5232
5940
|
}
|
|
@@ -5239,16 +5947,17 @@ impl From<html_to_markdown_rs::options::ConversionOptions> for ConversionOptions
|
|
|
5239
5947
|
heading_style: val.heading_style.into(),
|
|
5240
5948
|
list_indent_type: val.list_indent_type.into(),
|
|
5241
5949
|
list_indent_width: val.list_indent_width,
|
|
5242
|
-
bullets: val.bullets,
|
|
5950
|
+
bullets: val.bullets.to_string(),
|
|
5243
5951
|
strong_em_symbol: val.strong_em_symbol.to_string(),
|
|
5244
5952
|
escape_asterisks: val.escape_asterisks,
|
|
5245
5953
|
escape_underscores: val.escape_underscores,
|
|
5246
5954
|
escape_misc: val.escape_misc,
|
|
5247
5955
|
escape_ascii: val.escape_ascii,
|
|
5248
|
-
code_language: val.code_language,
|
|
5956
|
+
code_language: val.code_language.to_string(),
|
|
5249
5957
|
autolinks: val.autolinks,
|
|
5250
5958
|
default_title: val.default_title,
|
|
5251
5959
|
br_in_tables: val.br_in_tables,
|
|
5960
|
+
compact_tables: val.compact_tables,
|
|
5252
5961
|
highlight_style: val.highlight_style.into(),
|
|
5253
5962
|
extract_metadata: val.extract_metadata,
|
|
5254
5963
|
whitespace_mode: val.whitespace_mode.into(),
|
|
@@ -5256,17 +5965,18 @@ impl From<html_to_markdown_rs::options::ConversionOptions> for ConversionOptions
|
|
|
5256
5965
|
wrap: val.wrap,
|
|
5257
5966
|
wrap_width: val.wrap_width,
|
|
5258
5967
|
convert_as_inline: val.convert_as_inline,
|
|
5259
|
-
sub_symbol: val.sub_symbol,
|
|
5260
|
-
sup_symbol: val.sup_symbol,
|
|
5968
|
+
sub_symbol: val.sub_symbol.to_string(),
|
|
5969
|
+
sup_symbol: val.sup_symbol.to_string(),
|
|
5261
5970
|
newline_style: val.newline_style.into(),
|
|
5262
5971
|
code_block_style: val.code_block_style.into(),
|
|
5263
|
-
keep_inline_images_in: val.keep_inline_images_in,
|
|
5972
|
+
keep_inline_images_in: val.keep_inline_images_in.into_iter().collect(),
|
|
5264
5973
|
preprocessing: val.preprocessing.into(),
|
|
5265
|
-
encoding: val.encoding,
|
|
5974
|
+
encoding: val.encoding.to_string(),
|
|
5266
5975
|
debug: val.debug,
|
|
5267
|
-
strip_tags: val.strip_tags,
|
|
5268
|
-
preserve_tags: val.preserve_tags,
|
|
5976
|
+
strip_tags: val.strip_tags.into_iter().collect(),
|
|
5977
|
+
preserve_tags: val.preserve_tags.into_iter().collect(),
|
|
5269
5978
|
skip_images: val.skip_images,
|
|
5979
|
+
url_escape_style: val.url_escape_style.into(),
|
|
5270
5980
|
link_style: val.link_style.into(),
|
|
5271
5981
|
output_format: val.output_format.into(),
|
|
5272
5982
|
include_document_structure: val.include_document_structure,
|
|
@@ -5275,57 +5985,8 @@ impl From<html_to_markdown_rs::options::ConversionOptions> for ConversionOptions
|
|
|
5275
5985
|
capture_svg: val.capture_svg,
|
|
5276
5986
|
infer_dimensions: val.infer_dimensions,
|
|
5277
5987
|
max_depth: val.max_depth,
|
|
5278
|
-
exclude_selectors: val.exclude_selectors,
|
|
5279
|
-
|
|
5280
|
-
}
|
|
5281
|
-
}
|
|
5282
|
-
|
|
5283
|
-
#[allow(clippy::needless_update)]
|
|
5284
|
-
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
5285
|
-
impl From<ConversionOptionsUpdate> for html_to_markdown_rs::options::ConversionOptionsUpdate {
|
|
5286
|
-
fn from(val: ConversionOptionsUpdate) -> Self {
|
|
5287
|
-
Self {
|
|
5288
|
-
heading_style: val.heading_style.map(Into::into),
|
|
5289
|
-
list_indent_type: val.list_indent_type.map(Into::into),
|
|
5290
|
-
list_indent_width: val.list_indent_width,
|
|
5291
|
-
bullets: val.bullets,
|
|
5292
|
-
strong_em_symbol: val.strong_em_symbol.and_then(|s| s.chars().next()),
|
|
5293
|
-
escape_asterisks: val.escape_asterisks,
|
|
5294
|
-
escape_underscores: val.escape_underscores,
|
|
5295
|
-
escape_misc: val.escape_misc,
|
|
5296
|
-
escape_ascii: val.escape_ascii,
|
|
5297
|
-
code_language: val.code_language,
|
|
5298
|
-
autolinks: val.autolinks,
|
|
5299
|
-
default_title: val.default_title,
|
|
5300
|
-
br_in_tables: val.br_in_tables,
|
|
5301
|
-
highlight_style: val.highlight_style.map(Into::into),
|
|
5302
|
-
extract_metadata: val.extract_metadata,
|
|
5303
|
-
whitespace_mode: val.whitespace_mode.map(Into::into),
|
|
5304
|
-
strip_newlines: val.strip_newlines,
|
|
5305
|
-
wrap: val.wrap,
|
|
5306
|
-
wrap_width: val.wrap_width,
|
|
5307
|
-
convert_as_inline: val.convert_as_inline,
|
|
5308
|
-
sub_symbol: val.sub_symbol,
|
|
5309
|
-
sup_symbol: val.sup_symbol,
|
|
5310
|
-
newline_style: val.newline_style.map(Into::into),
|
|
5311
|
-
code_block_style: val.code_block_style.map(Into::into),
|
|
5312
|
-
keep_inline_images_in: val.keep_inline_images_in,
|
|
5313
|
-
preprocessing: val.preprocessing.map(Into::into),
|
|
5314
|
-
encoding: val.encoding,
|
|
5315
|
-
debug: val.debug,
|
|
5316
|
-
strip_tags: val.strip_tags,
|
|
5317
|
-
preserve_tags: val.preserve_tags,
|
|
5318
|
-
skip_images: val.skip_images,
|
|
5319
|
-
link_style: val.link_style.map(Into::into),
|
|
5320
|
-
output_format: val.output_format.map(Into::into),
|
|
5321
|
-
include_document_structure: val.include_document_structure,
|
|
5322
|
-
extract_images: val.extract_images,
|
|
5323
|
-
max_image_size: val.max_image_size,
|
|
5324
|
-
capture_svg: val.capture_svg,
|
|
5325
|
-
infer_dimensions: val.infer_dimensions,
|
|
5326
|
-
max_depth: (val.max_depth).map(Some),
|
|
5327
|
-
exclude_selectors: val.exclude_selectors,
|
|
5328
|
-
..Default::default()
|
|
5988
|
+
exclude_selectors: val.exclude_selectors.into_iter().collect(),
|
|
5989
|
+
tier_strategy: val.tier_strategy.into(),
|
|
5329
5990
|
}
|
|
5330
5991
|
}
|
|
5331
5992
|
}
|
|
@@ -5337,16 +5998,17 @@ impl From<html_to_markdown_rs::options::ConversionOptionsUpdate> for ConversionO
|
|
|
5337
5998
|
heading_style: val.heading_style.map(Into::into),
|
|
5338
5999
|
list_indent_type: val.list_indent_type.map(Into::into),
|
|
5339
6000
|
list_indent_width: val.list_indent_width,
|
|
5340
|
-
bullets: val.bullets,
|
|
6001
|
+
bullets: val.bullets.map(|v| v.to_string()),
|
|
5341
6002
|
strong_em_symbol: val.strong_em_symbol.map(|c| c.to_string()),
|
|
5342
6003
|
escape_asterisks: val.escape_asterisks,
|
|
5343
6004
|
escape_underscores: val.escape_underscores,
|
|
5344
6005
|
escape_misc: val.escape_misc,
|
|
5345
6006
|
escape_ascii: val.escape_ascii,
|
|
5346
|
-
code_language: val.code_language,
|
|
6007
|
+
code_language: val.code_language.map(|v| v.to_string()),
|
|
5347
6008
|
autolinks: val.autolinks,
|
|
5348
6009
|
default_title: val.default_title,
|
|
5349
6010
|
br_in_tables: val.br_in_tables,
|
|
6011
|
+
compact_tables: val.compact_tables,
|
|
5350
6012
|
highlight_style: val.highlight_style.map(Into::into),
|
|
5351
6013
|
extract_metadata: val.extract_metadata,
|
|
5352
6014
|
whitespace_mode: val.whitespace_mode.map(Into::into),
|
|
@@ -5354,17 +6016,18 @@ impl From<html_to_markdown_rs::options::ConversionOptionsUpdate> for ConversionO
|
|
|
5354
6016
|
wrap: val.wrap,
|
|
5355
6017
|
wrap_width: val.wrap_width,
|
|
5356
6018
|
convert_as_inline: val.convert_as_inline,
|
|
5357
|
-
sub_symbol: val.sub_symbol,
|
|
5358
|
-
sup_symbol: val.sup_symbol,
|
|
6019
|
+
sub_symbol: val.sub_symbol.map(|v| v.to_string()),
|
|
6020
|
+
sup_symbol: val.sup_symbol.map(|v| v.to_string()),
|
|
5359
6021
|
newline_style: val.newline_style.map(Into::into),
|
|
5360
6022
|
code_block_style: val.code_block_style.map(Into::into),
|
|
5361
|
-
keep_inline_images_in: val.keep_inline_images_in,
|
|
6023
|
+
keep_inline_images_in: val.keep_inline_images_in.map(|v| v.into_iter().collect()),
|
|
5362
6024
|
preprocessing: val.preprocessing.map(Into::into),
|
|
5363
|
-
encoding: val.encoding,
|
|
6025
|
+
encoding: val.encoding.map(|v| v.to_string()),
|
|
5364
6026
|
debug: val.debug,
|
|
5365
|
-
strip_tags: val.strip_tags,
|
|
5366
|
-
preserve_tags: val.preserve_tags,
|
|
6027
|
+
strip_tags: val.strip_tags.map(|v| v.into_iter().collect()),
|
|
6028
|
+
preserve_tags: val.preserve_tags.map(|v| v.into_iter().collect()),
|
|
5367
6029
|
skip_images: val.skip_images,
|
|
6030
|
+
url_escape_style: val.url_escape_style.map(Into::into),
|
|
5368
6031
|
link_style: val.link_style.map(Into::into),
|
|
5369
6032
|
output_format: val.output_format.map(Into::into),
|
|
5370
6033
|
include_document_structure: val.include_document_structure,
|
|
@@ -5373,7 +6036,8 @@ impl From<html_to_markdown_rs::options::ConversionOptionsUpdate> for ConversionO
|
|
|
5373
6036
|
capture_svg: val.capture_svg,
|
|
5374
6037
|
infer_dimensions: val.infer_dimensions,
|
|
5375
6038
|
max_depth: val.max_depth.flatten(),
|
|
5376
|
-
exclude_selectors: val.exclude_selectors,
|
|
6039
|
+
exclude_selectors: val.exclude_selectors.map(|v| v.into_iter().collect()),
|
|
6040
|
+
tier_strategy: val.tier_strategy.map(Into::into),
|
|
5377
6041
|
}
|
|
5378
6042
|
}
|
|
5379
6043
|
}
|
|
@@ -5403,8 +6067,8 @@ impl From<html_to_markdown_rs::options::PreprocessingOptions> for PreprocessingO
|
|
|
5403
6067
|
}
|
|
5404
6068
|
|
|
5405
6069
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
5406
|
-
impl From<PreprocessingOptionsUpdate> for
|
|
5407
|
-
fn from(val: PreprocessingOptionsUpdate) -> Self {
|
|
6070
|
+
impl From<html_to_markdown_rs::options::PreprocessingOptionsUpdate> for PreprocessingOptionsUpdate {
|
|
6071
|
+
fn from(val: html_to_markdown_rs::options::PreprocessingOptionsUpdate) -> Self {
|
|
5408
6072
|
Self {
|
|
5409
6073
|
enabled: val.enabled,
|
|
5410
6074
|
preset: val.preset.map(Into::into),
|
|
@@ -5415,13 +6079,21 @@ impl From<PreprocessingOptionsUpdate> for html_to_markdown_rs::options::Preproce
|
|
|
5415
6079
|
}
|
|
5416
6080
|
|
|
5417
6081
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
5418
|
-
impl From<
|
|
5419
|
-
fn from(val:
|
|
6082
|
+
impl From<ImageDimensions> for html_to_markdown_rs::ImageDimensions {
|
|
6083
|
+
fn from(val: ImageDimensions) -> Self {
|
|
5420
6084
|
Self {
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
6085
|
+
width: val.width,
|
|
6086
|
+
height: val.height,
|
|
6087
|
+
}
|
|
6088
|
+
}
|
|
6089
|
+
}
|
|
6090
|
+
|
|
6091
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6092
|
+
impl From<html_to_markdown_rs::ImageDimensions> for ImageDimensions {
|
|
6093
|
+
fn from(val: html_to_markdown_rs::ImageDimensions) -> Self {
|
|
6094
|
+
Self {
|
|
6095
|
+
width: val.width,
|
|
6096
|
+
height: val.height,
|
|
5425
6097
|
}
|
|
5426
6098
|
}
|
|
5427
6099
|
}
|
|
@@ -5441,7 +6113,7 @@ impl From<html_to_markdown_rs::DocumentStructure> for DocumentStructure {
|
|
|
5441
6113
|
fn from(val: html_to_markdown_rs::DocumentStructure) -> Self {
|
|
5442
6114
|
Self {
|
|
5443
6115
|
nodes: val.nodes.into_iter().map(Into::into).collect(),
|
|
5444
|
-
source_format: val.source_format,
|
|
6116
|
+
source_format: val.source_format.map(|v| v.to_string()),
|
|
5445
6117
|
}
|
|
5446
6118
|
}
|
|
5447
6119
|
}
|
|
@@ -5453,7 +6125,7 @@ impl From<DocumentNode> for html_to_markdown_rs::DocumentNode {
|
|
|
5453
6125
|
id: val.id,
|
|
5454
6126
|
content: val.content.into(),
|
|
5455
6127
|
parent: val.parent,
|
|
5456
|
-
children: val.children,
|
|
6128
|
+
children: val.children.into_iter().collect(),
|
|
5457
6129
|
annotations: val.annotations.into_iter().map(Into::into).collect(),
|
|
5458
6130
|
attributes: val
|
|
5459
6131
|
.attributes
|
|
@@ -5466,10 +6138,10 @@ impl From<DocumentNode> for html_to_markdown_rs::DocumentNode {
|
|
|
5466
6138
|
impl From<html_to_markdown_rs::DocumentNode> for DocumentNode {
|
|
5467
6139
|
fn from(val: html_to_markdown_rs::DocumentNode) -> Self {
|
|
5468
6140
|
Self {
|
|
5469
|
-
id: val.id,
|
|
6141
|
+
id: val.id.to_string(),
|
|
5470
6142
|
content: val.content.into(),
|
|
5471
6143
|
parent: val.parent,
|
|
5472
|
-
children: val.children,
|
|
6144
|
+
children: val.children.into_iter().collect(),
|
|
5473
6145
|
annotations: val.annotations.into_iter().map(Into::into).collect(),
|
|
5474
6146
|
attributes: val
|
|
5475
6147
|
.attributes
|
|
@@ -5500,6 +6172,26 @@ impl From<html_to_markdown_rs::TextAnnotation> for TextAnnotation {
|
|
|
5500
6172
|
}
|
|
5501
6173
|
}
|
|
5502
6174
|
|
|
6175
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6176
|
+
impl From<MetadataEntry> for html_to_markdown_rs::MetadataEntry {
|
|
6177
|
+
fn from(val: MetadataEntry) -> Self {
|
|
6178
|
+
Self {
|
|
6179
|
+
key: val.key,
|
|
6180
|
+
value: val.value,
|
|
6181
|
+
}
|
|
6182
|
+
}
|
|
6183
|
+
}
|
|
6184
|
+
|
|
6185
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6186
|
+
impl From<html_to_markdown_rs::MetadataEntry> for MetadataEntry {
|
|
6187
|
+
fn from(val: html_to_markdown_rs::MetadataEntry) -> Self {
|
|
6188
|
+
Self {
|
|
6189
|
+
key: val.key.to_string(),
|
|
6190
|
+
value: val.value.to_string(),
|
|
6191
|
+
}
|
|
6192
|
+
}
|
|
6193
|
+
}
|
|
6194
|
+
|
|
5503
6195
|
#[allow(clippy::needless_update)]
|
|
5504
6196
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
5505
6197
|
impl From<ConversionResult> for html_to_markdown_rs::ConversionResult {
|
|
@@ -5509,7 +6201,6 @@ impl From<ConversionResult> for html_to_markdown_rs::ConversionResult {
|
|
|
5509
6201
|
document: val.document.map(Into::into),
|
|
5510
6202
|
metadata: val.metadata.into(),
|
|
5511
6203
|
tables: val.tables.into_iter().map(Into::into).collect(),
|
|
5512
|
-
images: Default::default(),
|
|
5513
6204
|
warnings: val.warnings.into_iter().map(Into::into).collect(),
|
|
5514
6205
|
..Default::default()
|
|
5515
6206
|
}
|
|
@@ -5520,11 +6211,10 @@ impl From<ConversionResult> for html_to_markdown_rs::ConversionResult {
|
|
|
5520
6211
|
impl From<html_to_markdown_rs::ConversionResult> for ConversionResult {
|
|
5521
6212
|
fn from(val: html_to_markdown_rs::ConversionResult) -> Self {
|
|
5522
6213
|
Self {
|
|
5523
|
-
content: val.content,
|
|
6214
|
+
content: val.content.map(|v| v.to_string()),
|
|
5524
6215
|
document: val.document.map(Into::into),
|
|
5525
6216
|
metadata: val.metadata.into(),
|
|
5526
6217
|
tables: val.tables.into_iter().map(Into::into).collect(),
|
|
5527
|
-
images: val.images.iter().map(|i| format!("{:?}", i)).collect(),
|
|
5528
6218
|
warnings: val.warnings.into_iter().map(Into::into).collect(),
|
|
5529
6219
|
}
|
|
5530
6220
|
}
|
|
@@ -5570,7 +6260,7 @@ impl From<GridCell> for html_to_markdown_rs::GridCell {
|
|
|
5570
6260
|
impl From<html_to_markdown_rs::GridCell> for GridCell {
|
|
5571
6261
|
fn from(val: html_to_markdown_rs::GridCell) -> Self {
|
|
5572
6262
|
Self {
|
|
5573
|
-
content: val.content,
|
|
6263
|
+
content: val.content.to_string(),
|
|
5574
6264
|
row: val.row,
|
|
5575
6265
|
col: val.col,
|
|
5576
6266
|
row_span: val.row_span,
|
|
@@ -5595,7 +6285,7 @@ impl From<html_to_markdown_rs::TableData> for TableData {
|
|
|
5595
6285
|
fn from(val: html_to_markdown_rs::TableData) -> Self {
|
|
5596
6286
|
Self {
|
|
5597
6287
|
grid: val.grid.into(),
|
|
5598
|
-
markdown: val.markdown,
|
|
6288
|
+
markdown: val.markdown.to_string(),
|
|
5599
6289
|
}
|
|
5600
6290
|
}
|
|
5601
6291
|
}
|
|
@@ -5614,22 +6304,36 @@ impl From<ProcessingWarning> for html_to_markdown_rs::ProcessingWarning {
|
|
|
5614
6304
|
impl From<html_to_markdown_rs::ProcessingWarning> for ProcessingWarning {
|
|
5615
6305
|
fn from(val: html_to_markdown_rs::ProcessingWarning) -> Self {
|
|
5616
6306
|
Self {
|
|
5617
|
-
message: val.message,
|
|
6307
|
+
message: val.message.to_string(),
|
|
5618
6308
|
kind: val.kind.into(),
|
|
5619
6309
|
}
|
|
5620
6310
|
}
|
|
5621
6311
|
}
|
|
5622
6312
|
|
|
5623
6313
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
5624
|
-
impl From<
|
|
5625
|
-
fn from(val:
|
|
6314
|
+
impl From<NodeContext> for html_to_markdown_rs::NodeContext<'_> {
|
|
6315
|
+
fn from(val: NodeContext) -> Self {
|
|
6316
|
+
html_to_markdown_rs::NodeContext::with_owned_attributes(
|
|
6317
|
+
val.node_type.into(),
|
|
6318
|
+
val.tag_name.into(),
|
|
6319
|
+
std::collections::BTreeMap::new(),
|
|
6320
|
+
val.depth,
|
|
6321
|
+
val.index_in_parent,
|
|
6322
|
+
val.parent_tag.map(Into::into),
|
|
6323
|
+
val.is_inline,
|
|
6324
|
+
)
|
|
6325
|
+
}
|
|
6326
|
+
}
|
|
6327
|
+
|
|
6328
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
6329
|
+
impl From<html_to_markdown_rs::NodeContext<'_>> for NodeContext {
|
|
6330
|
+
fn from(val: html_to_markdown_rs::NodeContext<'_>) -> Self {
|
|
5626
6331
|
Self {
|
|
5627
6332
|
node_type: val.node_type.into(),
|
|
5628
|
-
tag_name: val.tag_name,
|
|
5629
|
-
attributes: val.attributes.into_iter().map(|(k, v)| (k.into(), v.into())).collect(),
|
|
6333
|
+
tag_name: val.tag_name.to_string(),
|
|
5630
6334
|
depth: val.depth,
|
|
5631
6335
|
index_in_parent: val.index_in_parent,
|
|
5632
|
-
parent_tag: val.parent_tag,
|
|
6336
|
+
parent_tag: val.parent_tag.as_ref().map(|v| v.to_string()),
|
|
5633
6337
|
is_inline: val.is_inline,
|
|
5634
6338
|
}
|
|
5635
6339
|
}
|
|
@@ -5723,6 +6427,26 @@ impl From<html_to_markdown_rs::metadata::StructuredDataType> for StructuredDataT
|
|
|
5723
6427
|
}
|
|
5724
6428
|
}
|
|
5725
6429
|
|
|
6430
|
+
impl From<TierStrategy> for html_to_markdown_rs::options::TierStrategy {
|
|
6431
|
+
fn from(val: TierStrategy) -> Self {
|
|
6432
|
+
match val {
|
|
6433
|
+
TierStrategy::Auto => Self::Auto,
|
|
6434
|
+
TierStrategy::Tier2 => Self::Tier2,
|
|
6435
|
+
TierStrategy::Tier1 => Self::Tier1,
|
|
6436
|
+
}
|
|
6437
|
+
}
|
|
6438
|
+
}
|
|
6439
|
+
|
|
6440
|
+
impl From<html_to_markdown_rs::options::TierStrategy> for TierStrategy {
|
|
6441
|
+
fn from(val: html_to_markdown_rs::options::TierStrategy) -> Self {
|
|
6442
|
+
match val {
|
|
6443
|
+
html_to_markdown_rs::options::TierStrategy::Auto => Self::Auto,
|
|
6444
|
+
html_to_markdown_rs::options::TierStrategy::Tier2 => Self::Tier2,
|
|
6445
|
+
html_to_markdown_rs::options::TierStrategy::Tier1 => Self::Tier1,
|
|
6446
|
+
}
|
|
6447
|
+
}
|
|
6448
|
+
}
|
|
6449
|
+
|
|
5726
6450
|
impl From<PreprocessingPreset> for html_to_markdown_rs::options::PreprocessingPreset {
|
|
5727
6451
|
fn from(val: PreprocessingPreset) -> Self {
|
|
5728
6452
|
match val {
|
|
@@ -5877,6 +6601,24 @@ impl From<html_to_markdown_rs::options::LinkStyle> for LinkStyle {
|
|
|
5877
6601
|
}
|
|
5878
6602
|
}
|
|
5879
6603
|
|
|
6604
|
+
impl From<UrlEscapeStyle> for html_to_markdown_rs::options::UrlEscapeStyle {
|
|
6605
|
+
fn from(val: UrlEscapeStyle) -> Self {
|
|
6606
|
+
match val {
|
|
6607
|
+
UrlEscapeStyle::Angle => Self::Angle,
|
|
6608
|
+
UrlEscapeStyle::Percent => Self::Percent,
|
|
6609
|
+
}
|
|
6610
|
+
}
|
|
6611
|
+
}
|
|
6612
|
+
|
|
6613
|
+
impl From<html_to_markdown_rs::options::UrlEscapeStyle> for UrlEscapeStyle {
|
|
6614
|
+
fn from(val: html_to_markdown_rs::options::UrlEscapeStyle) -> Self {
|
|
6615
|
+
match val {
|
|
6616
|
+
html_to_markdown_rs::options::UrlEscapeStyle::Angle => Self::Angle,
|
|
6617
|
+
html_to_markdown_rs::options::UrlEscapeStyle::Percent => Self::Percent,
|
|
6618
|
+
}
|
|
6619
|
+
}
|
|
6620
|
+
}
|
|
6621
|
+
|
|
5880
6622
|
impl From<OutputFormat> for html_to_markdown_rs::options::OutputFormat {
|
|
5881
6623
|
fn from(val: OutputFormat) -> Self {
|
|
5882
6624
|
match val {
|
|
@@ -5920,7 +6662,7 @@ impl From<NodeContent> for html_to_markdown_rs::NodeContent {
|
|
|
5920
6662
|
NodeContent::DefinitionItem { term, definition } => Self::DefinitionItem { term, definition },
|
|
5921
6663
|
NodeContent::RawBlock { format, content } => Self::RawBlock { format, content },
|
|
5922
6664
|
NodeContent::MetadataBlock { entries } => Self::MetadataBlock {
|
|
5923
|
-
entries: entries.
|
|
6665
|
+
entries: entries.into_iter().map(Into::into).collect(),
|
|
5924
6666
|
},
|
|
5925
6667
|
NodeContent::Group {
|
|
5926
6668
|
label,
|
|
@@ -5938,38 +6680,48 @@ impl From<NodeContent> for html_to_markdown_rs::NodeContent {
|
|
|
5938
6680
|
impl From<html_to_markdown_rs::NodeContent> for NodeContent {
|
|
5939
6681
|
fn from(val: html_to_markdown_rs::NodeContent) -> Self {
|
|
5940
6682
|
match val {
|
|
5941
|
-
html_to_markdown_rs::NodeContent::Heading { level, text } => Self::Heading {
|
|
5942
|
-
|
|
6683
|
+
html_to_markdown_rs::NodeContent::Heading { level, text } => Self::Heading {
|
|
6684
|
+
level,
|
|
6685
|
+
text: text.to_string(),
|
|
6686
|
+
},
|
|
6687
|
+
html_to_markdown_rs::NodeContent::Paragraph { text } => Self::Paragraph { text: text.to_string() },
|
|
5943
6688
|
html_to_markdown_rs::NodeContent::List { ordered } => Self::List { ordered },
|
|
5944
|
-
html_to_markdown_rs::NodeContent::ListItem { text } => Self::ListItem { text },
|
|
6689
|
+
html_to_markdown_rs::NodeContent::ListItem { text } => Self::ListItem { text: text.to_string() },
|
|
5945
6690
|
html_to_markdown_rs::NodeContent::Table { grid } => Self::Table { grid: grid.into() },
|
|
5946
6691
|
html_to_markdown_rs::NodeContent::Image {
|
|
5947
6692
|
description,
|
|
5948
6693
|
src,
|
|
5949
6694
|
image_index,
|
|
5950
6695
|
} => Self::Image {
|
|
5951
|
-
description,
|
|
5952
|
-
src,
|
|
6696
|
+
description: description.map(|v| v.to_string()),
|
|
6697
|
+
src: src.map(|v| v.to_string()),
|
|
5953
6698
|
image_index,
|
|
5954
6699
|
},
|
|
5955
|
-
html_to_markdown_rs::NodeContent::Code { text, language } => Self::Code {
|
|
6700
|
+
html_to_markdown_rs::NodeContent::Code { text, language } => Self::Code {
|
|
6701
|
+
text: text.to_string(),
|
|
6702
|
+
language: language.map(|v| v.to_string()),
|
|
6703
|
+
},
|
|
5956
6704
|
html_to_markdown_rs::NodeContent::Quote => Self::Quote,
|
|
5957
6705
|
html_to_markdown_rs::NodeContent::DefinitionList => Self::DefinitionList,
|
|
5958
|
-
html_to_markdown_rs::NodeContent::DefinitionItem { term, definition } => {
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
6706
|
+
html_to_markdown_rs::NodeContent::DefinitionItem { term, definition } => Self::DefinitionItem {
|
|
6707
|
+
term: term.to_string(),
|
|
6708
|
+
definition: definition.to_string(),
|
|
6709
|
+
},
|
|
6710
|
+
html_to_markdown_rs::NodeContent::RawBlock { format, content } => Self::RawBlock {
|
|
6711
|
+
format: format.to_string(),
|
|
6712
|
+
content: content.to_string(),
|
|
6713
|
+
},
|
|
5962
6714
|
html_to_markdown_rs::NodeContent::MetadataBlock { entries } => Self::MetadataBlock {
|
|
5963
|
-
entries: entries.
|
|
6715
|
+
entries: entries.into_iter().map(Into::into).collect(),
|
|
5964
6716
|
},
|
|
5965
6717
|
html_to_markdown_rs::NodeContent::Group {
|
|
5966
6718
|
label,
|
|
5967
6719
|
heading_level,
|
|
5968
6720
|
heading_text,
|
|
5969
6721
|
} => Self::Group {
|
|
5970
|
-
label,
|
|
6722
|
+
label: label.map(|v| v.to_string()),
|
|
5971
6723
|
heading_level,
|
|
5972
|
-
heading_text,
|
|
6724
|
+
heading_text: heading_text.map(|v| v.to_string()),
|
|
5973
6725
|
},
|
|
5974
6726
|
}
|
|
5975
6727
|
}
|
|
@@ -6002,7 +6754,10 @@ impl From<html_to_markdown_rs::AnnotationKind> for AnnotationKind {
|
|
|
6002
6754
|
html_to_markdown_rs::AnnotationKind::Subscript => Self::Subscript,
|
|
6003
6755
|
html_to_markdown_rs::AnnotationKind::Superscript => Self::Superscript,
|
|
6004
6756
|
html_to_markdown_rs::AnnotationKind::Highlight => Self::Highlight,
|
|
6005
|
-
html_to_markdown_rs::AnnotationKind::Link { url, title } => Self::Link {
|
|
6757
|
+
html_to_markdown_rs::AnnotationKind::Link { url, title } => Self::Link {
|
|
6758
|
+
url: url.to_string(),
|
|
6759
|
+
title: title.map(|v| v.to_string()),
|
|
6760
|
+
},
|
|
6006
6761
|
}
|
|
6007
6762
|
}
|
|
6008
6763
|
}
|
|
@@ -6033,6 +6788,101 @@ impl From<html_to_markdown_rs::WarningKind> for WarningKind {
|
|
|
6033
6788
|
}
|
|
6034
6789
|
}
|
|
6035
6790
|
|
|
6791
|
+
impl From<NodeType> for html_to_markdown_rs::NodeType {
|
|
6792
|
+
fn from(val: NodeType) -> Self {
|
|
6793
|
+
match val {
|
|
6794
|
+
NodeType::Text => Self::Text,
|
|
6795
|
+
NodeType::Element => Self::Element,
|
|
6796
|
+
NodeType::Heading => Self::Heading,
|
|
6797
|
+
NodeType::Paragraph => Self::Paragraph,
|
|
6798
|
+
NodeType::Div => Self::Div,
|
|
6799
|
+
NodeType::Blockquote => Self::Blockquote,
|
|
6800
|
+
NodeType::Pre => Self::Pre,
|
|
6801
|
+
NodeType::Hr => Self::Hr,
|
|
6802
|
+
NodeType::List => Self::List,
|
|
6803
|
+
NodeType::ListItem => Self::ListItem,
|
|
6804
|
+
NodeType::DefinitionList => Self::DefinitionList,
|
|
6805
|
+
NodeType::DefinitionTerm => Self::DefinitionTerm,
|
|
6806
|
+
NodeType::DefinitionDescription => Self::DefinitionDescription,
|
|
6807
|
+
NodeType::Table => Self::Table,
|
|
6808
|
+
NodeType::TableRow => Self::TableRow,
|
|
6809
|
+
NodeType::TableCell => Self::TableCell,
|
|
6810
|
+
NodeType::TableHeader => Self::TableHeader,
|
|
6811
|
+
NodeType::TableBody => Self::TableBody,
|
|
6812
|
+
NodeType::TableHead => Self::TableHead,
|
|
6813
|
+
NodeType::TableFoot => Self::TableFoot,
|
|
6814
|
+
NodeType::Link => Self::Link,
|
|
6815
|
+
NodeType::Image => Self::Image,
|
|
6816
|
+
NodeType::Strong => Self::Strong,
|
|
6817
|
+
NodeType::Em => Self::Em,
|
|
6818
|
+
NodeType::Code => Self::Code,
|
|
6819
|
+
NodeType::Strikethrough => Self::Strikethrough,
|
|
6820
|
+
NodeType::Underline => Self::Underline,
|
|
6821
|
+
NodeType::Subscript => Self::Subscript,
|
|
6822
|
+
NodeType::Superscript => Self::Superscript,
|
|
6823
|
+
NodeType::Mark => Self::Mark,
|
|
6824
|
+
NodeType::Small => Self::Small,
|
|
6825
|
+
NodeType::Br => Self::Br,
|
|
6826
|
+
NodeType::Span => Self::Span,
|
|
6827
|
+
NodeType::Article => Self::Article,
|
|
6828
|
+
NodeType::Section => Self::Section,
|
|
6829
|
+
NodeType::Nav => Self::Nav,
|
|
6830
|
+
NodeType::Aside => Self::Aside,
|
|
6831
|
+
NodeType::Header => Self::Header,
|
|
6832
|
+
NodeType::Footer => Self::Footer,
|
|
6833
|
+
NodeType::Main => Self::Main,
|
|
6834
|
+
NodeType::Figure => Self::Figure,
|
|
6835
|
+
NodeType::Figcaption => Self::Figcaption,
|
|
6836
|
+
NodeType::Time => Self::Time,
|
|
6837
|
+
NodeType::Details => Self::Details,
|
|
6838
|
+
NodeType::Summary => Self::Summary,
|
|
6839
|
+
NodeType::Form => Self::Form,
|
|
6840
|
+
NodeType::Input => Self::Input,
|
|
6841
|
+
NodeType::Select => Self::Select,
|
|
6842
|
+
NodeType::Option => Self::Option,
|
|
6843
|
+
NodeType::Button => Self::Button,
|
|
6844
|
+
NodeType::Textarea => Self::Textarea,
|
|
6845
|
+
NodeType::Label => Self::Label,
|
|
6846
|
+
NodeType::Fieldset => Self::Fieldset,
|
|
6847
|
+
NodeType::Legend => Self::Legend,
|
|
6848
|
+
NodeType::Audio => Self::Audio,
|
|
6849
|
+
NodeType::Video => Self::Video,
|
|
6850
|
+
NodeType::Picture => Self::Picture,
|
|
6851
|
+
NodeType::Source => Self::Source,
|
|
6852
|
+
NodeType::Iframe => Self::Iframe,
|
|
6853
|
+
NodeType::Svg => Self::Svg,
|
|
6854
|
+
NodeType::Canvas => Self::Canvas,
|
|
6855
|
+
NodeType::Ruby => Self::Ruby,
|
|
6856
|
+
NodeType::Rt => Self::Rt,
|
|
6857
|
+
NodeType::Rp => Self::Rp,
|
|
6858
|
+
NodeType::Abbr => Self::Abbr,
|
|
6859
|
+
NodeType::Kbd => Self::Kbd,
|
|
6860
|
+
NodeType::Samp => Self::Samp,
|
|
6861
|
+
NodeType::Var => Self::Var,
|
|
6862
|
+
NodeType::Cite => Self::Cite,
|
|
6863
|
+
NodeType::Q => Self::Q,
|
|
6864
|
+
NodeType::Del => Self::Del,
|
|
6865
|
+
NodeType::Ins => Self::Ins,
|
|
6866
|
+
NodeType::Data => Self::Data,
|
|
6867
|
+
NodeType::Meter => Self::Meter,
|
|
6868
|
+
NodeType::Progress => Self::Progress,
|
|
6869
|
+
NodeType::Output => Self::Output,
|
|
6870
|
+
NodeType::Template => Self::Template,
|
|
6871
|
+
NodeType::Slot => Self::Slot,
|
|
6872
|
+
NodeType::Html => Self::Html,
|
|
6873
|
+
NodeType::Head => Self::Head,
|
|
6874
|
+
NodeType::Body => Self::Body,
|
|
6875
|
+
NodeType::Title => Self::Title,
|
|
6876
|
+
NodeType::Meta => Self::Meta,
|
|
6877
|
+
NodeType::LinkTag => Self::LinkTag,
|
|
6878
|
+
NodeType::Style => Self::Style,
|
|
6879
|
+
NodeType::Script => Self::Script,
|
|
6880
|
+
NodeType::Base => Self::Base,
|
|
6881
|
+
NodeType::Custom => Self::Custom,
|
|
6882
|
+
}
|
|
6883
|
+
}
|
|
6884
|
+
}
|
|
6885
|
+
|
|
6036
6886
|
impl From<html_to_markdown_rs::NodeType> for NodeType {
|
|
6037
6887
|
fn from(val: html_to_markdown_rs::NodeType) -> Self {
|
|
6038
6888
|
match val {
|
|
@@ -6132,10 +6982,10 @@ impl From<html_to_markdown_rs::VisitResult> for VisitResult {
|
|
|
6132
6982
|
fn from(val: html_to_markdown_rs::VisitResult) -> Self {
|
|
6133
6983
|
match val {
|
|
6134
6984
|
html_to_markdown_rs::VisitResult::Continue => Self::Continue,
|
|
6135
|
-
html_to_markdown_rs::VisitResult::Custom(_0) => Self::Custom { _0 },
|
|
6985
|
+
html_to_markdown_rs::VisitResult::Custom(_0) => Self::Custom { _0: _0.to_string() },
|
|
6136
6986
|
html_to_markdown_rs::VisitResult::Skip => Self::Skip,
|
|
6137
6987
|
html_to_markdown_rs::VisitResult::PreserveHtml => Self::PreserveHtml,
|
|
6138
|
-
html_to_markdown_rs::VisitResult::Error(_0) => Self::Error { _0 },
|
|
6988
|
+
html_to_markdown_rs::VisitResult::Error(_0) => Self::Error { _0: _0.to_string() },
|
|
6139
6989
|
}
|
|
6140
6990
|
}
|
|
6141
6991
|
}
|
|
@@ -6151,272 +7001,491 @@ fn conversion_error_to_magnus_err(e: html_to_markdown_rs::error::ConversionError
|
|
|
6151
7001
|
fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
6152
7002
|
let module = ruby.define_module("HtmlToMarkdownRs")?;
|
|
6153
7003
|
|
|
7004
|
+
// Ensure JSON library is loaded for Hash#to_json
|
|
7005
|
+
let _ = ruby.eval::<magnus::Value>("require \"json\"");
|
|
7006
|
+
|
|
6154
7007
|
let class = module.define_class("DocumentMetadata", ruby.class_object())?;
|
|
7008
|
+
|
|
6155
7009
|
class.define_singleton_method("new", function!(DocumentMetadata::new, -1))?;
|
|
7010
|
+
|
|
6156
7011
|
class.define_method("title", method!(DocumentMetadata::title, 0))?;
|
|
7012
|
+
|
|
6157
7013
|
class.define_method("description", method!(DocumentMetadata::description, 0))?;
|
|
7014
|
+
|
|
6158
7015
|
class.define_method("keywords", method!(DocumentMetadata::keywords, 0))?;
|
|
7016
|
+
|
|
6159
7017
|
class.define_method("author", method!(DocumentMetadata::author, 0))?;
|
|
7018
|
+
|
|
6160
7019
|
class.define_method("canonical_url", method!(DocumentMetadata::canonical_url, 0))?;
|
|
7020
|
+
|
|
6161
7021
|
class.define_method("base_href", method!(DocumentMetadata::base_href, 0))?;
|
|
7022
|
+
|
|
6162
7023
|
class.define_method("language", method!(DocumentMetadata::language, 0))?;
|
|
7024
|
+
|
|
6163
7025
|
class.define_method("text_direction", method!(DocumentMetadata::text_direction, 0))?;
|
|
7026
|
+
|
|
6164
7027
|
class.define_method("open_graph", method!(DocumentMetadata::open_graph, 0))?;
|
|
7028
|
+
|
|
6165
7029
|
class.define_method("twitter_card", method!(DocumentMetadata::twitter_card, 0))?;
|
|
7030
|
+
|
|
6166
7031
|
class.define_method("meta_tags", method!(DocumentMetadata::meta_tags, 0))?;
|
|
6167
7032
|
|
|
6168
7033
|
let class = module.define_class("HeaderMetadata", ruby.class_object())?;
|
|
7034
|
+
|
|
6169
7035
|
class.define_singleton_method("new", function!(HeaderMetadata::new, -1))?;
|
|
7036
|
+
|
|
6170
7037
|
class.define_method("level", method!(HeaderMetadata::level, 0))?;
|
|
7038
|
+
|
|
6171
7039
|
class.define_method("text", method!(HeaderMetadata::text, 0))?;
|
|
7040
|
+
|
|
6172
7041
|
class.define_method("id", method!(HeaderMetadata::id, 0))?;
|
|
7042
|
+
|
|
6173
7043
|
class.define_method("depth", method!(HeaderMetadata::depth, 0))?;
|
|
7044
|
+
|
|
6174
7045
|
class.define_method("html_offset", method!(HeaderMetadata::html_offset, 0))?;
|
|
7046
|
+
|
|
6175
7047
|
class.define_method("is_valid", method!(HeaderMetadata::is_valid, 0))?;
|
|
6176
7048
|
|
|
6177
7049
|
let class = module.define_class("LinkMetadata", ruby.class_object())?;
|
|
7050
|
+
|
|
6178
7051
|
class.define_singleton_method("new", function!(LinkMetadata::new, -1))?;
|
|
7052
|
+
|
|
6179
7053
|
class.define_method("href", method!(LinkMetadata::href, 0))?;
|
|
7054
|
+
|
|
6180
7055
|
class.define_method("text", method!(LinkMetadata::text, 0))?;
|
|
7056
|
+
|
|
6181
7057
|
class.define_method("title", method!(LinkMetadata::title, 0))?;
|
|
7058
|
+
|
|
6182
7059
|
class.define_method("link_type", method!(LinkMetadata::link_type, 0))?;
|
|
7060
|
+
|
|
6183
7061
|
class.define_method("rel", method!(LinkMetadata::rel, 0))?;
|
|
7062
|
+
|
|
6184
7063
|
class.define_method("attributes", method!(LinkMetadata::attributes, 0))?;
|
|
6185
7064
|
|
|
6186
7065
|
let class = module.define_class("ImageMetadata", ruby.class_object())?;
|
|
7066
|
+
|
|
6187
7067
|
class.define_singleton_method("new", function!(ImageMetadata::new, -1))?;
|
|
7068
|
+
|
|
6188
7069
|
class.define_method("src", method!(ImageMetadata::src, 0))?;
|
|
7070
|
+
|
|
6189
7071
|
class.define_method("alt", method!(ImageMetadata::alt, 0))?;
|
|
7072
|
+
|
|
6190
7073
|
class.define_method("title", method!(ImageMetadata::title, 0))?;
|
|
7074
|
+
|
|
6191
7075
|
class.define_method("dimensions", method!(ImageMetadata::dimensions, 0))?;
|
|
7076
|
+
|
|
6192
7077
|
class.define_method("image_type", method!(ImageMetadata::image_type, 0))?;
|
|
7078
|
+
|
|
6193
7079
|
class.define_method("attributes", method!(ImageMetadata::attributes, 0))?;
|
|
6194
7080
|
|
|
6195
7081
|
let class = module.define_class("StructuredData", ruby.class_object())?;
|
|
7082
|
+
|
|
6196
7083
|
class.define_singleton_method("new", function!(StructuredData::new, -1))?;
|
|
7084
|
+
|
|
6197
7085
|
class.define_method("data_type", method!(StructuredData::data_type, 0))?;
|
|
7086
|
+
|
|
6198
7087
|
class.define_method("raw_json", method!(StructuredData::raw_json, 0))?;
|
|
7088
|
+
|
|
6199
7089
|
class.define_method("schema_type", method!(StructuredData::schema_type, 0))?;
|
|
6200
7090
|
|
|
6201
7091
|
let class = module.define_class("HtmlMetadata", ruby.class_object())?;
|
|
7092
|
+
|
|
6202
7093
|
class.define_singleton_method("new", function!(HtmlMetadata::new, -1))?;
|
|
7094
|
+
|
|
6203
7095
|
class.define_method("document", method!(HtmlMetadata::document, 0))?;
|
|
7096
|
+
|
|
6204
7097
|
class.define_method("headers", method!(HtmlMetadata::headers, 0))?;
|
|
7098
|
+
|
|
6205
7099
|
class.define_method("links", method!(HtmlMetadata::links, 0))?;
|
|
7100
|
+
|
|
6206
7101
|
class.define_method("images", method!(HtmlMetadata::images, 0))?;
|
|
7102
|
+
|
|
6207
7103
|
class.define_method("structured_data", method!(HtmlMetadata::structured_data, 0))?;
|
|
6208
7104
|
|
|
6209
7105
|
let class = module.define_class("ConversionOptions", ruby.class_object())?;
|
|
7106
|
+
|
|
6210
7107
|
class.define_singleton_method("new", function!(ConversionOptions::new, -1))?;
|
|
7108
|
+
|
|
6211
7109
|
class.define_method("heading_style", method!(ConversionOptions::heading_style, 0))?;
|
|
7110
|
+
|
|
6212
7111
|
class.define_method("list_indent_type", method!(ConversionOptions::list_indent_type, 0))?;
|
|
7112
|
+
|
|
6213
7113
|
class.define_method("list_indent_width", method!(ConversionOptions::list_indent_width, 0))?;
|
|
7114
|
+
|
|
6214
7115
|
class.define_method("bullets", method!(ConversionOptions::bullets, 0))?;
|
|
7116
|
+
|
|
6215
7117
|
class.define_method("strong_em_symbol", method!(ConversionOptions::strong_em_symbol, 0))?;
|
|
7118
|
+
|
|
6216
7119
|
class.define_method("escape_asterisks", method!(ConversionOptions::escape_asterisks, 0))?;
|
|
7120
|
+
|
|
6217
7121
|
class.define_method("escape_underscores", method!(ConversionOptions::escape_underscores, 0))?;
|
|
7122
|
+
|
|
6218
7123
|
class.define_method("escape_misc", method!(ConversionOptions::escape_misc, 0))?;
|
|
7124
|
+
|
|
6219
7125
|
class.define_method("escape_ascii", method!(ConversionOptions::escape_ascii, 0))?;
|
|
7126
|
+
|
|
6220
7127
|
class.define_method("code_language", method!(ConversionOptions::code_language, 0))?;
|
|
7128
|
+
|
|
6221
7129
|
class.define_method("autolinks", method!(ConversionOptions::autolinks, 0))?;
|
|
7130
|
+
|
|
6222
7131
|
class.define_method("default_title", method!(ConversionOptions::default_title, 0))?;
|
|
7132
|
+
|
|
6223
7133
|
class.define_method("br_in_tables", method!(ConversionOptions::br_in_tables, 0))?;
|
|
7134
|
+
|
|
7135
|
+
class.define_method("compact_tables", method!(ConversionOptions::compact_tables, 0))?;
|
|
7136
|
+
|
|
6224
7137
|
class.define_method("highlight_style", method!(ConversionOptions::highlight_style, 0))?;
|
|
7138
|
+
|
|
6225
7139
|
class.define_method("extract_metadata", method!(ConversionOptions::extract_metadata, 0))?;
|
|
7140
|
+
|
|
6226
7141
|
class.define_method("whitespace_mode", method!(ConversionOptions::whitespace_mode, 0))?;
|
|
7142
|
+
|
|
6227
7143
|
class.define_method("strip_newlines", method!(ConversionOptions::strip_newlines, 0))?;
|
|
7144
|
+
|
|
6228
7145
|
class.define_method("wrap", method!(ConversionOptions::wrap, 0))?;
|
|
7146
|
+
|
|
6229
7147
|
class.define_method("wrap_width", method!(ConversionOptions::wrap_width, 0))?;
|
|
7148
|
+
|
|
6230
7149
|
class.define_method("convert_as_inline", method!(ConversionOptions::convert_as_inline, 0))?;
|
|
7150
|
+
|
|
6231
7151
|
class.define_method("sub_symbol", method!(ConversionOptions::sub_symbol, 0))?;
|
|
7152
|
+
|
|
6232
7153
|
class.define_method("sup_symbol", method!(ConversionOptions::sup_symbol, 0))?;
|
|
7154
|
+
|
|
6233
7155
|
class.define_method("newline_style", method!(ConversionOptions::newline_style, 0))?;
|
|
7156
|
+
|
|
6234
7157
|
class.define_method("code_block_style", method!(ConversionOptions::code_block_style, 0))?;
|
|
7158
|
+
|
|
6235
7159
|
class.define_method(
|
|
6236
7160
|
"keep_inline_images_in",
|
|
6237
7161
|
method!(ConversionOptions::keep_inline_images_in, 0),
|
|
6238
7162
|
)?;
|
|
7163
|
+
|
|
6239
7164
|
class.define_method("preprocessing", method!(ConversionOptions::preprocessing, 0))?;
|
|
7165
|
+
|
|
6240
7166
|
class.define_method("encoding", method!(ConversionOptions::encoding, 0))?;
|
|
7167
|
+
|
|
6241
7168
|
class.define_method("debug", method!(ConversionOptions::debug, 0))?;
|
|
7169
|
+
|
|
6242
7170
|
class.define_method("strip_tags", method!(ConversionOptions::strip_tags, 0))?;
|
|
7171
|
+
|
|
6243
7172
|
class.define_method("preserve_tags", method!(ConversionOptions::preserve_tags, 0))?;
|
|
7173
|
+
|
|
6244
7174
|
class.define_method("skip_images", method!(ConversionOptions::skip_images, 0))?;
|
|
7175
|
+
|
|
7176
|
+
class.define_method("url_escape_style", method!(ConversionOptions::url_escape_style, 0))?;
|
|
7177
|
+
|
|
6245
7178
|
class.define_method("link_style", method!(ConversionOptions::link_style, 0))?;
|
|
7179
|
+
|
|
6246
7180
|
class.define_method("output_format", method!(ConversionOptions::output_format, 0))?;
|
|
7181
|
+
|
|
6247
7182
|
class.define_method(
|
|
6248
7183
|
"include_document_structure",
|
|
6249
7184
|
method!(ConversionOptions::include_document_structure, 0),
|
|
6250
7185
|
)?;
|
|
7186
|
+
|
|
6251
7187
|
class.define_method("extract_images", method!(ConversionOptions::extract_images, 0))?;
|
|
7188
|
+
|
|
6252
7189
|
class.define_method("max_image_size", method!(ConversionOptions::max_image_size, 0))?;
|
|
7190
|
+
|
|
6253
7191
|
class.define_method("capture_svg", method!(ConversionOptions::capture_svg, 0))?;
|
|
7192
|
+
|
|
6254
7193
|
class.define_method("infer_dimensions", method!(ConversionOptions::infer_dimensions, 0))?;
|
|
7194
|
+
|
|
6255
7195
|
class.define_method("max_depth", method!(ConversionOptions::max_depth, 0))?;
|
|
7196
|
+
|
|
6256
7197
|
class.define_method("exclude_selectors", method!(ConversionOptions::exclude_selectors, 0))?;
|
|
6257
7198
|
|
|
7199
|
+
class.define_method("tier_strategy", method!(ConversionOptions::tier_strategy, 0))?;
|
|
7200
|
+
|
|
6258
7201
|
let class = module.define_class("ConversionOptionsUpdate", ruby.class_object())?;
|
|
7202
|
+
|
|
6259
7203
|
class.define_singleton_method("new", function!(ConversionOptionsUpdate::new, -1))?;
|
|
7204
|
+
|
|
6260
7205
|
class.define_method("heading_style", method!(ConversionOptionsUpdate::heading_style, 0))?;
|
|
7206
|
+
|
|
6261
7207
|
class.define_method(
|
|
6262
7208
|
"list_indent_type",
|
|
6263
7209
|
method!(ConversionOptionsUpdate::list_indent_type, 0),
|
|
6264
7210
|
)?;
|
|
7211
|
+
|
|
6265
7212
|
class.define_method(
|
|
6266
7213
|
"list_indent_width",
|
|
6267
7214
|
method!(ConversionOptionsUpdate::list_indent_width, 0),
|
|
6268
7215
|
)?;
|
|
7216
|
+
|
|
6269
7217
|
class.define_method("bullets", method!(ConversionOptionsUpdate::bullets, 0))?;
|
|
7218
|
+
|
|
6270
7219
|
class.define_method(
|
|
6271
7220
|
"strong_em_symbol",
|
|
6272
7221
|
method!(ConversionOptionsUpdate::strong_em_symbol, 0),
|
|
6273
7222
|
)?;
|
|
7223
|
+
|
|
6274
7224
|
class.define_method(
|
|
6275
7225
|
"escape_asterisks",
|
|
6276
7226
|
method!(ConversionOptionsUpdate::escape_asterisks, 0),
|
|
6277
7227
|
)?;
|
|
7228
|
+
|
|
6278
7229
|
class.define_method(
|
|
6279
7230
|
"escape_underscores",
|
|
6280
7231
|
method!(ConversionOptionsUpdate::escape_underscores, 0),
|
|
6281
7232
|
)?;
|
|
7233
|
+
|
|
6282
7234
|
class.define_method("escape_misc", method!(ConversionOptionsUpdate::escape_misc, 0))?;
|
|
7235
|
+
|
|
6283
7236
|
class.define_method("escape_ascii", method!(ConversionOptionsUpdate::escape_ascii, 0))?;
|
|
7237
|
+
|
|
6284
7238
|
class.define_method("code_language", method!(ConversionOptionsUpdate::code_language, 0))?;
|
|
7239
|
+
|
|
6285
7240
|
class.define_method("autolinks", method!(ConversionOptionsUpdate::autolinks, 0))?;
|
|
7241
|
+
|
|
6286
7242
|
class.define_method("default_title", method!(ConversionOptionsUpdate::default_title, 0))?;
|
|
7243
|
+
|
|
6287
7244
|
class.define_method("br_in_tables", method!(ConversionOptionsUpdate::br_in_tables, 0))?;
|
|
7245
|
+
|
|
7246
|
+
class.define_method("compact_tables", method!(ConversionOptionsUpdate::compact_tables, 0))?;
|
|
7247
|
+
|
|
6288
7248
|
class.define_method("highlight_style", method!(ConversionOptionsUpdate::highlight_style, 0))?;
|
|
7249
|
+
|
|
6289
7250
|
class.define_method(
|
|
6290
7251
|
"extract_metadata",
|
|
6291
7252
|
method!(ConversionOptionsUpdate::extract_metadata, 0),
|
|
6292
7253
|
)?;
|
|
7254
|
+
|
|
6293
7255
|
class.define_method("whitespace_mode", method!(ConversionOptionsUpdate::whitespace_mode, 0))?;
|
|
7256
|
+
|
|
6294
7257
|
class.define_method("strip_newlines", method!(ConversionOptionsUpdate::strip_newlines, 0))?;
|
|
7258
|
+
|
|
6295
7259
|
class.define_method("wrap", method!(ConversionOptionsUpdate::wrap, 0))?;
|
|
7260
|
+
|
|
6296
7261
|
class.define_method("wrap_width", method!(ConversionOptionsUpdate::wrap_width, 0))?;
|
|
7262
|
+
|
|
6297
7263
|
class.define_method(
|
|
6298
7264
|
"convert_as_inline",
|
|
6299
7265
|
method!(ConversionOptionsUpdate::convert_as_inline, 0),
|
|
6300
7266
|
)?;
|
|
7267
|
+
|
|
6301
7268
|
class.define_method("sub_symbol", method!(ConversionOptionsUpdate::sub_symbol, 0))?;
|
|
7269
|
+
|
|
6302
7270
|
class.define_method("sup_symbol", method!(ConversionOptionsUpdate::sup_symbol, 0))?;
|
|
7271
|
+
|
|
6303
7272
|
class.define_method("newline_style", method!(ConversionOptionsUpdate::newline_style, 0))?;
|
|
7273
|
+
|
|
6304
7274
|
class.define_method(
|
|
6305
7275
|
"code_block_style",
|
|
6306
7276
|
method!(ConversionOptionsUpdate::code_block_style, 0),
|
|
6307
7277
|
)?;
|
|
7278
|
+
|
|
6308
7279
|
class.define_method(
|
|
6309
7280
|
"keep_inline_images_in",
|
|
6310
7281
|
method!(ConversionOptionsUpdate::keep_inline_images_in, 0),
|
|
6311
7282
|
)?;
|
|
7283
|
+
|
|
6312
7284
|
class.define_method("preprocessing", method!(ConversionOptionsUpdate::preprocessing, 0))?;
|
|
7285
|
+
|
|
6313
7286
|
class.define_method("encoding", method!(ConversionOptionsUpdate::encoding, 0))?;
|
|
7287
|
+
|
|
6314
7288
|
class.define_method("debug", method!(ConversionOptionsUpdate::debug, 0))?;
|
|
7289
|
+
|
|
6315
7290
|
class.define_method("strip_tags", method!(ConversionOptionsUpdate::strip_tags, 0))?;
|
|
7291
|
+
|
|
6316
7292
|
class.define_method("preserve_tags", method!(ConversionOptionsUpdate::preserve_tags, 0))?;
|
|
7293
|
+
|
|
6317
7294
|
class.define_method("skip_images", method!(ConversionOptionsUpdate::skip_images, 0))?;
|
|
7295
|
+
|
|
7296
|
+
class.define_method(
|
|
7297
|
+
"url_escape_style",
|
|
7298
|
+
method!(ConversionOptionsUpdate::url_escape_style, 0),
|
|
7299
|
+
)?;
|
|
7300
|
+
|
|
6318
7301
|
class.define_method("link_style", method!(ConversionOptionsUpdate::link_style, 0))?;
|
|
7302
|
+
|
|
6319
7303
|
class.define_method("output_format", method!(ConversionOptionsUpdate::output_format, 0))?;
|
|
7304
|
+
|
|
6320
7305
|
class.define_method(
|
|
6321
7306
|
"include_document_structure",
|
|
6322
7307
|
method!(ConversionOptionsUpdate::include_document_structure, 0),
|
|
6323
7308
|
)?;
|
|
7309
|
+
|
|
6324
7310
|
class.define_method("extract_images", method!(ConversionOptionsUpdate::extract_images, 0))?;
|
|
7311
|
+
|
|
6325
7312
|
class.define_method("max_image_size", method!(ConversionOptionsUpdate::max_image_size, 0))?;
|
|
7313
|
+
|
|
6326
7314
|
class.define_method("capture_svg", method!(ConversionOptionsUpdate::capture_svg, 0))?;
|
|
7315
|
+
|
|
6327
7316
|
class.define_method(
|
|
6328
7317
|
"infer_dimensions",
|
|
6329
7318
|
method!(ConversionOptionsUpdate::infer_dimensions, 0),
|
|
6330
7319
|
)?;
|
|
7320
|
+
|
|
6331
7321
|
class.define_method("max_depth", method!(ConversionOptionsUpdate::max_depth, 0))?;
|
|
7322
|
+
|
|
6332
7323
|
class.define_method(
|
|
6333
7324
|
"exclude_selectors",
|
|
6334
7325
|
method!(ConversionOptionsUpdate::exclude_selectors, 0),
|
|
6335
7326
|
)?;
|
|
6336
7327
|
|
|
7328
|
+
class.define_method("tier_strategy", method!(ConversionOptionsUpdate::tier_strategy, 0))?;
|
|
7329
|
+
|
|
6337
7330
|
let class = module.define_class("PreprocessingOptions", ruby.class_object())?;
|
|
7331
|
+
|
|
6338
7332
|
class.define_singleton_method("new", function!(PreprocessingOptions::new, -1))?;
|
|
7333
|
+
|
|
6339
7334
|
class.define_method("enabled", method!(PreprocessingOptions::enabled, 0))?;
|
|
7335
|
+
|
|
6340
7336
|
class.define_method("preset", method!(PreprocessingOptions::preset, 0))?;
|
|
7337
|
+
|
|
6341
7338
|
class.define_method("remove_navigation", method!(PreprocessingOptions::remove_navigation, 0))?;
|
|
7339
|
+
|
|
6342
7340
|
class.define_method("remove_forms", method!(PreprocessingOptions::remove_forms, 0))?;
|
|
6343
7341
|
|
|
6344
7342
|
let class = module.define_class("PreprocessingOptionsUpdate", ruby.class_object())?;
|
|
7343
|
+
|
|
6345
7344
|
class.define_singleton_method("new", function!(PreprocessingOptionsUpdate::new, -1))?;
|
|
7345
|
+
|
|
6346
7346
|
class.define_method("enabled", method!(PreprocessingOptionsUpdate::enabled, 0))?;
|
|
7347
|
+
|
|
6347
7348
|
class.define_method("preset", method!(PreprocessingOptionsUpdate::preset, 0))?;
|
|
7349
|
+
|
|
6348
7350
|
class.define_method(
|
|
6349
7351
|
"remove_navigation",
|
|
6350
7352
|
method!(PreprocessingOptionsUpdate::remove_navigation, 0),
|
|
6351
7353
|
)?;
|
|
7354
|
+
|
|
6352
7355
|
class.define_method("remove_forms", method!(PreprocessingOptionsUpdate::remove_forms, 0))?;
|
|
6353
7356
|
|
|
7357
|
+
let class = module.define_class("ImageDimensions", ruby.class_object())?;
|
|
7358
|
+
|
|
7359
|
+
class.define_singleton_method("new", function!(ImageDimensions::new, -1))?;
|
|
7360
|
+
|
|
7361
|
+
class.define_method("width", method!(ImageDimensions::width, 0))?;
|
|
7362
|
+
|
|
7363
|
+
class.define_method("height", method!(ImageDimensions::height, 0))?;
|
|
7364
|
+
|
|
6354
7365
|
let class = module.define_class("DocumentStructure", ruby.class_object())?;
|
|
7366
|
+
|
|
6355
7367
|
class.define_singleton_method("new", function!(DocumentStructure::new, -1))?;
|
|
7368
|
+
|
|
6356
7369
|
class.define_method("nodes", method!(DocumentStructure::nodes, 0))?;
|
|
7370
|
+
|
|
6357
7371
|
class.define_method("source_format", method!(DocumentStructure::source_format, 0))?;
|
|
6358
7372
|
|
|
6359
7373
|
let class = module.define_class("DocumentNode", ruby.class_object())?;
|
|
7374
|
+
|
|
6360
7375
|
class.define_singleton_method("new", function!(DocumentNode::new, -1))?;
|
|
7376
|
+
|
|
6361
7377
|
class.define_method("id", method!(DocumentNode::id, 0))?;
|
|
7378
|
+
|
|
6362
7379
|
class.define_method("content", method!(DocumentNode::content, 0))?;
|
|
7380
|
+
|
|
6363
7381
|
class.define_method("parent", method!(DocumentNode::parent, 0))?;
|
|
7382
|
+
|
|
6364
7383
|
class.define_method("children", method!(DocumentNode::children, 0))?;
|
|
7384
|
+
|
|
6365
7385
|
class.define_method("annotations", method!(DocumentNode::annotations, 0))?;
|
|
7386
|
+
|
|
6366
7387
|
class.define_method("attributes", method!(DocumentNode::attributes, 0))?;
|
|
6367
7388
|
|
|
6368
7389
|
let class = module.define_class("TextAnnotation", ruby.class_object())?;
|
|
7390
|
+
|
|
6369
7391
|
class.define_singleton_method("new", function!(TextAnnotation::new, -1))?;
|
|
7392
|
+
|
|
6370
7393
|
class.define_method("start", method!(TextAnnotation::start, 0))?;
|
|
7394
|
+
|
|
6371
7395
|
class.define_method("end", method!(TextAnnotation::end, 0))?;
|
|
7396
|
+
|
|
6372
7397
|
class.define_method("kind", method!(TextAnnotation::kind, 0))?;
|
|
6373
7398
|
|
|
7399
|
+
let class = module.define_class("MetadataEntry", ruby.class_object())?;
|
|
7400
|
+
|
|
7401
|
+
class.define_singleton_method("new", function!(MetadataEntry::new, -1))?;
|
|
7402
|
+
|
|
7403
|
+
class.define_method("key", method!(MetadataEntry::key, 0))?;
|
|
7404
|
+
|
|
7405
|
+
class.define_method("value", method!(MetadataEntry::value, 0))?;
|
|
7406
|
+
|
|
6374
7407
|
let class = module.define_class("ConversionResult", ruby.class_object())?;
|
|
7408
|
+
|
|
6375
7409
|
class.define_singleton_method("new", function!(ConversionResult::new, -1))?;
|
|
7410
|
+
|
|
6376
7411
|
class.define_method("content", method!(ConversionResult::content, 0))?;
|
|
7412
|
+
|
|
6377
7413
|
class.define_method("document", method!(ConversionResult::document, 0))?;
|
|
7414
|
+
|
|
6378
7415
|
class.define_method("metadata", method!(ConversionResult::metadata, 0))?;
|
|
7416
|
+
|
|
6379
7417
|
class.define_method("tables", method!(ConversionResult::tables, 0))?;
|
|
6380
|
-
|
|
7418
|
+
|
|
6381
7419
|
class.define_method("warnings", method!(ConversionResult::warnings, 0))?;
|
|
7420
|
+
|
|
6382
7421
|
class.define_method("to_s", method!(ConversionResult::to_s, 0))?;
|
|
6383
7422
|
|
|
6384
7423
|
let class = module.define_class("TableGrid", ruby.class_object())?;
|
|
7424
|
+
|
|
6385
7425
|
class.define_singleton_method("new", function!(TableGrid::new, -1))?;
|
|
7426
|
+
|
|
6386
7427
|
class.define_method("rows", method!(TableGrid::rows, 0))?;
|
|
7428
|
+
|
|
6387
7429
|
class.define_method("cols", method!(TableGrid::cols, 0))?;
|
|
7430
|
+
|
|
6388
7431
|
class.define_method("cells", method!(TableGrid::cells, 0))?;
|
|
6389
7432
|
|
|
6390
7433
|
let class = module.define_class("GridCell", ruby.class_object())?;
|
|
7434
|
+
|
|
6391
7435
|
class.define_singleton_method("new", function!(GridCell::new, -1))?;
|
|
7436
|
+
|
|
6392
7437
|
class.define_method("content", method!(GridCell::content, 0))?;
|
|
7438
|
+
|
|
6393
7439
|
class.define_method("row", method!(GridCell::row, 0))?;
|
|
7440
|
+
|
|
6394
7441
|
class.define_method("col", method!(GridCell::col, 0))?;
|
|
7442
|
+
|
|
6395
7443
|
class.define_method("row_span", method!(GridCell::row_span, 0))?;
|
|
7444
|
+
|
|
6396
7445
|
class.define_method("col_span", method!(GridCell::col_span, 0))?;
|
|
7446
|
+
|
|
6397
7447
|
class.define_method("is_header", method!(GridCell::is_header, 0))?;
|
|
7448
|
+
|
|
6398
7449
|
class.define_method("to_s", method!(GridCell::to_s, 0))?;
|
|
6399
7450
|
|
|
6400
7451
|
let class = module.define_class("TableData", ruby.class_object())?;
|
|
7452
|
+
|
|
6401
7453
|
class.define_singleton_method("new", function!(TableData::new, -1))?;
|
|
7454
|
+
|
|
6402
7455
|
class.define_method("grid", method!(TableData::grid, 0))?;
|
|
7456
|
+
|
|
6403
7457
|
class.define_method("markdown", method!(TableData::markdown, 0))?;
|
|
6404
7458
|
|
|
6405
7459
|
let class = module.define_class("ProcessingWarning", ruby.class_object())?;
|
|
7460
|
+
|
|
6406
7461
|
class.define_singleton_method("new", function!(ProcessingWarning::new, -1))?;
|
|
7462
|
+
|
|
6407
7463
|
class.define_method("message", method!(ProcessingWarning::message, 0))?;
|
|
7464
|
+
|
|
6408
7465
|
class.define_method("kind", method!(ProcessingWarning::kind, 0))?;
|
|
6409
7466
|
|
|
7467
|
+
let class = module.define_class("VisitorHandle", ruby.class_object())?;
|
|
7468
|
+
|
|
6410
7469
|
let class = module.define_class("NodeContext", ruby.class_object())?;
|
|
7470
|
+
|
|
6411
7471
|
class.define_singleton_method("new", function!(NodeContext::new, -1))?;
|
|
7472
|
+
|
|
6412
7473
|
class.define_method("node_type", method!(NodeContext::node_type, 0))?;
|
|
7474
|
+
|
|
6413
7475
|
class.define_method("tag_name", method!(NodeContext::tag_name, 0))?;
|
|
6414
|
-
|
|
7476
|
+
|
|
6415
7477
|
class.define_method("depth", method!(NodeContext::depth, 0))?;
|
|
7478
|
+
|
|
6416
7479
|
class.define_method("index_in_parent", method!(NodeContext::index_in_parent, 0))?;
|
|
7480
|
+
|
|
6417
7481
|
class.define_method("parent_tag", method!(NodeContext::parent_tag, 0))?;
|
|
7482
|
+
|
|
6418
7483
|
class.define_method("is_inline", method!(NodeContext::is_inline, 0))?;
|
|
6419
7484
|
|
|
7485
|
+
class.define_method("attributes", method!(NodeContext::attributes, 0))?;
|
|
7486
|
+
|
|
7487
|
+
class.define_method("into_owned", method!(NodeContext::into_owned, 0))?;
|
|
7488
|
+
|
|
6420
7489
|
module.define_module_function("convert", function!(convert, -1))?;
|
|
6421
7490
|
|
|
6422
7491
|
Ok(())
|