html-to-markdown 3.2.3 → 3.4.0.pre.rc.13
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/Steepfile +6 -0
- data/ext/html_to_markdown_rb/Cargo.toml +2 -2
- data/ext/html_to_markdown_rb/native/Cargo.toml +28 -0
- data/ext/html_to_markdown_rb/src/html-to-markdown/version.rb +10 -0
- data/ext/html_to_markdown_rb/src/html-to-markdown.rb +13 -0
- data/ext/html_to_markdown_rb/src/lib.rs +2088 -268
- data/lib/bin/html-to-markdown +0 -0
- data/lib/html_to_markdown/version.rb +1 -1
- data/lib/html_to_markdown.rb +5 -3
- data/sig/types.rbs +769 -0
- data/vendor/Cargo.toml +2 -2
- data/vendor/html-to-markdown-rs/Cargo.toml +1 -1
- data/vendor/html-to-markdown-rs/examples/basic.rs +1 -1
- data/vendor/html-to-markdown-rs/examples/table.rs +1 -1
- data/vendor/html-to-markdown-rs/examples/test_deser.rs +1 -1
- data/vendor/html-to-markdown-rs/examples/test_escape.rs +1 -1
- data/vendor/html-to-markdown-rs/examples/test_inline_formatting.rs +1 -1
- data/vendor/html-to-markdown-rs/examples/test_lists.rs +1 -1
- data/vendor/html-to-markdown-rs/examples/test_semantic_tags.rs +1 -1
- data/vendor/html-to-markdown-rs/examples/test_tables.rs +1 -1
- data/vendor/html-to-markdown-rs/examples/test_task_lists.rs +1 -1
- data/vendor/html-to-markdown-rs/examples/test_whitespace.rs +1 -1
- data/vendor/html-to-markdown-rs/src/convert_api.rs +15 -25
- data/vendor/html-to-markdown-rs/src/converter/block/blockquote.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/block/container.rs +3 -3
- data/vendor/html-to-markdown-rs/src/converter/block/div.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/block/heading.rs +6 -7
- data/vendor/html-to-markdown-rs/src/converter/block/horizontal_rule.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/block/line_break.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/block/mod.rs +0 -108
- data/vendor/html-to-markdown-rs/src/converter/block/paragraph.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/block/preformatted.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/block/table/builder.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/block/table/cell.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/block/table/layout.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/block/table/mod.rs +2 -4
- data/vendor/html-to-markdown-rs/src/converter/block/unknown.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/context.rs +10 -0
- data/vendor/html-to-markdown-rs/src/converter/dom_context.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/form/elements.rs +14 -14
- data/vendor/html-to-markdown-rs/src/converter/form/mod.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/format/mod.rs +0 -3
- data/vendor/html-to-markdown-rs/src/converter/inline/code.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/inline/emphasis.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/inline/link.rs +2 -2
- data/vendor/html-to-markdown-rs/src/converter/inline/mod.rs +0 -1
- data/vendor/html-to-markdown-rs/src/converter/inline/ruby.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/inline/semantic/mod.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/list/definition.rs +3 -3
- data/vendor/html-to-markdown-rs/src/converter/list/item.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/list/mod.rs +0 -1
- data/vendor/html-to-markdown-rs/src/converter/list/ordered.rs +2 -2
- data/vendor/html-to-markdown-rs/src/converter/list/unordered.rs +2 -2
- data/vendor/html-to-markdown-rs/src/converter/main.rs +57 -31
- data/vendor/html-to-markdown-rs/src/converter/media/embedded.rs +8 -8
- data/vendor/html-to-markdown-rs/src/converter/media/image.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/media/mod.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/media/svg.rs +5 -5
- data/vendor/html-to-markdown-rs/src/converter/mod.rs +6 -17
- data/vendor/html-to-markdown-rs/src/converter/plain_text.rs +64 -11
- data/vendor/html-to-markdown-rs/src/converter/preprocessing_helpers.rs +80 -22
- data/vendor/html-to-markdown-rs/src/converter/semantic/figure.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/semantic/mod.rs +1 -1
- data/vendor/html-to-markdown-rs/src/converter/text/mod.rs +0 -4
- data/vendor/html-to-markdown-rs/src/converter/utility/attributes.rs +5 -9
- data/vendor/html-to-markdown-rs/src/converter/utility/caching.rs +3 -3
- data/vendor/html-to-markdown-rs/src/converter/utility/content.rs +10 -10
- data/vendor/html-to-markdown-rs/src/converter/utility/preprocessing.rs +13 -13
- data/vendor/html-to-markdown-rs/src/converter/utility/serialization.rs +4 -4
- data/vendor/html-to-markdown-rs/src/converter/utility/siblings.rs +6 -14
- data/vendor/html-to-markdown-rs/src/inline_images.rs +6 -0
- data/vendor/html-to-markdown-rs/src/lib.rs +17 -18
- data/vendor/html-to-markdown-rs/src/options/conversion.rs +31 -0
- data/vendor/html-to-markdown-rs/src/prelude.rs +1 -12
- data/vendor/html-to-markdown-rs/src/text.rs +0 -44
- data/vendor/html-to-markdown-rs/src/types/warnings.rs +2 -0
- data/vendor/html-to-markdown-rs/src/visitor/types.rs +5 -1
- data/vendor/html-to-markdown-rs/src/visitor_helpers.rs +4 -1
- data/vendor/html-to-markdown-rs/tests/br_in_inline_test.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/commonmark_compliance_test.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/djot_output_test.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/exclude_selectors_test.rs +136 -0
- data/vendor/html-to-markdown-rs/tests/integration_test.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_121_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_127_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_128_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_131_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_134_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_139_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_140_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_143_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_145_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_146_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_176_regressions.rs +2 -2
- data/vendor/html-to-markdown-rs/tests/issue_190_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_199_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_200_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_212_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/issue_216_217_regressions.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/json_ld_script_extraction.rs +2 -2
- data/vendor/html-to-markdown-rs/tests/lists_test.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/plain_output_test.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/preprocessing_tests.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/reference_links_test.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/sectioning_elements_test.rs +137 -0
- data/vendor/html-to-markdown-rs/tests/skip_images_test.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/tables_test.rs +2 -2
- data/vendor/html-to-markdown-rs/tests/test_custom_elements.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/test_issue_187.rs +5 -2
- data/vendor/html-to-markdown-rs/tests/test_issue_218.rs +4 -4
- data/vendor/html-to-markdown-rs/tests/test_issue_277.rs +77 -0
- data/vendor/html-to-markdown-rs/tests/test_max_depth.rs +82 -0
- data/vendor/html-to-markdown-rs/tests/test_nested_simple.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/test_script_style_stripping.rs +4 -4
- data/vendor/html-to-markdown-rs/tests/test_spa_bisect.rs +1 -1
- data/vendor/html-to-markdown-rs/tests/visitor_code_integration_test.rs +6 -6
- data/vendor/html-to-markdown-rs/tests/visitor_integration_test.rs +103 -35
- data/vendor/html-to-markdown-rs/tests/xml_tables_test.rs +1 -1
- metadata +21 -43
- data/.bundle/config +0 -2
- data/.gitignore +0 -3
- data/.rubocop.yml +0 -59
- data/Gemfile +0 -18
- data/Gemfile.lock +0 -173
- data/README.md +0 -331
- data/Rakefile +0 -26
- data/exe/html-to-markdown +0 -6
- data/ext/html_to_markdown_rb/src/html_to_markdown_rs/version.rb +0 -6
- data/ext/html_to_markdown_rb/src/html_to_markdown_rs.rb +0 -9
- data/html-to-markdown-rb.gemspec +0 -99
- data/lib/html_to_markdown_rs.rb +0 -3
- data/sig/html_to_markdown.rbs +0 -149
- data/vendor/html-to-markdown-rs/src/converter/text/escaping.rs +0 -94
- data/vendor/html-to-markdown-rs/src/converter/text/normalization.rs +0 -86
- data/vendor/html-to-markdown-rs/src/safety.rs +0 -70
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
// This file is auto-generated by alef. DO NOT EDIT.
|
|
2
|
+
// alef:hash:05410d54dbc3bf180f287036de010a1a0a1160595b540211d172b1cdd9bb6dff
|
|
2
3
|
// Re-generate with: alef generate
|
|
3
|
-
#![allow(dead_code)]
|
|
4
|
+
#![allow(dead_code, unused_imports, unused_variables)]
|
|
5
|
+
#![allow(
|
|
6
|
+
clippy::too_many_arguments,
|
|
7
|
+
clippy::let_unit_value,
|
|
8
|
+
clippy::needless_borrow,
|
|
9
|
+
clippy::map_identity,
|
|
10
|
+
clippy::just_underscores_and_digits,
|
|
11
|
+
clippy::unnecessary_cast,
|
|
12
|
+
clippy::unused_unit,
|
|
13
|
+
clippy::unwrap_or_default,
|
|
14
|
+
clippy::derivable_impls,
|
|
15
|
+
clippy::needless_borrows_for_generic_args,
|
|
16
|
+
clippy::unnecessary_fallible_conversions
|
|
17
|
+
)]
|
|
4
18
|
|
|
5
19
|
use magnus::{Error, IntoValueFromNative, Ruby, function, method, prelude::*, try_convert::TryConvertOwned};
|
|
6
20
|
use std::collections::HashMap;
|
|
@@ -40,176 +54,9 @@ fn json_to_ruby(handle: &Ruby, val: serde_json::Value) -> magnus::Value {
|
|
|
40
54
|
}
|
|
41
55
|
}
|
|
42
56
|
|
|
43
|
-
#[derive(Clone, Debug)]
|
|
44
|
-
#[magnus::wrap(class = "HtmlToMarkdownRs::MetadataConfig")]
|
|
45
|
-
pub struct MetadataConfig {
|
|
46
|
-
pub extract_document: bool,
|
|
47
|
-
pub extract_headers: bool,
|
|
48
|
-
pub extract_links: bool,
|
|
49
|
-
pub extract_images: bool,
|
|
50
|
-
pub extract_structured_data: bool,
|
|
51
|
-
pub max_structured_data_size: usize,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
unsafe impl IntoValueFromNative for MetadataConfig {}
|
|
55
|
-
|
|
56
|
-
impl magnus::TryConvert for MetadataConfig {
|
|
57
|
-
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
58
|
-
let r: &MetadataConfig = magnus::TryConvert::try_convert(val)?;
|
|
59
|
-
Ok(r.clone())
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
unsafe impl TryConvertOwned for MetadataConfig {}
|
|
63
|
-
|
|
64
|
-
impl Default for MetadataConfig {
|
|
65
|
-
fn default() -> Self {
|
|
66
|
-
Self {
|
|
67
|
-
extract_document: Default::default(),
|
|
68
|
-
extract_headers: Default::default(),
|
|
69
|
-
extract_links: Default::default(),
|
|
70
|
-
extract_images: Default::default(),
|
|
71
|
-
extract_structured_data: Default::default(),
|
|
72
|
-
max_structured_data_size: Default::default(),
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
impl MetadataConfig {
|
|
78
|
-
fn new(
|
|
79
|
-
extract_document: Option<bool>,
|
|
80
|
-
extract_headers: Option<bool>,
|
|
81
|
-
extract_links: Option<bool>,
|
|
82
|
-
extract_images: Option<bool>,
|
|
83
|
-
extract_structured_data: Option<bool>,
|
|
84
|
-
max_structured_data_size: Option<usize>,
|
|
85
|
-
) -> Self {
|
|
86
|
-
Self {
|
|
87
|
-
extract_document: extract_document.unwrap_or(true),
|
|
88
|
-
extract_headers: extract_headers.unwrap_or(true),
|
|
89
|
-
extract_links: extract_links.unwrap_or(true),
|
|
90
|
-
extract_images: extract_images.unwrap_or(true),
|
|
91
|
-
extract_structured_data: extract_structured_data.unwrap_or(true),
|
|
92
|
-
max_structured_data_size: max_structured_data_size.unwrap_or_default(),
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
fn extract_document(&self) -> bool {
|
|
97
|
-
self.extract_document
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
fn extract_headers(&self) -> bool {
|
|
101
|
-
self.extract_headers
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
fn extract_links(&self) -> bool {
|
|
105
|
-
self.extract_links
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
fn extract_images(&self) -> bool {
|
|
109
|
-
self.extract_images
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
fn extract_structured_data(&self) -> bool {
|
|
113
|
-
self.extract_structured_data
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
fn max_structured_data_size(&self) -> usize {
|
|
117
|
-
self.max_structured_data_size
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
fn any_enabled(&self) -> bool {
|
|
121
|
-
let core_self = html_to_markdown_rs::metadata::MetadataConfig {
|
|
122
|
-
extract_document: self.extract_document,
|
|
123
|
-
extract_headers: self.extract_headers,
|
|
124
|
-
extract_links: self.extract_links,
|
|
125
|
-
extract_images: self.extract_images,
|
|
126
|
-
extract_structured_data: self.extract_structured_data,
|
|
127
|
-
max_structured_data_size: self.max_structured_data_size,
|
|
128
|
-
};
|
|
129
|
-
core_self.any_enabled()
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
#[derive(Clone, Debug)]
|
|
134
|
-
#[magnus::wrap(class = "HtmlToMarkdownRs::MetadataConfigUpdate")]
|
|
135
|
-
pub struct MetadataConfigUpdate {
|
|
136
|
-
pub extract_document: Option<bool>,
|
|
137
|
-
pub extract_headers: Option<bool>,
|
|
138
|
-
pub extract_links: Option<bool>,
|
|
139
|
-
pub extract_images: Option<bool>,
|
|
140
|
-
pub extract_structured_data: Option<bool>,
|
|
141
|
-
pub max_structured_data_size: Option<usize>,
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
unsafe impl IntoValueFromNative for MetadataConfigUpdate {}
|
|
145
|
-
|
|
146
|
-
impl magnus::TryConvert for MetadataConfigUpdate {
|
|
147
|
-
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
148
|
-
let r: &MetadataConfigUpdate = magnus::TryConvert::try_convert(val)?;
|
|
149
|
-
Ok(r.clone())
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
unsafe impl TryConvertOwned for MetadataConfigUpdate {}
|
|
153
|
-
|
|
154
|
-
impl Default for MetadataConfigUpdate {
|
|
155
|
-
fn default() -> Self {
|
|
156
|
-
Self {
|
|
157
|
-
extract_document: Default::default(),
|
|
158
|
-
extract_headers: Default::default(),
|
|
159
|
-
extract_links: Default::default(),
|
|
160
|
-
extract_images: Default::default(),
|
|
161
|
-
extract_structured_data: Default::default(),
|
|
162
|
-
max_structured_data_size: Default::default(),
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
impl MetadataConfigUpdate {
|
|
168
|
-
fn new(
|
|
169
|
-
extract_document: Option<bool>,
|
|
170
|
-
extract_headers: Option<bool>,
|
|
171
|
-
extract_links: Option<bool>,
|
|
172
|
-
extract_images: Option<bool>,
|
|
173
|
-
extract_structured_data: Option<bool>,
|
|
174
|
-
max_structured_data_size: Option<usize>,
|
|
175
|
-
) -> Self {
|
|
176
|
-
Self {
|
|
177
|
-
extract_document,
|
|
178
|
-
extract_headers,
|
|
179
|
-
extract_links,
|
|
180
|
-
extract_images,
|
|
181
|
-
extract_structured_data,
|
|
182
|
-
max_structured_data_size,
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
fn extract_document(&self) -> Option<bool> {
|
|
187
|
-
self.extract_document
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
fn extract_headers(&self) -> Option<bool> {
|
|
191
|
-
self.extract_headers
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
fn extract_links(&self) -> Option<bool> {
|
|
195
|
-
self.extract_links
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
fn extract_images(&self) -> Option<bool> {
|
|
199
|
-
self.extract_images
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
fn extract_structured_data(&self) -> Option<bool> {
|
|
203
|
-
self.extract_structured_data
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
fn max_structured_data_size(&self) -> Option<usize> {
|
|
207
|
-
self.max_structured_data_size
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
#[derive(Clone, Debug, Default)]
|
|
57
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
212
58
|
#[magnus::wrap(class = "HtmlToMarkdownRs::DocumentMetadata")]
|
|
59
|
+
#[serde(default)]
|
|
213
60
|
pub struct DocumentMetadata {
|
|
214
61
|
pub title: Option<String>,
|
|
215
62
|
pub description: Option<String>,
|
|
@@ -308,7 +155,7 @@ impl DocumentMetadata {
|
|
|
308
155
|
}
|
|
309
156
|
}
|
|
310
157
|
|
|
311
|
-
#[derive(Clone, Debug)]
|
|
158
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
312
159
|
#[magnus::wrap(class = "HtmlToMarkdownRs::HeaderMetadata")]
|
|
313
160
|
pub struct HeaderMetadata {
|
|
314
161
|
pub level: u8,
|
|
@@ -371,7 +218,7 @@ impl HeaderMetadata {
|
|
|
371
218
|
}
|
|
372
219
|
}
|
|
373
220
|
|
|
374
|
-
#[derive(Clone, Debug)]
|
|
221
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
375
222
|
#[magnus::wrap(class = "HtmlToMarkdownRs::LinkMetadata")]
|
|
376
223
|
pub struct LinkMetadata {
|
|
377
224
|
pub href: String,
|
|
@@ -436,13 +283,13 @@ impl LinkMetadata {
|
|
|
436
283
|
}
|
|
437
284
|
}
|
|
438
285
|
|
|
439
|
-
#[derive(Clone, Debug)]
|
|
286
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
440
287
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ImageMetadata")]
|
|
441
288
|
pub struct ImageMetadata {
|
|
442
289
|
pub src: String,
|
|
443
290
|
pub alt: Option<String>,
|
|
444
291
|
pub title: Option<String>,
|
|
445
|
-
pub dimensions: Option<
|
|
292
|
+
pub dimensions: Option<Vec<u32>>,
|
|
446
293
|
pub image_type: ImageType,
|
|
447
294
|
pub attributes: HashMap<String, String>,
|
|
448
295
|
}
|
|
@@ -464,7 +311,7 @@ impl ImageMetadata {
|
|
|
464
311
|
attributes: HashMap<String, String>,
|
|
465
312
|
alt: Option<String>,
|
|
466
313
|
title: Option<String>,
|
|
467
|
-
dimensions: Option<
|
|
314
|
+
dimensions: Option<Vec<u32>>,
|
|
468
315
|
) -> Self {
|
|
469
316
|
Self {
|
|
470
317
|
src,
|
|
@@ -488,7 +335,7 @@ impl ImageMetadata {
|
|
|
488
335
|
self.title.clone()
|
|
489
336
|
}
|
|
490
337
|
|
|
491
|
-
fn dimensions(&self) -> Option<
|
|
338
|
+
fn dimensions(&self) -> Option<Vec<u32>> {
|
|
492
339
|
self.dimensions.clone()
|
|
493
340
|
}
|
|
494
341
|
|
|
@@ -501,7 +348,7 @@ impl ImageMetadata {
|
|
|
501
348
|
}
|
|
502
349
|
}
|
|
503
350
|
|
|
504
|
-
#[derive(Clone, Debug)]
|
|
351
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
505
352
|
#[magnus::wrap(class = "HtmlToMarkdownRs::StructuredData")]
|
|
506
353
|
pub struct StructuredData {
|
|
507
354
|
pub data_type: StructuredDataType,
|
|
@@ -541,8 +388,9 @@ impl StructuredData {
|
|
|
541
388
|
}
|
|
542
389
|
}
|
|
543
390
|
|
|
544
|
-
#[derive(Clone, Debug, Default)]
|
|
391
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
545
392
|
#[magnus::wrap(class = "HtmlToMarkdownRs::HtmlMetadata")]
|
|
393
|
+
#[serde(default)]
|
|
546
394
|
pub struct HtmlMetadata {
|
|
547
395
|
pub document: DocumentMetadata,
|
|
548
396
|
pub headers: Vec<HeaderMetadata>,
|
|
@@ -599,8 +447,9 @@ impl HtmlMetadata {
|
|
|
599
447
|
}
|
|
600
448
|
}
|
|
601
449
|
|
|
602
|
-
#[derive(Clone, Debug, Default)]
|
|
450
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
603
451
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ConversionOptions")]
|
|
452
|
+
#[serde(default)]
|
|
604
453
|
pub struct ConversionOptions {
|
|
605
454
|
pub heading_style: HeadingStyle,
|
|
606
455
|
pub list_indent_type: ListIndentType,
|
|
@@ -640,6 +489,8 @@ pub struct ConversionOptions {
|
|
|
640
489
|
pub max_image_size: u64,
|
|
641
490
|
pub capture_svg: bool,
|
|
642
491
|
pub infer_dimensions: bool,
|
|
492
|
+
pub max_depth: Option<usize>,
|
|
493
|
+
pub exclude_selectors: Vec<String>,
|
|
643
494
|
}
|
|
644
495
|
|
|
645
496
|
unsafe impl IntoValueFromNative for ConversionOptions {}
|
|
@@ -808,6 +659,13 @@ impl ConversionOptions {
|
|
|
808
659
|
.get(ruby.to_symbol("infer_dimensions"))
|
|
809
660
|
.and_then(|v| bool::try_convert(v).ok())
|
|
810
661
|
.unwrap_or(true),
|
|
662
|
+
max_depth: kwargs
|
|
663
|
+
.get(ruby.to_symbol("max_depth"))
|
|
664
|
+
.and_then(|v| usize::try_convert(v).ok()),
|
|
665
|
+
exclude_selectors: kwargs
|
|
666
|
+
.get(ruby.to_symbol("exclude_selectors"))
|
|
667
|
+
.and_then(|v| <Vec<String>>::try_convert(v).ok())
|
|
668
|
+
.unwrap_or_default(),
|
|
811
669
|
})
|
|
812
670
|
}
|
|
813
671
|
|
|
@@ -962,6 +820,18 @@ impl ConversionOptions {
|
|
|
962
820
|
fn infer_dimensions(&self) -> bool {
|
|
963
821
|
self.infer_dimensions
|
|
964
822
|
}
|
|
823
|
+
|
|
824
|
+
fn max_depth(&self) -> Option<usize> {
|
|
825
|
+
self.max_depth
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
fn exclude_selectors(&self) -> Vec<String> {
|
|
829
|
+
self.exclude_selectors.clone()
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
fn apply_update(&self, update: ConversionOptionsUpdate) -> () {
|
|
833
|
+
()
|
|
834
|
+
}
|
|
965
835
|
}
|
|
966
836
|
|
|
967
837
|
#[derive(Clone)]
|
|
@@ -999,6 +869,12 @@ impl ConversionOptionsBuilder {
|
|
|
999
869
|
}
|
|
1000
870
|
}
|
|
1001
871
|
|
|
872
|
+
fn exclude_selectors(&self, selectors: Vec<String>) -> ConversionOptionsBuilder {
|
|
873
|
+
Self {
|
|
874
|
+
inner: Arc::new(self.inner.as_ref().clone().exclude_selectors(selectors)),
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
1002
878
|
fn preprocessing(&self, preprocessing: PreprocessingOptions) -> ConversionOptionsBuilder {
|
|
1003
879
|
Self {
|
|
1004
880
|
inner: Arc::new(self.inner.as_ref().clone().preprocessing(preprocessing.into())),
|
|
@@ -1010,8 +886,9 @@ impl ConversionOptionsBuilder {
|
|
|
1010
886
|
}
|
|
1011
887
|
}
|
|
1012
888
|
|
|
1013
|
-
#[derive(Clone, Debug, Default)]
|
|
889
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1014
890
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ConversionOptionsUpdate")]
|
|
891
|
+
#[serde(default)]
|
|
1015
892
|
pub struct ConversionOptionsUpdate {
|
|
1016
893
|
pub heading_style: Option<HeadingStyle>,
|
|
1017
894
|
pub list_indent_type: Option<ListIndentType>,
|
|
@@ -1051,6 +928,8 @@ pub struct ConversionOptionsUpdate {
|
|
|
1051
928
|
pub max_image_size: Option<u64>,
|
|
1052
929
|
pub capture_svg: Option<bool>,
|
|
1053
930
|
pub infer_dimensions: Option<bool>,
|
|
931
|
+
pub max_depth: Option<usize>,
|
|
932
|
+
pub exclude_selectors: Option<Vec<String>>,
|
|
1054
933
|
}
|
|
1055
934
|
|
|
1056
935
|
unsafe impl IntoValueFromNative for ConversionOptionsUpdate {}
|
|
@@ -1181,6 +1060,12 @@ impl ConversionOptionsUpdate {
|
|
|
1181
1060
|
infer_dimensions: kwargs
|
|
1182
1061
|
.get(ruby.to_symbol("infer_dimensions"))
|
|
1183
1062
|
.and_then(|v| bool::try_convert(v).ok()),
|
|
1063
|
+
max_depth: kwargs
|
|
1064
|
+
.get(ruby.to_symbol("max_depth"))
|
|
1065
|
+
.and_then(|v| usize::try_convert(v).ok()),
|
|
1066
|
+
exclude_selectors: kwargs
|
|
1067
|
+
.get(ruby.to_symbol("exclude_selectors"))
|
|
1068
|
+
.and_then(|v| <Vec<String>>::try_convert(v).ok()),
|
|
1184
1069
|
})
|
|
1185
1070
|
}
|
|
1186
1071
|
|
|
@@ -1335,10 +1220,19 @@ impl ConversionOptionsUpdate {
|
|
|
1335
1220
|
fn infer_dimensions(&self) -> Option<bool> {
|
|
1336
1221
|
self.infer_dimensions
|
|
1337
1222
|
}
|
|
1223
|
+
|
|
1224
|
+
fn max_depth(&self) -> Option<usize> {
|
|
1225
|
+
self.max_depth.clone()
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
fn exclude_selectors(&self) -> Option<Vec<String>> {
|
|
1229
|
+
self.exclude_selectors.clone()
|
|
1230
|
+
}
|
|
1338
1231
|
}
|
|
1339
1232
|
|
|
1340
|
-
#[derive(Clone, Debug, Default)]
|
|
1233
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1341
1234
|
#[magnus::wrap(class = "HtmlToMarkdownRs::PreprocessingOptions")]
|
|
1235
|
+
#[serde(default)]
|
|
1342
1236
|
pub struct PreprocessingOptions {
|
|
1343
1237
|
pub enabled: bool,
|
|
1344
1238
|
pub preset: PreprocessingPreset,
|
|
@@ -1386,10 +1280,15 @@ impl PreprocessingOptions {
|
|
|
1386
1280
|
fn remove_forms(&self) -> bool {
|
|
1387
1281
|
self.remove_forms
|
|
1388
1282
|
}
|
|
1283
|
+
|
|
1284
|
+
fn apply_update(&self, update: PreprocessingOptionsUpdate) -> () {
|
|
1285
|
+
()
|
|
1286
|
+
}
|
|
1389
1287
|
}
|
|
1390
1288
|
|
|
1391
|
-
#[derive(Clone, Debug, Default)]
|
|
1289
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1392
1290
|
#[magnus::wrap(class = "HtmlToMarkdownRs::PreprocessingOptionsUpdate")]
|
|
1291
|
+
#[serde(default)]
|
|
1393
1292
|
pub struct PreprocessingOptionsUpdate {
|
|
1394
1293
|
pub enabled: Option<bool>,
|
|
1395
1294
|
pub preset: Option<PreprocessingPreset>,
|
|
@@ -1439,7 +1338,7 @@ impl PreprocessingOptionsUpdate {
|
|
|
1439
1338
|
}
|
|
1440
1339
|
}
|
|
1441
1340
|
|
|
1442
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1341
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1443
1342
|
#[magnus::wrap(class = "HtmlToMarkdownRs::DocumentStructure")]
|
|
1444
1343
|
pub struct DocumentStructure {
|
|
1445
1344
|
pub nodes: Vec<DocumentNode>,
|
|
@@ -1470,7 +1369,7 @@ impl DocumentStructure {
|
|
|
1470
1369
|
}
|
|
1471
1370
|
}
|
|
1472
1371
|
|
|
1473
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1372
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1474
1373
|
#[magnus::wrap(class = "HtmlToMarkdownRs::DocumentNode")]
|
|
1475
1374
|
pub struct DocumentNode {
|
|
1476
1375
|
pub id: String,
|
|
@@ -1535,7 +1434,7 @@ impl DocumentNode {
|
|
|
1535
1434
|
}
|
|
1536
1435
|
}
|
|
1537
1436
|
|
|
1538
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1437
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1539
1438
|
#[magnus::wrap(class = "HtmlToMarkdownRs::TextAnnotation")]
|
|
1540
1439
|
pub struct TextAnnotation {
|
|
1541
1440
|
pub start: u32,
|
|
@@ -1571,8 +1470,9 @@ impl TextAnnotation {
|
|
|
1571
1470
|
}
|
|
1572
1471
|
}
|
|
1573
1472
|
|
|
1574
|
-
#[derive(Clone, Debug, Default)]
|
|
1473
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1575
1474
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ConversionResult")]
|
|
1475
|
+
#[serde(default)]
|
|
1576
1476
|
pub struct ConversionResult {
|
|
1577
1477
|
pub content: Option<String>,
|
|
1578
1478
|
pub document: Option<DocumentStructure>,
|
|
@@ -1636,7 +1536,7 @@ impl ConversionResult {
|
|
|
1636
1536
|
}
|
|
1637
1537
|
}
|
|
1638
1538
|
|
|
1639
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize
|
|
1539
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1640
1540
|
#[magnus::wrap(class = "HtmlToMarkdownRs::TableGrid")]
|
|
1641
1541
|
#[serde(default)]
|
|
1642
1542
|
pub struct TableGrid {
|
|
@@ -1677,7 +1577,7 @@ impl TableGrid {
|
|
|
1677
1577
|
}
|
|
1678
1578
|
}
|
|
1679
1579
|
|
|
1680
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1580
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1681
1581
|
#[magnus::wrap(class = "HtmlToMarkdownRs::GridCell")]
|
|
1682
1582
|
pub struct GridCell {
|
|
1683
1583
|
pub content: String,
|
|
@@ -1735,7 +1635,7 @@ impl GridCell {
|
|
|
1735
1635
|
}
|
|
1736
1636
|
}
|
|
1737
1637
|
|
|
1738
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1638
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1739
1639
|
#[magnus::wrap(class = "HtmlToMarkdownRs::TableData")]
|
|
1740
1640
|
pub struct TableData {
|
|
1741
1641
|
pub grid: TableGrid,
|
|
@@ -1766,7 +1666,7 @@ impl TableData {
|
|
|
1766
1666
|
}
|
|
1767
1667
|
}
|
|
1768
1668
|
|
|
1769
|
-
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
1669
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1770
1670
|
#[magnus::wrap(class = "HtmlToMarkdownRs::ProcessingWarning")]
|
|
1771
1671
|
pub struct ProcessingWarning {
|
|
1772
1672
|
pub message: String,
|
|
@@ -1797,6 +1697,78 @@ impl ProcessingWarning {
|
|
|
1797
1697
|
}
|
|
1798
1698
|
}
|
|
1799
1699
|
|
|
1700
|
+
#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
|
|
1701
|
+
#[magnus::wrap(class = "HtmlToMarkdownRs::NodeContext")]
|
|
1702
|
+
pub struct NodeContext {
|
|
1703
|
+
pub node_type: NodeType,
|
|
1704
|
+
pub tag_name: String,
|
|
1705
|
+
pub attributes: HashMap<String, String>,
|
|
1706
|
+
pub depth: usize,
|
|
1707
|
+
pub index_in_parent: usize,
|
|
1708
|
+
pub parent_tag: Option<String>,
|
|
1709
|
+
pub is_inline: bool,
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
unsafe impl IntoValueFromNative for NodeContext {}
|
|
1713
|
+
|
|
1714
|
+
impl magnus::TryConvert for NodeContext {
|
|
1715
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
1716
|
+
let r: &NodeContext = magnus::TryConvert::try_convert(val)?;
|
|
1717
|
+
Ok(r.clone())
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
unsafe impl TryConvertOwned for NodeContext {}
|
|
1721
|
+
|
|
1722
|
+
impl NodeContext {
|
|
1723
|
+
fn new(
|
|
1724
|
+
node_type: NodeType,
|
|
1725
|
+
tag_name: String,
|
|
1726
|
+
attributes: HashMap<String, String>,
|
|
1727
|
+
depth: usize,
|
|
1728
|
+
index_in_parent: usize,
|
|
1729
|
+
is_inline: bool,
|
|
1730
|
+
parent_tag: Option<String>,
|
|
1731
|
+
) -> Self {
|
|
1732
|
+
Self {
|
|
1733
|
+
node_type,
|
|
1734
|
+
tag_name,
|
|
1735
|
+
attributes,
|
|
1736
|
+
depth,
|
|
1737
|
+
index_in_parent,
|
|
1738
|
+
parent_tag,
|
|
1739
|
+
is_inline,
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
fn node_type(&self) -> NodeType {
|
|
1744
|
+
self.node_type.clone()
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
fn tag_name(&self) -> String {
|
|
1748
|
+
self.tag_name.clone()
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
fn attributes(&self) -> HashMap<String, String> {
|
|
1752
|
+
self.attributes.clone()
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
fn depth(&self) -> usize {
|
|
1756
|
+
self.depth
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
fn index_in_parent(&self) -> usize {
|
|
1760
|
+
self.index_in_parent
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
fn parent_tag(&self) -> Option<String> {
|
|
1764
|
+
self.parent_tag.clone()
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
fn is_inline(&self) -> bool {
|
|
1768
|
+
self.is_inline
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1800
1772
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
1801
1773
|
pub enum TextDirection {
|
|
1802
1774
|
#[serde(rename = "ltr")]
|
|
@@ -2390,7 +2362,7 @@ pub enum NodeContent {
|
|
|
2390
2362
|
content: String,
|
|
2391
2363
|
},
|
|
2392
2364
|
MetadataBlock {
|
|
2393
|
-
entries: String
|
|
2365
|
+
entries: Vec<String>,
|
|
2394
2366
|
},
|
|
2395
2367
|
Group {
|
|
2396
2368
|
label: Option<String>,
|
|
@@ -2475,6 +2447,7 @@ pub enum WarningKind {
|
|
|
2475
2447
|
TruncatedInput,
|
|
2476
2448
|
MalformedHtml,
|
|
2477
2449
|
SanitizationApplied,
|
|
2450
|
+
DepthLimitExceeded,
|
|
2478
2451
|
}
|
|
2479
2452
|
|
|
2480
2453
|
impl Default for WarningKind {
|
|
@@ -2491,6 +2464,7 @@ impl magnus::IntoValue for WarningKind {
|
|
|
2491
2464
|
WarningKind::TruncatedInput => "truncated_input",
|
|
2492
2465
|
WarningKind::MalformedHtml => "malformed_html",
|
|
2493
2466
|
WarningKind::SanitizationApplied => "sanitization_applied",
|
|
2467
|
+
WarningKind::DepthLimitExceeded => "depth_limit_exceeded",
|
|
2494
2468
|
};
|
|
2495
2469
|
handle.to_symbol(sym).into_value_with(handle)
|
|
2496
2470
|
}
|
|
@@ -2505,6 +2479,7 @@ impl magnus::TryConvert for WarningKind {
|
|
|
2505
2479
|
"truncated_input" => Ok(WarningKind::TruncatedInput),
|
|
2506
2480
|
"malformed_html" => Ok(WarningKind::MalformedHtml),
|
|
2507
2481
|
"sanitization_applied" => Ok(WarningKind::SanitizationApplied),
|
|
2482
|
+
"depth_limit_exceeded" => Ok(WarningKind::DepthLimitExceeded),
|
|
2508
2483
|
other => Err(magnus::Error::new(
|
|
2509
2484
|
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2510
2485
|
format!("invalid WarningKind value: {other}"),
|
|
@@ -2516,65 +2491,1692 @@ impl magnus::TryConvert for WarningKind {
|
|
|
2516
2491
|
unsafe impl IntoValueFromNative for WarningKind {}
|
|
2517
2492
|
unsafe impl TryConvertOwned for WarningKind {}
|
|
2518
2493
|
|
|
2519
|
-
|
|
2520
|
-
|
|
2494
|
+
#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
|
|
2495
|
+
pub enum NodeType {
|
|
2496
|
+
Text,
|
|
2497
|
+
Element,
|
|
2498
|
+
Heading,
|
|
2499
|
+
Paragraph,
|
|
2500
|
+
Div,
|
|
2501
|
+
Blockquote,
|
|
2502
|
+
Pre,
|
|
2503
|
+
Hr,
|
|
2504
|
+
List,
|
|
2505
|
+
ListItem,
|
|
2506
|
+
DefinitionList,
|
|
2507
|
+
DefinitionTerm,
|
|
2508
|
+
DefinitionDescription,
|
|
2509
|
+
Table,
|
|
2510
|
+
TableRow,
|
|
2511
|
+
TableCell,
|
|
2512
|
+
TableHeader,
|
|
2513
|
+
TableBody,
|
|
2514
|
+
TableHead,
|
|
2515
|
+
TableFoot,
|
|
2516
|
+
Link,
|
|
2517
|
+
Image,
|
|
2518
|
+
Strong,
|
|
2519
|
+
Em,
|
|
2520
|
+
Code,
|
|
2521
|
+
Strikethrough,
|
|
2522
|
+
Underline,
|
|
2523
|
+
Subscript,
|
|
2524
|
+
Superscript,
|
|
2525
|
+
Mark,
|
|
2526
|
+
Small,
|
|
2527
|
+
Br,
|
|
2528
|
+
Span,
|
|
2529
|
+
Article,
|
|
2530
|
+
Section,
|
|
2531
|
+
Nav,
|
|
2532
|
+
Aside,
|
|
2533
|
+
Header,
|
|
2534
|
+
Footer,
|
|
2535
|
+
Main,
|
|
2536
|
+
Figure,
|
|
2537
|
+
Figcaption,
|
|
2538
|
+
Time,
|
|
2539
|
+
Details,
|
|
2540
|
+
Summary,
|
|
2541
|
+
Form,
|
|
2542
|
+
Input,
|
|
2543
|
+
Select,
|
|
2544
|
+
Option,
|
|
2545
|
+
Button,
|
|
2546
|
+
Textarea,
|
|
2547
|
+
Label,
|
|
2548
|
+
Fieldset,
|
|
2549
|
+
Legend,
|
|
2550
|
+
Audio,
|
|
2551
|
+
Video,
|
|
2552
|
+
Picture,
|
|
2553
|
+
Source,
|
|
2554
|
+
Iframe,
|
|
2555
|
+
Svg,
|
|
2556
|
+
Canvas,
|
|
2557
|
+
Ruby,
|
|
2558
|
+
Rt,
|
|
2559
|
+
Rp,
|
|
2560
|
+
Abbr,
|
|
2561
|
+
Kbd,
|
|
2562
|
+
Samp,
|
|
2563
|
+
Var,
|
|
2564
|
+
Cite,
|
|
2565
|
+
Q,
|
|
2566
|
+
Del,
|
|
2567
|
+
Ins,
|
|
2568
|
+
Data,
|
|
2569
|
+
Meter,
|
|
2570
|
+
Progress,
|
|
2571
|
+
Output,
|
|
2572
|
+
Template,
|
|
2573
|
+
Slot,
|
|
2574
|
+
Html,
|
|
2575
|
+
Head,
|
|
2576
|
+
Body,
|
|
2577
|
+
Title,
|
|
2578
|
+
Meta,
|
|
2579
|
+
LinkTag,
|
|
2580
|
+
Style,
|
|
2581
|
+
Script,
|
|
2582
|
+
Base,
|
|
2583
|
+
Custom,
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
impl Default for NodeType {
|
|
2587
|
+
fn default() -> Self {
|
|
2588
|
+
Self::Text
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
impl magnus::IntoValue for NodeType {
|
|
2593
|
+
fn into_value_with(self, handle: &Ruby) -> magnus::Value {
|
|
2594
|
+
let sym = match self {
|
|
2595
|
+
NodeType::Text => "text",
|
|
2596
|
+
NodeType::Element => "element",
|
|
2597
|
+
NodeType::Heading => "heading",
|
|
2598
|
+
NodeType::Paragraph => "paragraph",
|
|
2599
|
+
NodeType::Div => "div",
|
|
2600
|
+
NodeType::Blockquote => "blockquote",
|
|
2601
|
+
NodeType::Pre => "pre",
|
|
2602
|
+
NodeType::Hr => "hr",
|
|
2603
|
+
NodeType::List => "list",
|
|
2604
|
+
NodeType::ListItem => "list_item",
|
|
2605
|
+
NodeType::DefinitionList => "definition_list",
|
|
2606
|
+
NodeType::DefinitionTerm => "definition_term",
|
|
2607
|
+
NodeType::DefinitionDescription => "definition_description",
|
|
2608
|
+
NodeType::Table => "table",
|
|
2609
|
+
NodeType::TableRow => "table_row",
|
|
2610
|
+
NodeType::TableCell => "table_cell",
|
|
2611
|
+
NodeType::TableHeader => "table_header",
|
|
2612
|
+
NodeType::TableBody => "table_body",
|
|
2613
|
+
NodeType::TableHead => "table_head",
|
|
2614
|
+
NodeType::TableFoot => "table_foot",
|
|
2615
|
+
NodeType::Link => "link",
|
|
2616
|
+
NodeType::Image => "image",
|
|
2617
|
+
NodeType::Strong => "strong",
|
|
2618
|
+
NodeType::Em => "em",
|
|
2619
|
+
NodeType::Code => "code",
|
|
2620
|
+
NodeType::Strikethrough => "strikethrough",
|
|
2621
|
+
NodeType::Underline => "underline",
|
|
2622
|
+
NodeType::Subscript => "subscript",
|
|
2623
|
+
NodeType::Superscript => "superscript",
|
|
2624
|
+
NodeType::Mark => "mark",
|
|
2625
|
+
NodeType::Small => "small",
|
|
2626
|
+
NodeType::Br => "br",
|
|
2627
|
+
NodeType::Span => "span",
|
|
2628
|
+
NodeType::Article => "article",
|
|
2629
|
+
NodeType::Section => "section",
|
|
2630
|
+
NodeType::Nav => "nav",
|
|
2631
|
+
NodeType::Aside => "aside",
|
|
2632
|
+
NodeType::Header => "header",
|
|
2633
|
+
NodeType::Footer => "footer",
|
|
2634
|
+
NodeType::Main => "main",
|
|
2635
|
+
NodeType::Figure => "figure",
|
|
2636
|
+
NodeType::Figcaption => "figcaption",
|
|
2637
|
+
NodeType::Time => "time",
|
|
2638
|
+
NodeType::Details => "details",
|
|
2639
|
+
NodeType::Summary => "summary",
|
|
2640
|
+
NodeType::Form => "form",
|
|
2641
|
+
NodeType::Input => "input",
|
|
2642
|
+
NodeType::Select => "select",
|
|
2643
|
+
NodeType::Option => "option",
|
|
2644
|
+
NodeType::Button => "button",
|
|
2645
|
+
NodeType::Textarea => "textarea",
|
|
2646
|
+
NodeType::Label => "label",
|
|
2647
|
+
NodeType::Fieldset => "fieldset",
|
|
2648
|
+
NodeType::Legend => "legend",
|
|
2649
|
+
NodeType::Audio => "audio",
|
|
2650
|
+
NodeType::Video => "video",
|
|
2651
|
+
NodeType::Picture => "picture",
|
|
2652
|
+
NodeType::Source => "source",
|
|
2653
|
+
NodeType::Iframe => "iframe",
|
|
2654
|
+
NodeType::Svg => "svg",
|
|
2655
|
+
NodeType::Canvas => "canvas",
|
|
2656
|
+
NodeType::Ruby => "ruby",
|
|
2657
|
+
NodeType::Rt => "rt",
|
|
2658
|
+
NodeType::Rp => "rp",
|
|
2659
|
+
NodeType::Abbr => "abbr",
|
|
2660
|
+
NodeType::Kbd => "kbd",
|
|
2661
|
+
NodeType::Samp => "samp",
|
|
2662
|
+
NodeType::Var => "var",
|
|
2663
|
+
NodeType::Cite => "cite",
|
|
2664
|
+
NodeType::Q => "q",
|
|
2665
|
+
NodeType::Del => "del",
|
|
2666
|
+
NodeType::Ins => "ins",
|
|
2667
|
+
NodeType::Data => "data",
|
|
2668
|
+
NodeType::Meter => "meter",
|
|
2669
|
+
NodeType::Progress => "progress",
|
|
2670
|
+
NodeType::Output => "output",
|
|
2671
|
+
NodeType::Template => "template",
|
|
2672
|
+
NodeType::Slot => "slot",
|
|
2673
|
+
NodeType::Html => "html",
|
|
2674
|
+
NodeType::Head => "head",
|
|
2675
|
+
NodeType::Body => "body",
|
|
2676
|
+
NodeType::Title => "title",
|
|
2677
|
+
NodeType::Meta => "meta",
|
|
2678
|
+
NodeType::LinkTag => "link_tag",
|
|
2679
|
+
NodeType::Style => "style",
|
|
2680
|
+
NodeType::Script => "script",
|
|
2681
|
+
NodeType::Base => "base",
|
|
2682
|
+
NodeType::Custom => "custom",
|
|
2683
|
+
};
|
|
2684
|
+
handle.to_symbol(sym).into_value_with(handle)
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
impl magnus::TryConvert for NodeType {
|
|
2689
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2690
|
+
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
2691
|
+
match s.as_str() {
|
|
2692
|
+
"text" => Ok(NodeType::Text),
|
|
2693
|
+
"element" => Ok(NodeType::Element),
|
|
2694
|
+
"heading" => Ok(NodeType::Heading),
|
|
2695
|
+
"paragraph" => Ok(NodeType::Paragraph),
|
|
2696
|
+
"div" => Ok(NodeType::Div),
|
|
2697
|
+
"blockquote" => Ok(NodeType::Blockquote),
|
|
2698
|
+
"pre" => Ok(NodeType::Pre),
|
|
2699
|
+
"hr" => Ok(NodeType::Hr),
|
|
2700
|
+
"list" => Ok(NodeType::List),
|
|
2701
|
+
"list_item" => Ok(NodeType::ListItem),
|
|
2702
|
+
"definition_list" => Ok(NodeType::DefinitionList),
|
|
2703
|
+
"definition_term" => Ok(NodeType::DefinitionTerm),
|
|
2704
|
+
"definition_description" => Ok(NodeType::DefinitionDescription),
|
|
2705
|
+
"table" => Ok(NodeType::Table),
|
|
2706
|
+
"table_row" => Ok(NodeType::TableRow),
|
|
2707
|
+
"table_cell" => Ok(NodeType::TableCell),
|
|
2708
|
+
"table_header" => Ok(NodeType::TableHeader),
|
|
2709
|
+
"table_body" => Ok(NodeType::TableBody),
|
|
2710
|
+
"table_head" => Ok(NodeType::TableHead),
|
|
2711
|
+
"table_foot" => Ok(NodeType::TableFoot),
|
|
2712
|
+
"link" => Ok(NodeType::Link),
|
|
2713
|
+
"image" => Ok(NodeType::Image),
|
|
2714
|
+
"strong" => Ok(NodeType::Strong),
|
|
2715
|
+
"em" => Ok(NodeType::Em),
|
|
2716
|
+
"code" => Ok(NodeType::Code),
|
|
2717
|
+
"strikethrough" => Ok(NodeType::Strikethrough),
|
|
2718
|
+
"underline" => Ok(NodeType::Underline),
|
|
2719
|
+
"subscript" => Ok(NodeType::Subscript),
|
|
2720
|
+
"superscript" => Ok(NodeType::Superscript),
|
|
2721
|
+
"mark" => Ok(NodeType::Mark),
|
|
2722
|
+
"small" => Ok(NodeType::Small),
|
|
2723
|
+
"br" => Ok(NodeType::Br),
|
|
2724
|
+
"span" => Ok(NodeType::Span),
|
|
2725
|
+
"article" => Ok(NodeType::Article),
|
|
2726
|
+
"section" => Ok(NodeType::Section),
|
|
2727
|
+
"nav" => Ok(NodeType::Nav),
|
|
2728
|
+
"aside" => Ok(NodeType::Aside),
|
|
2729
|
+
"header" => Ok(NodeType::Header),
|
|
2730
|
+
"footer" => Ok(NodeType::Footer),
|
|
2731
|
+
"main" => Ok(NodeType::Main),
|
|
2732
|
+
"figure" => Ok(NodeType::Figure),
|
|
2733
|
+
"figcaption" => Ok(NodeType::Figcaption),
|
|
2734
|
+
"time" => Ok(NodeType::Time),
|
|
2735
|
+
"details" => Ok(NodeType::Details),
|
|
2736
|
+
"summary" => Ok(NodeType::Summary),
|
|
2737
|
+
"form" => Ok(NodeType::Form),
|
|
2738
|
+
"input" => Ok(NodeType::Input),
|
|
2739
|
+
"select" => Ok(NodeType::Select),
|
|
2740
|
+
"option" => Ok(NodeType::Option),
|
|
2741
|
+
"button" => Ok(NodeType::Button),
|
|
2742
|
+
"textarea" => Ok(NodeType::Textarea),
|
|
2743
|
+
"label" => Ok(NodeType::Label),
|
|
2744
|
+
"fieldset" => Ok(NodeType::Fieldset),
|
|
2745
|
+
"legend" => Ok(NodeType::Legend),
|
|
2746
|
+
"audio" => Ok(NodeType::Audio),
|
|
2747
|
+
"video" => Ok(NodeType::Video),
|
|
2748
|
+
"picture" => Ok(NodeType::Picture),
|
|
2749
|
+
"source" => Ok(NodeType::Source),
|
|
2750
|
+
"iframe" => Ok(NodeType::Iframe),
|
|
2751
|
+
"svg" => Ok(NodeType::Svg),
|
|
2752
|
+
"canvas" => Ok(NodeType::Canvas),
|
|
2753
|
+
"ruby" => Ok(NodeType::Ruby),
|
|
2754
|
+
"rt" => Ok(NodeType::Rt),
|
|
2755
|
+
"rp" => Ok(NodeType::Rp),
|
|
2756
|
+
"abbr" => Ok(NodeType::Abbr),
|
|
2757
|
+
"kbd" => Ok(NodeType::Kbd),
|
|
2758
|
+
"samp" => Ok(NodeType::Samp),
|
|
2759
|
+
"var" => Ok(NodeType::Var),
|
|
2760
|
+
"cite" => Ok(NodeType::Cite),
|
|
2761
|
+
"q" => Ok(NodeType::Q),
|
|
2762
|
+
"del" => Ok(NodeType::Del),
|
|
2763
|
+
"ins" => Ok(NodeType::Ins),
|
|
2764
|
+
"data" => Ok(NodeType::Data),
|
|
2765
|
+
"meter" => Ok(NodeType::Meter),
|
|
2766
|
+
"progress" => Ok(NodeType::Progress),
|
|
2767
|
+
"output" => Ok(NodeType::Output),
|
|
2768
|
+
"template" => Ok(NodeType::Template),
|
|
2769
|
+
"slot" => Ok(NodeType::Slot),
|
|
2770
|
+
"html" => Ok(NodeType::Html),
|
|
2771
|
+
"head" => Ok(NodeType::Head),
|
|
2772
|
+
"body" => Ok(NodeType::Body),
|
|
2773
|
+
"title" => Ok(NodeType::Title),
|
|
2774
|
+
"meta" => Ok(NodeType::Meta),
|
|
2775
|
+
"link_tag" => Ok(NodeType::LinkTag),
|
|
2776
|
+
"style" => Ok(NodeType::Style),
|
|
2777
|
+
"script" => Ok(NodeType::Script),
|
|
2778
|
+
"base" => Ok(NodeType::Base),
|
|
2779
|
+
"custom" => Ok(NodeType::Custom),
|
|
2780
|
+
other => Err(magnus::Error::new(
|
|
2781
|
+
unsafe { Ruby::get_unchecked() }.exception_arg_error(),
|
|
2782
|
+
format!("invalid NodeType value: {other}"),
|
|
2783
|
+
)),
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
unsafe impl IntoValueFromNative for NodeType {}
|
|
2789
|
+
unsafe impl TryConvertOwned for NodeType {}
|
|
2790
|
+
|
|
2791
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
2792
|
+
pub enum VisitResult {
|
|
2793
|
+
Continue,
|
|
2794
|
+
Custom { _0: String },
|
|
2795
|
+
Skip,
|
|
2796
|
+
PreserveHtml,
|
|
2797
|
+
Error { _0: String },
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
impl Default for VisitResult {
|
|
2801
|
+
fn default() -> Self {
|
|
2802
|
+
Self::Continue
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2806
|
+
impl magnus::IntoValue for VisitResult {
|
|
2807
|
+
fn into_value_with(self, handle: &Ruby) -> magnus::Value {
|
|
2808
|
+
match serde_json::to_value(&self) {
|
|
2809
|
+
Ok(v) => json_to_ruby(handle, v),
|
|
2810
|
+
Err(_) => handle.qnil().into_value_with(handle),
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
impl magnus::TryConvert for VisitResult {
|
|
2816
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2817
|
+
let s: String = magnus::TryConvert::try_convert(val)?;
|
|
2818
|
+
serde_json::from_str(&s)
|
|
2819
|
+
.map_err(|e| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_type_error(), e.to_string()))
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
unsafe impl IntoValueFromNative for VisitResult {}
|
|
2824
|
+
unsafe impl TryConvertOwned for VisitResult {}
|
|
2825
|
+
|
|
2826
|
+
#[allow(clippy::missing_errors_doc)]
|
|
2827
|
+
#[allow(unused_variables)]
|
|
2828
|
+
pub fn convert(
|
|
2829
|
+
html: String,
|
|
2830
|
+
options: Option<String>,
|
|
2831
|
+
visitor: Option<magnus::Value>,
|
|
2832
|
+
) -> Result<ConversionResult, Error> {
|
|
2833
|
+
let visitor: Option<html_to_markdown_rs::visitor::VisitorHandle> = match visitor {
|
|
2834
|
+
Some(v) if !v.is_nil() => {
|
|
2835
|
+
let bridge = RbHtmlVisitorBridge::new(v);
|
|
2836
|
+
Some(std::rc::Rc::new(std::cell::RefCell::new(bridge)) as html_to_markdown_rs::visitor::VisitorHandle)
|
|
2837
|
+
}
|
|
2838
|
+
_ => None,
|
|
2839
|
+
};
|
|
2840
|
+
let options_core: Option<html_to_markdown_rs::ConversionOptions> = options
|
|
2521
2841
|
.as_deref()
|
|
2522
2842
|
.filter(|s| *s != "nil")
|
|
2523
2843
|
.map(|s| {
|
|
2524
|
-
|
|
2525
|
-
magnus::Error::new(
|
|
2526
|
-
|
|
2527
|
-
|
|
2844
|
+
serde_json::from_str(s).map_err(|e| {
|
|
2845
|
+
magnus::Error::new(
|
|
2846
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_runtime_error(),
|
|
2847
|
+
e.to_string(),
|
|
2848
|
+
)
|
|
2849
|
+
})
|
|
2528
2850
|
})
|
|
2529
2851
|
.transpose()?;
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2852
|
+
html_to_markdown_rs::convert(&html, options_core, visitor)
|
|
2853
|
+
.map(|val| val.into())
|
|
2854
|
+
.map_err(|e| {
|
|
2855
|
+
magnus::Error::new(
|
|
2856
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_runtime_error(),
|
|
2857
|
+
e.to_string(),
|
|
2858
|
+
)
|
|
2859
|
+
})
|
|
2537
2860
|
}
|
|
2538
2861
|
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2862
|
+
fn nodecontext_to_rb_hash(ctx: &html_to_markdown_rs::visitor::NodeContext) -> magnus::RHash {
|
|
2863
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2864
|
+
let h = ruby.hash_new();
|
|
2865
|
+
h.aset(ruby.to_symbol("node_type"), format!("{:?}", ctx.node_type)).ok();
|
|
2866
|
+
h.aset(ruby.to_symbol("tag_name"), ctx.tag_name.as_str()).ok();
|
|
2867
|
+
h.aset(ruby.to_symbol("depth"), ctx.depth as i64).ok();
|
|
2868
|
+
h.aset(ruby.to_symbol("index_in_parent"), ctx.index_in_parent as i64)
|
|
2869
|
+
.ok();
|
|
2870
|
+
h.aset(ruby.to_symbol("is_inline"), ctx.is_inline).ok();
|
|
2871
|
+
h.aset(
|
|
2872
|
+
ruby.to_symbol("parent_tag"),
|
|
2873
|
+
ctx.parent_tag.as_deref().map(|s| ruby.str_new(s).as_value()),
|
|
2874
|
+
)
|
|
2875
|
+
.ok();
|
|
2876
|
+
let attrs = ruby.hash_new();
|
|
2877
|
+
for (k, v) in &ctx.attributes {
|
|
2878
|
+
attrs.aset(ruby.str_new(k), ruby.str_new(v)).ok();
|
|
2549
2879
|
}
|
|
2880
|
+
h.aset(ruby.to_symbol("attributes"), attrs).ok();
|
|
2881
|
+
h
|
|
2550
2882
|
}
|
|
2551
2883
|
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
extract_structured_data: val.extract_structured_data,
|
|
2560
|
-
max_structured_data_size: val.max_structured_data_size,
|
|
2561
|
-
}
|
|
2884
|
+
pub struct RbHtmlVisitorBridge {
|
|
2885
|
+
rb_obj: magnus::Value,
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
impl std::fmt::Debug for RbHtmlVisitorBridge {
|
|
2889
|
+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
2890
|
+
write!(f, "RbHtmlVisitorBridge")
|
|
2562
2891
|
}
|
|
2563
2892
|
}
|
|
2564
2893
|
|
|
2565
|
-
impl
|
|
2566
|
-
fn
|
|
2567
|
-
Self {
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2894
|
+
impl RbHtmlVisitorBridge {
|
|
2895
|
+
pub fn new(rb_obj: magnus::Value) -> Self {
|
|
2896
|
+
Self { rb_obj }
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
impl html_to_markdown_rs::visitor::HtmlVisitor for RbHtmlVisitorBridge {
|
|
2901
|
+
fn visit_element_start(&mut self, _ctx: &html_to_markdown_rs::NodeContext) -> html_to_markdown_rs::VisitResult {
|
|
2902
|
+
let responds = self.rb_obj.respond_to("visit_element_start", false).unwrap_or(false);
|
|
2903
|
+
if !responds {
|
|
2904
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
2905
|
+
}
|
|
2906
|
+
let result: Result<magnus::Value, magnus::Error> = self
|
|
2907
|
+
.rb_obj
|
|
2908
|
+
.funcall("visit_element_start", (nodecontext_to_rb_hash(_ctx),));
|
|
2909
|
+
match result {
|
|
2910
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
2911
|
+
Ok(val) => {
|
|
2912
|
+
let s: String = val.to_string();
|
|
2913
|
+
match s.to_lowercase().as_str() {
|
|
2914
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
2915
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
2916
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
2917
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
|
|
2923
|
+
fn visit_element_end(
|
|
2924
|
+
&mut self,
|
|
2925
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
2926
|
+
_output: &str,
|
|
2927
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
2928
|
+
let responds = self.rb_obj.respond_to("visit_element_end", false).unwrap_or(false);
|
|
2929
|
+
if !responds {
|
|
2930
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
2931
|
+
}
|
|
2932
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
2933
|
+
"visit_element_end",
|
|
2934
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
2935
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2936
|
+
ruby.str_new(_output)
|
|
2937
|
+
}),
|
|
2938
|
+
);
|
|
2939
|
+
match result {
|
|
2940
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
2941
|
+
Ok(val) => {
|
|
2942
|
+
let s: String = val.to_string();
|
|
2943
|
+
match s.to_lowercase().as_str() {
|
|
2944
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
2945
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
2946
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
2947
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
fn visit_text(&mut self, _ctx: &html_to_markdown_rs::NodeContext, _text: &str) -> html_to_markdown_rs::VisitResult {
|
|
2954
|
+
let responds = self.rb_obj.respond_to("visit_text", false).unwrap_or(false);
|
|
2955
|
+
if !responds {
|
|
2956
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
2957
|
+
}
|
|
2958
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
2959
|
+
"visit_text",
|
|
2960
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
2961
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2962
|
+
ruby.str_new(_text)
|
|
2963
|
+
}),
|
|
2964
|
+
);
|
|
2965
|
+
match result {
|
|
2966
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
2967
|
+
Ok(val) => {
|
|
2968
|
+
let s: String = val.to_string();
|
|
2969
|
+
match s.to_lowercase().as_str() {
|
|
2970
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
2971
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
2972
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
2973
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
fn visit_link(
|
|
2980
|
+
&mut self,
|
|
2981
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
2982
|
+
_href: &str,
|
|
2983
|
+
_text: &str,
|
|
2984
|
+
_title: Option<&str>,
|
|
2985
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
2986
|
+
let responds = self.rb_obj.respond_to("visit_link", false).unwrap_or(false);
|
|
2987
|
+
if !responds {
|
|
2988
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
2989
|
+
}
|
|
2990
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
2991
|
+
"visit_link",
|
|
2992
|
+
(
|
|
2993
|
+
nodecontext_to_rb_hash(_ctx),
|
|
2994
|
+
{
|
|
2995
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2996
|
+
ruby.str_new(_href)
|
|
2997
|
+
},
|
|
2998
|
+
{
|
|
2999
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3000
|
+
ruby.str_new(_text)
|
|
3001
|
+
},
|
|
3002
|
+
{
|
|
3003
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3004
|
+
match _title {
|
|
3005
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3006
|
+
None => ruby.qnil().as_value(),
|
|
3007
|
+
}
|
|
3008
|
+
},
|
|
3009
|
+
),
|
|
3010
|
+
);
|
|
3011
|
+
match result {
|
|
3012
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3013
|
+
Ok(val) => {
|
|
3014
|
+
let s: String = val.to_string();
|
|
3015
|
+
match s.to_lowercase().as_str() {
|
|
3016
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3017
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3018
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3019
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
fn visit_image(
|
|
3026
|
+
&mut self,
|
|
3027
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3028
|
+
_src: &str,
|
|
3029
|
+
_alt: &str,
|
|
3030
|
+
_title: Option<&str>,
|
|
3031
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3032
|
+
let responds = self.rb_obj.respond_to("visit_image", false).unwrap_or(false);
|
|
3033
|
+
if !responds {
|
|
3034
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3035
|
+
}
|
|
3036
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3037
|
+
"visit_image",
|
|
3038
|
+
(
|
|
3039
|
+
nodecontext_to_rb_hash(_ctx),
|
|
3040
|
+
{
|
|
3041
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3042
|
+
ruby.str_new(_src)
|
|
3043
|
+
},
|
|
3044
|
+
{
|
|
3045
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3046
|
+
ruby.str_new(_alt)
|
|
3047
|
+
},
|
|
3048
|
+
{
|
|
3049
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3050
|
+
match _title {
|
|
3051
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3052
|
+
None => ruby.qnil().as_value(),
|
|
3053
|
+
}
|
|
3054
|
+
},
|
|
3055
|
+
),
|
|
3056
|
+
);
|
|
3057
|
+
match result {
|
|
3058
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3059
|
+
Ok(val) => {
|
|
3060
|
+
let s: String = val.to_string();
|
|
3061
|
+
match s.to_lowercase().as_str() {
|
|
3062
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3063
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3064
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3065
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
fn visit_heading(
|
|
3072
|
+
&mut self,
|
|
3073
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3074
|
+
_level: u32,
|
|
3075
|
+
_text: &str,
|
|
3076
|
+
_id: Option<&str>,
|
|
3077
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3078
|
+
let responds = self.rb_obj.respond_to("visit_heading", false).unwrap_or(false);
|
|
3079
|
+
if !responds {
|
|
3080
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3081
|
+
}
|
|
3082
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3083
|
+
"visit_heading",
|
|
3084
|
+
(
|
|
3085
|
+
nodecontext_to_rb_hash(_ctx),
|
|
3086
|
+
_level,
|
|
3087
|
+
{
|
|
3088
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3089
|
+
ruby.str_new(_text)
|
|
3090
|
+
},
|
|
3091
|
+
{
|
|
3092
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3093
|
+
match _id {
|
|
3094
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3095
|
+
None => ruby.qnil().as_value(),
|
|
3096
|
+
}
|
|
3097
|
+
},
|
|
3098
|
+
),
|
|
3099
|
+
);
|
|
3100
|
+
match result {
|
|
3101
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3102
|
+
Ok(val) => {
|
|
3103
|
+
let s: String = val.to_string();
|
|
3104
|
+
match s.to_lowercase().as_str() {
|
|
3105
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3106
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3107
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3108
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
fn visit_code_block(
|
|
3115
|
+
&mut self,
|
|
3116
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3117
|
+
_lang: Option<&str>,
|
|
3118
|
+
_code: &str,
|
|
3119
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3120
|
+
let responds = self.rb_obj.respond_to("visit_code_block", false).unwrap_or(false);
|
|
3121
|
+
if !responds {
|
|
3122
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3123
|
+
}
|
|
3124
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3125
|
+
"visit_code_block",
|
|
3126
|
+
(
|
|
3127
|
+
nodecontext_to_rb_hash(_ctx),
|
|
3128
|
+
{
|
|
3129
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3130
|
+
match _lang {
|
|
3131
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3132
|
+
None => ruby.qnil().as_value(),
|
|
3133
|
+
}
|
|
3134
|
+
},
|
|
3135
|
+
{
|
|
3136
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3137
|
+
ruby.str_new(_code)
|
|
3138
|
+
},
|
|
3139
|
+
),
|
|
3140
|
+
);
|
|
3141
|
+
match result {
|
|
3142
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3143
|
+
Ok(val) => {
|
|
3144
|
+
let s: String = val.to_string();
|
|
3145
|
+
match s.to_lowercase().as_str() {
|
|
3146
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3147
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3148
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3149
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
fn visit_code_inline(
|
|
3156
|
+
&mut self,
|
|
3157
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3158
|
+
_code: &str,
|
|
3159
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3160
|
+
let responds = self.rb_obj.respond_to("visit_code_inline", false).unwrap_or(false);
|
|
3161
|
+
if !responds {
|
|
3162
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3163
|
+
}
|
|
3164
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3165
|
+
"visit_code_inline",
|
|
3166
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3167
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3168
|
+
ruby.str_new(_code)
|
|
3169
|
+
}),
|
|
3170
|
+
);
|
|
3171
|
+
match result {
|
|
3172
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3173
|
+
Ok(val) => {
|
|
3174
|
+
let s: String = val.to_string();
|
|
3175
|
+
match s.to_lowercase().as_str() {
|
|
3176
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3177
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3178
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3179
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
|
|
3185
|
+
fn visit_list_item(
|
|
3186
|
+
&mut self,
|
|
3187
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3188
|
+
_ordered: bool,
|
|
3189
|
+
_marker: &str,
|
|
3190
|
+
_text: &str,
|
|
3191
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3192
|
+
let responds = self.rb_obj.respond_to("visit_list_item", false).unwrap_or(false);
|
|
3193
|
+
if !responds {
|
|
3194
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3195
|
+
}
|
|
3196
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3197
|
+
"visit_list_item",
|
|
3198
|
+
(
|
|
3199
|
+
nodecontext_to_rb_hash(_ctx),
|
|
3200
|
+
_ordered,
|
|
3201
|
+
{
|
|
3202
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3203
|
+
ruby.str_new(_marker)
|
|
3204
|
+
},
|
|
3205
|
+
{
|
|
3206
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3207
|
+
ruby.str_new(_text)
|
|
3208
|
+
},
|
|
3209
|
+
),
|
|
3210
|
+
);
|
|
3211
|
+
match result {
|
|
3212
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3213
|
+
Ok(val) => {
|
|
3214
|
+
let s: String = val.to_string();
|
|
3215
|
+
match s.to_lowercase().as_str() {
|
|
3216
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3217
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3218
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3219
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
fn visit_list_start(
|
|
3226
|
+
&mut self,
|
|
3227
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3228
|
+
_ordered: bool,
|
|
3229
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3230
|
+
let responds = self.rb_obj.respond_to("visit_list_start", false).unwrap_or(false);
|
|
3231
|
+
if !responds {
|
|
3232
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3233
|
+
}
|
|
3234
|
+
let result: Result<magnus::Value, magnus::Error> = self
|
|
3235
|
+
.rb_obj
|
|
3236
|
+
.funcall("visit_list_start", (nodecontext_to_rb_hash(_ctx), _ordered));
|
|
3237
|
+
match result {
|
|
3238
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3239
|
+
Ok(val) => {
|
|
3240
|
+
let s: String = val.to_string();
|
|
3241
|
+
match s.to_lowercase().as_str() {
|
|
3242
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3243
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3244
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3245
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
fn visit_list_end(
|
|
3252
|
+
&mut self,
|
|
3253
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3254
|
+
_ordered: bool,
|
|
3255
|
+
_output: &str,
|
|
3256
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3257
|
+
let responds = self.rb_obj.respond_to("visit_list_end", false).unwrap_or(false);
|
|
3258
|
+
if !responds {
|
|
3259
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3260
|
+
}
|
|
3261
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3262
|
+
"visit_list_end",
|
|
3263
|
+
(nodecontext_to_rb_hash(_ctx), _ordered, {
|
|
3264
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3265
|
+
ruby.str_new(_output)
|
|
3266
|
+
}),
|
|
3267
|
+
);
|
|
3268
|
+
match result {
|
|
3269
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3270
|
+
Ok(val) => {
|
|
3271
|
+
let s: String = val.to_string();
|
|
3272
|
+
match s.to_lowercase().as_str() {
|
|
3273
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3274
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3275
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3276
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
|
|
3282
|
+
fn visit_table_start(&mut self, _ctx: &html_to_markdown_rs::NodeContext) -> html_to_markdown_rs::VisitResult {
|
|
3283
|
+
let responds = self.rb_obj.respond_to("visit_table_start", false).unwrap_or(false);
|
|
3284
|
+
if !responds {
|
|
3285
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3286
|
+
}
|
|
3287
|
+
let result: Result<magnus::Value, magnus::Error> = self
|
|
3288
|
+
.rb_obj
|
|
3289
|
+
.funcall("visit_table_start", (nodecontext_to_rb_hash(_ctx),));
|
|
3290
|
+
match result {
|
|
3291
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3292
|
+
Ok(val) => {
|
|
3293
|
+
let s: String = val.to_string();
|
|
3294
|
+
match s.to_lowercase().as_str() {
|
|
3295
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3296
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3297
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3298
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
fn visit_table_row(
|
|
3305
|
+
&mut self,
|
|
3306
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3307
|
+
_cells: &[String],
|
|
3308
|
+
_is_header: bool,
|
|
3309
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3310
|
+
let responds = self.rb_obj.respond_to("visit_table_row", false).unwrap_or(false);
|
|
3311
|
+
if !responds {
|
|
3312
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3313
|
+
}
|
|
3314
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3315
|
+
"visit_table_row",
|
|
3316
|
+
(
|
|
3317
|
+
nodecontext_to_rb_hash(_ctx),
|
|
3318
|
+
{
|
|
3319
|
+
let arr = unsafe { magnus::Ruby::get_unchecked() }.ary_new_capa(_cells.len());
|
|
3320
|
+
for item in _cells {
|
|
3321
|
+
let _ = arr.push(item.to_string());
|
|
3322
|
+
}
|
|
3323
|
+
arr
|
|
3324
|
+
},
|
|
3325
|
+
_is_header,
|
|
3326
|
+
),
|
|
3327
|
+
);
|
|
3328
|
+
match result {
|
|
3329
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3330
|
+
Ok(val) => {
|
|
3331
|
+
let s: String = val.to_string();
|
|
3332
|
+
match s.to_lowercase().as_str() {
|
|
3333
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3334
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3335
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3336
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
fn visit_table_end(
|
|
3343
|
+
&mut self,
|
|
3344
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3345
|
+
_output: &str,
|
|
3346
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3347
|
+
let responds = self.rb_obj.respond_to("visit_table_end", false).unwrap_or(false);
|
|
3348
|
+
if !responds {
|
|
3349
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3350
|
+
}
|
|
3351
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3352
|
+
"visit_table_end",
|
|
3353
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3354
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3355
|
+
ruby.str_new(_output)
|
|
3356
|
+
}),
|
|
3357
|
+
);
|
|
3358
|
+
match result {
|
|
3359
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3360
|
+
Ok(val) => {
|
|
3361
|
+
let s: String = val.to_string();
|
|
3362
|
+
match s.to_lowercase().as_str() {
|
|
3363
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3364
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3365
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3366
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3372
|
+
fn visit_blockquote(
|
|
3373
|
+
&mut self,
|
|
3374
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3375
|
+
_content: &str,
|
|
3376
|
+
_depth: usize,
|
|
3377
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3378
|
+
let responds = self.rb_obj.respond_to("visit_blockquote", false).unwrap_or(false);
|
|
3379
|
+
if !responds {
|
|
3380
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3381
|
+
}
|
|
3382
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3383
|
+
"visit_blockquote",
|
|
3384
|
+
(
|
|
3385
|
+
nodecontext_to_rb_hash(_ctx),
|
|
3386
|
+
{
|
|
3387
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3388
|
+
ruby.str_new(_content)
|
|
3389
|
+
},
|
|
3390
|
+
_depth,
|
|
3391
|
+
),
|
|
3392
|
+
);
|
|
3393
|
+
match result {
|
|
3394
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3395
|
+
Ok(val) => {
|
|
3396
|
+
let s: String = val.to_string();
|
|
3397
|
+
match s.to_lowercase().as_str() {
|
|
3398
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3399
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3400
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3401
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
|
|
3407
|
+
fn visit_strong(
|
|
3408
|
+
&mut self,
|
|
3409
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3410
|
+
_text: &str,
|
|
3411
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3412
|
+
let responds = self.rb_obj.respond_to("visit_strong", false).unwrap_or(false);
|
|
3413
|
+
if !responds {
|
|
3414
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3415
|
+
}
|
|
3416
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3417
|
+
"visit_strong",
|
|
3418
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3419
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3420
|
+
ruby.str_new(_text)
|
|
3421
|
+
}),
|
|
3422
|
+
);
|
|
3423
|
+
match result {
|
|
3424
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3425
|
+
Ok(val) => {
|
|
3426
|
+
let s: String = val.to_string();
|
|
3427
|
+
match s.to_lowercase().as_str() {
|
|
3428
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3429
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3430
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3431
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
|
|
3437
|
+
fn visit_emphasis(
|
|
3438
|
+
&mut self,
|
|
3439
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3440
|
+
_text: &str,
|
|
3441
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3442
|
+
let responds = self.rb_obj.respond_to("visit_emphasis", false).unwrap_or(false);
|
|
3443
|
+
if !responds {
|
|
3444
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3445
|
+
}
|
|
3446
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3447
|
+
"visit_emphasis",
|
|
3448
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3449
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3450
|
+
ruby.str_new(_text)
|
|
3451
|
+
}),
|
|
3452
|
+
);
|
|
3453
|
+
match result {
|
|
3454
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3455
|
+
Ok(val) => {
|
|
3456
|
+
let s: String = val.to_string();
|
|
3457
|
+
match s.to_lowercase().as_str() {
|
|
3458
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3459
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3460
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3461
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3466
|
+
|
|
3467
|
+
fn visit_strikethrough(
|
|
3468
|
+
&mut self,
|
|
3469
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3470
|
+
_text: &str,
|
|
3471
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3472
|
+
let responds = self.rb_obj.respond_to("visit_strikethrough", false).unwrap_or(false);
|
|
3473
|
+
if !responds {
|
|
3474
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3475
|
+
}
|
|
3476
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3477
|
+
"visit_strikethrough",
|
|
3478
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3479
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3480
|
+
ruby.str_new(_text)
|
|
3481
|
+
}),
|
|
3482
|
+
);
|
|
3483
|
+
match result {
|
|
3484
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3485
|
+
Ok(val) => {
|
|
3486
|
+
let s: String = val.to_string();
|
|
3487
|
+
match s.to_lowercase().as_str() {
|
|
3488
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3489
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3490
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3491
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
|
|
3497
|
+
fn visit_underline(
|
|
3498
|
+
&mut self,
|
|
3499
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3500
|
+
_text: &str,
|
|
3501
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3502
|
+
let responds = self.rb_obj.respond_to("visit_underline", false).unwrap_or(false);
|
|
3503
|
+
if !responds {
|
|
3504
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3505
|
+
}
|
|
3506
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3507
|
+
"visit_underline",
|
|
3508
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3509
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3510
|
+
ruby.str_new(_text)
|
|
3511
|
+
}),
|
|
3512
|
+
);
|
|
3513
|
+
match result {
|
|
3514
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3515
|
+
Ok(val) => {
|
|
3516
|
+
let s: String = val.to_string();
|
|
3517
|
+
match s.to_lowercase().as_str() {
|
|
3518
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3519
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3520
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3521
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
|
|
3527
|
+
fn visit_subscript(
|
|
3528
|
+
&mut self,
|
|
3529
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3530
|
+
_text: &str,
|
|
3531
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3532
|
+
let responds = self.rb_obj.respond_to("visit_subscript", false).unwrap_or(false);
|
|
3533
|
+
if !responds {
|
|
3534
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3535
|
+
}
|
|
3536
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3537
|
+
"visit_subscript",
|
|
3538
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3539
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3540
|
+
ruby.str_new(_text)
|
|
3541
|
+
}),
|
|
3542
|
+
);
|
|
3543
|
+
match result {
|
|
3544
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3545
|
+
Ok(val) => {
|
|
3546
|
+
let s: String = val.to_string();
|
|
3547
|
+
match s.to_lowercase().as_str() {
|
|
3548
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3549
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3550
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3551
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
fn visit_superscript(
|
|
3558
|
+
&mut self,
|
|
3559
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3560
|
+
_text: &str,
|
|
3561
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3562
|
+
let responds = self.rb_obj.respond_to("visit_superscript", false).unwrap_or(false);
|
|
3563
|
+
if !responds {
|
|
3564
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3565
|
+
}
|
|
3566
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3567
|
+
"visit_superscript",
|
|
3568
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3569
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3570
|
+
ruby.str_new(_text)
|
|
3571
|
+
}),
|
|
3572
|
+
);
|
|
3573
|
+
match result {
|
|
3574
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3575
|
+
Ok(val) => {
|
|
3576
|
+
let s: String = val.to_string();
|
|
3577
|
+
match s.to_lowercase().as_str() {
|
|
3578
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3579
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3580
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3581
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
}
|
|
3586
|
+
|
|
3587
|
+
fn visit_mark(&mut self, _ctx: &html_to_markdown_rs::NodeContext, _text: &str) -> html_to_markdown_rs::VisitResult {
|
|
3588
|
+
let responds = self.rb_obj.respond_to("visit_mark", false).unwrap_or(false);
|
|
3589
|
+
if !responds {
|
|
3590
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3591
|
+
}
|
|
3592
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3593
|
+
"visit_mark",
|
|
3594
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3595
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3596
|
+
ruby.str_new(_text)
|
|
3597
|
+
}),
|
|
3598
|
+
);
|
|
3599
|
+
match result {
|
|
3600
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3601
|
+
Ok(val) => {
|
|
3602
|
+
let s: String = val.to_string();
|
|
3603
|
+
match s.to_lowercase().as_str() {
|
|
3604
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3605
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3606
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3607
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
fn visit_line_break(&mut self, _ctx: &html_to_markdown_rs::NodeContext) -> html_to_markdown_rs::VisitResult {
|
|
3614
|
+
let responds = self.rb_obj.respond_to("visit_line_break", false).unwrap_or(false);
|
|
3615
|
+
if !responds {
|
|
3616
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3617
|
+
}
|
|
3618
|
+
let result: Result<magnus::Value, magnus::Error> =
|
|
3619
|
+
self.rb_obj.funcall("visit_line_break", (nodecontext_to_rb_hash(_ctx),));
|
|
3620
|
+
match result {
|
|
3621
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3622
|
+
Ok(val) => {
|
|
3623
|
+
let s: String = val.to_string();
|
|
3624
|
+
match s.to_lowercase().as_str() {
|
|
3625
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3626
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3627
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3628
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3634
|
+
fn visit_horizontal_rule(&mut self, _ctx: &html_to_markdown_rs::NodeContext) -> html_to_markdown_rs::VisitResult {
|
|
3635
|
+
let responds = self.rb_obj.respond_to("visit_horizontal_rule", false).unwrap_or(false);
|
|
3636
|
+
if !responds {
|
|
3637
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3638
|
+
}
|
|
3639
|
+
let result: Result<magnus::Value, magnus::Error> = self
|
|
3640
|
+
.rb_obj
|
|
3641
|
+
.funcall("visit_horizontal_rule", (nodecontext_to_rb_hash(_ctx),));
|
|
3642
|
+
match result {
|
|
3643
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3644
|
+
Ok(val) => {
|
|
3645
|
+
let s: String = val.to_string();
|
|
3646
|
+
match s.to_lowercase().as_str() {
|
|
3647
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3648
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3649
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3650
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
|
|
3656
|
+
fn visit_custom_element(
|
|
3657
|
+
&mut self,
|
|
3658
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3659
|
+
_tag_name: &str,
|
|
3660
|
+
_html: &str,
|
|
3661
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3662
|
+
let responds = self.rb_obj.respond_to("visit_custom_element", false).unwrap_or(false);
|
|
3663
|
+
if !responds {
|
|
3664
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3665
|
+
}
|
|
3666
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3667
|
+
"visit_custom_element",
|
|
3668
|
+
(
|
|
3669
|
+
nodecontext_to_rb_hash(_ctx),
|
|
3670
|
+
{
|
|
3671
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3672
|
+
ruby.str_new(_tag_name)
|
|
3673
|
+
},
|
|
3674
|
+
{
|
|
3675
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3676
|
+
ruby.str_new(_html)
|
|
3677
|
+
},
|
|
3678
|
+
),
|
|
3679
|
+
);
|
|
3680
|
+
match result {
|
|
3681
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3682
|
+
Ok(val) => {
|
|
3683
|
+
let s: String = val.to_string();
|
|
3684
|
+
match s.to_lowercase().as_str() {
|
|
3685
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3686
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3687
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3688
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3693
|
+
|
|
3694
|
+
fn visit_definition_list_start(
|
|
3695
|
+
&mut self,
|
|
3696
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3697
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3698
|
+
let responds = self
|
|
3699
|
+
.rb_obj
|
|
3700
|
+
.respond_to("visit_definition_list_start", false)
|
|
3701
|
+
.unwrap_or(false);
|
|
3702
|
+
if !responds {
|
|
3703
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3704
|
+
}
|
|
3705
|
+
let result: Result<magnus::Value, magnus::Error> = self
|
|
3706
|
+
.rb_obj
|
|
3707
|
+
.funcall("visit_definition_list_start", (nodecontext_to_rb_hash(_ctx),));
|
|
3708
|
+
match result {
|
|
3709
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3710
|
+
Ok(val) => {
|
|
3711
|
+
let s: String = val.to_string();
|
|
3712
|
+
match s.to_lowercase().as_str() {
|
|
3713
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3714
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3715
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3716
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
}
|
|
3721
|
+
|
|
3722
|
+
fn visit_definition_term(
|
|
3723
|
+
&mut self,
|
|
3724
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3725
|
+
_text: &str,
|
|
3726
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3727
|
+
let responds = self.rb_obj.respond_to("visit_definition_term", false).unwrap_or(false);
|
|
3728
|
+
if !responds {
|
|
3729
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3730
|
+
}
|
|
3731
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3732
|
+
"visit_definition_term",
|
|
3733
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3734
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3735
|
+
ruby.str_new(_text)
|
|
3736
|
+
}),
|
|
3737
|
+
);
|
|
3738
|
+
match result {
|
|
3739
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3740
|
+
Ok(val) => {
|
|
3741
|
+
let s: String = val.to_string();
|
|
3742
|
+
match s.to_lowercase().as_str() {
|
|
3743
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3744
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3745
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3746
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3752
|
+
fn visit_definition_description(
|
|
3753
|
+
&mut self,
|
|
3754
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3755
|
+
_text: &str,
|
|
3756
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3757
|
+
let responds = self
|
|
3758
|
+
.rb_obj
|
|
3759
|
+
.respond_to("visit_definition_description", false)
|
|
3760
|
+
.unwrap_or(false);
|
|
3761
|
+
if !responds {
|
|
3762
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3763
|
+
}
|
|
3764
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3765
|
+
"visit_definition_description",
|
|
3766
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3767
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3768
|
+
ruby.str_new(_text)
|
|
3769
|
+
}),
|
|
3770
|
+
);
|
|
3771
|
+
match result {
|
|
3772
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3773
|
+
Ok(val) => {
|
|
3774
|
+
let s: String = val.to_string();
|
|
3775
|
+
match s.to_lowercase().as_str() {
|
|
3776
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3777
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3778
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3779
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
|
|
3785
|
+
fn visit_definition_list_end(
|
|
3786
|
+
&mut self,
|
|
3787
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3788
|
+
_output: &str,
|
|
3789
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3790
|
+
let responds = self
|
|
3791
|
+
.rb_obj
|
|
3792
|
+
.respond_to("visit_definition_list_end", false)
|
|
3793
|
+
.unwrap_or(false);
|
|
3794
|
+
if !responds {
|
|
3795
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3796
|
+
}
|
|
3797
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3798
|
+
"visit_definition_list_end",
|
|
3799
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3800
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3801
|
+
ruby.str_new(_output)
|
|
3802
|
+
}),
|
|
3803
|
+
);
|
|
3804
|
+
match result {
|
|
3805
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3806
|
+
Ok(val) => {
|
|
3807
|
+
let s: String = val.to_string();
|
|
3808
|
+
match s.to_lowercase().as_str() {
|
|
3809
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3810
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3811
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3812
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
fn visit_form(
|
|
3819
|
+
&mut self,
|
|
3820
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3821
|
+
_action: Option<&str>,
|
|
3822
|
+
_method: Option<&str>,
|
|
3823
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3824
|
+
let responds = self.rb_obj.respond_to("visit_form", false).unwrap_or(false);
|
|
3825
|
+
if !responds {
|
|
3826
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3827
|
+
}
|
|
3828
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3829
|
+
"visit_form",
|
|
3830
|
+
(
|
|
3831
|
+
nodecontext_to_rb_hash(_ctx),
|
|
3832
|
+
{
|
|
3833
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3834
|
+
match _action {
|
|
3835
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3836
|
+
None => ruby.qnil().as_value(),
|
|
3837
|
+
}
|
|
3838
|
+
},
|
|
3839
|
+
{
|
|
3840
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3841
|
+
match _method {
|
|
3842
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3843
|
+
None => ruby.qnil().as_value(),
|
|
3844
|
+
}
|
|
3845
|
+
},
|
|
3846
|
+
),
|
|
3847
|
+
);
|
|
3848
|
+
match result {
|
|
3849
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3850
|
+
Ok(val) => {
|
|
3851
|
+
let s: String = val.to_string();
|
|
3852
|
+
match s.to_lowercase().as_str() {
|
|
3853
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3854
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3855
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3856
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
fn visit_input(
|
|
3863
|
+
&mut self,
|
|
3864
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3865
|
+
_input_type: &str,
|
|
3866
|
+
_name: Option<&str>,
|
|
3867
|
+
_value: Option<&str>,
|
|
3868
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3869
|
+
let responds = self.rb_obj.respond_to("visit_input", false).unwrap_or(false);
|
|
3870
|
+
if !responds {
|
|
3871
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3872
|
+
}
|
|
3873
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3874
|
+
"visit_input",
|
|
3875
|
+
(
|
|
3876
|
+
nodecontext_to_rb_hash(_ctx),
|
|
3877
|
+
{
|
|
3878
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3879
|
+
ruby.str_new(_input_type)
|
|
3880
|
+
},
|
|
3881
|
+
{
|
|
3882
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3883
|
+
match _name {
|
|
3884
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3885
|
+
None => ruby.qnil().as_value(),
|
|
3886
|
+
}
|
|
3887
|
+
},
|
|
3888
|
+
{
|
|
3889
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3890
|
+
match _value {
|
|
3891
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3892
|
+
None => ruby.qnil().as_value(),
|
|
3893
|
+
}
|
|
3894
|
+
},
|
|
3895
|
+
),
|
|
3896
|
+
);
|
|
3897
|
+
match result {
|
|
3898
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3899
|
+
Ok(val) => {
|
|
3900
|
+
let s: String = val.to_string();
|
|
3901
|
+
match s.to_lowercase().as_str() {
|
|
3902
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3903
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3904
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3905
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
|
|
3911
|
+
fn visit_button(
|
|
3912
|
+
&mut self,
|
|
3913
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3914
|
+
_text: &str,
|
|
3915
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3916
|
+
let responds = self.rb_obj.respond_to("visit_button", false).unwrap_or(false);
|
|
3917
|
+
if !responds {
|
|
3918
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3919
|
+
}
|
|
3920
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3921
|
+
"visit_button",
|
|
3922
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3923
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3924
|
+
ruby.str_new(_text)
|
|
3925
|
+
}),
|
|
3926
|
+
);
|
|
3927
|
+
match result {
|
|
3928
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3929
|
+
Ok(val) => {
|
|
3930
|
+
let s: String = val.to_string();
|
|
3931
|
+
match s.to_lowercase().as_str() {
|
|
3932
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3933
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3934
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3935
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
|
|
3941
|
+
fn visit_audio(
|
|
3942
|
+
&mut self,
|
|
3943
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3944
|
+
_src: Option<&str>,
|
|
3945
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3946
|
+
let responds = self.rb_obj.respond_to("visit_audio", false).unwrap_or(false);
|
|
3947
|
+
if !responds {
|
|
3948
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3949
|
+
}
|
|
3950
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3951
|
+
"visit_audio",
|
|
3952
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3953
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3954
|
+
match _src {
|
|
3955
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3956
|
+
None => ruby.qnil().as_value(),
|
|
3957
|
+
}
|
|
3958
|
+
}),
|
|
3959
|
+
);
|
|
3960
|
+
match result {
|
|
3961
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3962
|
+
Ok(val) => {
|
|
3963
|
+
let s: String = val.to_string();
|
|
3964
|
+
match s.to_lowercase().as_str() {
|
|
3965
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3966
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
3967
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
3968
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
fn visit_video(
|
|
3975
|
+
&mut self,
|
|
3976
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
3977
|
+
_src: Option<&str>,
|
|
3978
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
3979
|
+
let responds = self.rb_obj.respond_to("visit_video", false).unwrap_or(false);
|
|
3980
|
+
if !responds {
|
|
3981
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
3982
|
+
}
|
|
3983
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
3984
|
+
"visit_video",
|
|
3985
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
3986
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
3987
|
+
match _src {
|
|
3988
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
3989
|
+
None => ruby.qnil().as_value(),
|
|
3990
|
+
}
|
|
3991
|
+
}),
|
|
3992
|
+
);
|
|
3993
|
+
match result {
|
|
3994
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
3995
|
+
Ok(val) => {
|
|
3996
|
+
let s: String = val.to_string();
|
|
3997
|
+
match s.to_lowercase().as_str() {
|
|
3998
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
3999
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4000
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4001
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
fn visit_iframe(
|
|
4008
|
+
&mut self,
|
|
4009
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
4010
|
+
_src: Option<&str>,
|
|
4011
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
4012
|
+
let responds = self.rb_obj.respond_to("visit_iframe", false).unwrap_or(false);
|
|
4013
|
+
if !responds {
|
|
4014
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
4015
|
+
}
|
|
4016
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
4017
|
+
"visit_iframe",
|
|
4018
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
4019
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4020
|
+
match _src {
|
|
4021
|
+
Some(s) => ruby.str_new(s).as_value(),
|
|
4022
|
+
None => ruby.qnil().as_value(),
|
|
4023
|
+
}
|
|
4024
|
+
}),
|
|
4025
|
+
);
|
|
4026
|
+
match result {
|
|
4027
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
4028
|
+
Ok(val) => {
|
|
4029
|
+
let s: String = val.to_string();
|
|
4030
|
+
match s.to_lowercase().as_str() {
|
|
4031
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4032
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4033
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4034
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
4035
|
+
}
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
fn visit_details(
|
|
4041
|
+
&mut self,
|
|
4042
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
4043
|
+
_open: bool,
|
|
4044
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
4045
|
+
let responds = self.rb_obj.respond_to("visit_details", false).unwrap_or(false);
|
|
4046
|
+
if !responds {
|
|
4047
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
4048
|
+
}
|
|
4049
|
+
let result: Result<magnus::Value, magnus::Error> = self
|
|
4050
|
+
.rb_obj
|
|
4051
|
+
.funcall("visit_details", (nodecontext_to_rb_hash(_ctx), _open));
|
|
4052
|
+
match result {
|
|
4053
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
4054
|
+
Ok(val) => {
|
|
4055
|
+
let s: String = val.to_string();
|
|
4056
|
+
match s.to_lowercase().as_str() {
|
|
4057
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4058
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4059
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4060
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
|
|
4066
|
+
fn visit_summary(
|
|
4067
|
+
&mut self,
|
|
4068
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
4069
|
+
_text: &str,
|
|
4070
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
4071
|
+
let responds = self.rb_obj.respond_to("visit_summary", false).unwrap_or(false);
|
|
4072
|
+
if !responds {
|
|
4073
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
4074
|
+
}
|
|
4075
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
4076
|
+
"visit_summary",
|
|
4077
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
4078
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4079
|
+
ruby.str_new(_text)
|
|
4080
|
+
}),
|
|
4081
|
+
);
|
|
4082
|
+
match result {
|
|
4083
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
4084
|
+
Ok(val) => {
|
|
4085
|
+
let s: String = val.to_string();
|
|
4086
|
+
match s.to_lowercase().as_str() {
|
|
4087
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4088
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4089
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4090
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
4091
|
+
}
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
fn visit_figure_start(&mut self, _ctx: &html_to_markdown_rs::NodeContext) -> html_to_markdown_rs::VisitResult {
|
|
4097
|
+
let responds = self.rb_obj.respond_to("visit_figure_start", false).unwrap_or(false);
|
|
4098
|
+
if !responds {
|
|
4099
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
4100
|
+
}
|
|
4101
|
+
let result: Result<magnus::Value, magnus::Error> = self
|
|
4102
|
+
.rb_obj
|
|
4103
|
+
.funcall("visit_figure_start", (nodecontext_to_rb_hash(_ctx),));
|
|
4104
|
+
match result {
|
|
4105
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
4106
|
+
Ok(val) => {
|
|
4107
|
+
let s: String = val.to_string();
|
|
4108
|
+
match s.to_lowercase().as_str() {
|
|
4109
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4110
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4111
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4112
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
4116
|
+
}
|
|
4117
|
+
|
|
4118
|
+
fn visit_figcaption(
|
|
4119
|
+
&mut self,
|
|
4120
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
4121
|
+
_text: &str,
|
|
4122
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
4123
|
+
let responds = self.rb_obj.respond_to("visit_figcaption", false).unwrap_or(false);
|
|
4124
|
+
if !responds {
|
|
4125
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
4126
|
+
}
|
|
4127
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
4128
|
+
"visit_figcaption",
|
|
4129
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
4130
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4131
|
+
ruby.str_new(_text)
|
|
4132
|
+
}),
|
|
4133
|
+
);
|
|
4134
|
+
match result {
|
|
4135
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
4136
|
+
Ok(val) => {
|
|
4137
|
+
let s: String = val.to_string();
|
|
4138
|
+
match s.to_lowercase().as_str() {
|
|
4139
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4140
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4141
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4142
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
|
|
4148
|
+
fn visit_figure_end(
|
|
4149
|
+
&mut self,
|
|
4150
|
+
_ctx: &html_to_markdown_rs::NodeContext,
|
|
4151
|
+
_output: &str,
|
|
4152
|
+
) -> html_to_markdown_rs::VisitResult {
|
|
4153
|
+
let responds = self.rb_obj.respond_to("visit_figure_end", false).unwrap_or(false);
|
|
4154
|
+
if !responds {
|
|
4155
|
+
return html_to_markdown_rs::VisitResult::Continue;
|
|
4156
|
+
}
|
|
4157
|
+
let result: Result<magnus::Value, magnus::Error> = self.rb_obj.funcall(
|
|
4158
|
+
"visit_figure_end",
|
|
4159
|
+
(nodecontext_to_rb_hash(_ctx), {
|
|
4160
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
4161
|
+
ruby.str_new(_output)
|
|
4162
|
+
}),
|
|
4163
|
+
);
|
|
4164
|
+
match result {
|
|
4165
|
+
Err(_) => html_to_markdown_rs::VisitResult::Continue,
|
|
4166
|
+
Ok(val) => {
|
|
4167
|
+
let s: String = val.to_string();
|
|
4168
|
+
match s.to_lowercase().as_str() {
|
|
4169
|
+
"continue" => html_to_markdown_rs::VisitResult::Continue,
|
|
4170
|
+
"skip" => html_to_markdown_rs::VisitResult::Skip,
|
|
4171
|
+
"preserve_html" | "preservehtml" => html_to_markdown_rs::VisitResult::PreserveHtml,
|
|
4172
|
+
other => html_to_markdown_rs::VisitResult::Custom(other.to_string()),
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
2574
4175
|
}
|
|
2575
4176
|
}
|
|
2576
4177
|
}
|
|
2577
4178
|
|
|
4179
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2578
4180
|
impl From<DocumentMetadata> for html_to_markdown_rs::metadata::DocumentMetadata {
|
|
2579
4181
|
fn from(val: DocumentMetadata) -> Self {
|
|
2580
4182
|
Self {
|
|
@@ -2593,6 +4195,7 @@ impl From<DocumentMetadata> for html_to_markdown_rs::metadata::DocumentMetadata
|
|
|
2593
4195
|
}
|
|
2594
4196
|
}
|
|
2595
4197
|
|
|
4198
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2596
4199
|
impl From<html_to_markdown_rs::metadata::DocumentMetadata> for DocumentMetadata {
|
|
2597
4200
|
fn from(val: html_to_markdown_rs::metadata::DocumentMetadata) -> Self {
|
|
2598
4201
|
Self {
|
|
@@ -2611,6 +4214,7 @@ impl From<html_to_markdown_rs::metadata::DocumentMetadata> for DocumentMetadata
|
|
|
2611
4214
|
}
|
|
2612
4215
|
}
|
|
2613
4216
|
|
|
4217
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2614
4218
|
impl From<HeaderMetadata> for html_to_markdown_rs::metadata::HeaderMetadata {
|
|
2615
4219
|
fn from(val: HeaderMetadata) -> Self {
|
|
2616
4220
|
Self {
|
|
@@ -2623,6 +4227,7 @@ impl From<HeaderMetadata> for html_to_markdown_rs::metadata::HeaderMetadata {
|
|
|
2623
4227
|
}
|
|
2624
4228
|
}
|
|
2625
4229
|
|
|
4230
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2626
4231
|
impl From<html_to_markdown_rs::metadata::HeaderMetadata> for HeaderMetadata {
|
|
2627
4232
|
fn from(val: html_to_markdown_rs::metadata::HeaderMetadata) -> Self {
|
|
2628
4233
|
Self {
|
|
@@ -2635,6 +4240,7 @@ impl From<html_to_markdown_rs::metadata::HeaderMetadata> for HeaderMetadata {
|
|
|
2635
4240
|
}
|
|
2636
4241
|
}
|
|
2637
4242
|
|
|
4243
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2638
4244
|
impl From<LinkMetadata> for html_to_markdown_rs::metadata::LinkMetadata {
|
|
2639
4245
|
fn from(val: LinkMetadata) -> Self {
|
|
2640
4246
|
Self {
|
|
@@ -2648,6 +4254,7 @@ impl From<LinkMetadata> for html_to_markdown_rs::metadata::LinkMetadata {
|
|
|
2648
4254
|
}
|
|
2649
4255
|
}
|
|
2650
4256
|
|
|
4257
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2651
4258
|
impl From<html_to_markdown_rs::metadata::LinkMetadata> for LinkMetadata {
|
|
2652
4259
|
fn from(val: html_to_markdown_rs::metadata::LinkMetadata) -> Self {
|
|
2653
4260
|
Self {
|
|
@@ -2661,6 +4268,7 @@ impl From<html_to_markdown_rs::metadata::LinkMetadata> for LinkMetadata {
|
|
|
2661
4268
|
}
|
|
2662
4269
|
}
|
|
2663
4270
|
|
|
4271
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2664
4272
|
impl From<ImageMetadata> for html_to_markdown_rs::metadata::ImageMetadata {
|
|
2665
4273
|
fn from(val: ImageMetadata) -> Self {
|
|
2666
4274
|
Self {
|
|
@@ -2674,19 +4282,24 @@ impl From<ImageMetadata> for html_to_markdown_rs::metadata::ImageMetadata {
|
|
|
2674
4282
|
}
|
|
2675
4283
|
}
|
|
2676
4284
|
|
|
4285
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2677
4286
|
impl From<html_to_markdown_rs::metadata::ImageMetadata> for ImageMetadata {
|
|
2678
4287
|
fn from(val: html_to_markdown_rs::metadata::ImageMetadata) -> Self {
|
|
2679
4288
|
Self {
|
|
2680
4289
|
src: val.src,
|
|
2681
4290
|
alt: val.alt,
|
|
2682
4291
|
title: val.title,
|
|
2683
|
-
dimensions: val.dimensions.
|
|
4292
|
+
dimensions: val.dimensions.map(|t| {
|
|
4293
|
+
let arr: Vec<_> = [t.0, t.1].into_iter().map(|v| v as _).collect();
|
|
4294
|
+
arr
|
|
4295
|
+
}),
|
|
2684
4296
|
image_type: val.image_type.into(),
|
|
2685
4297
|
attributes: val.attributes.into_iter().collect(),
|
|
2686
4298
|
}
|
|
2687
4299
|
}
|
|
2688
4300
|
}
|
|
2689
4301
|
|
|
4302
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2690
4303
|
impl From<StructuredData> for html_to_markdown_rs::metadata::StructuredData {
|
|
2691
4304
|
fn from(val: StructuredData) -> Self {
|
|
2692
4305
|
Self {
|
|
@@ -2697,6 +4310,7 @@ impl From<StructuredData> for html_to_markdown_rs::metadata::StructuredData {
|
|
|
2697
4310
|
}
|
|
2698
4311
|
}
|
|
2699
4312
|
|
|
4313
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2700
4314
|
impl From<html_to_markdown_rs::metadata::StructuredData> for StructuredData {
|
|
2701
4315
|
fn from(val: html_to_markdown_rs::metadata::StructuredData) -> Self {
|
|
2702
4316
|
Self {
|
|
@@ -2707,6 +4321,7 @@ impl From<html_to_markdown_rs::metadata::StructuredData> for StructuredData {
|
|
|
2707
4321
|
}
|
|
2708
4322
|
}
|
|
2709
4323
|
|
|
4324
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2710
4325
|
impl From<HtmlMetadata> for html_to_markdown_rs::metadata::HtmlMetadata {
|
|
2711
4326
|
fn from(val: HtmlMetadata) -> Self {
|
|
2712
4327
|
Self {
|
|
@@ -2719,6 +4334,7 @@ impl From<HtmlMetadata> for html_to_markdown_rs::metadata::HtmlMetadata {
|
|
|
2719
4334
|
}
|
|
2720
4335
|
}
|
|
2721
4336
|
|
|
4337
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2722
4338
|
impl From<html_to_markdown_rs::metadata::HtmlMetadata> for HtmlMetadata {
|
|
2723
4339
|
fn from(val: html_to_markdown_rs::metadata::HtmlMetadata) -> Self {
|
|
2724
4340
|
Self {
|
|
@@ -2731,6 +4347,7 @@ impl From<html_to_markdown_rs::metadata::HtmlMetadata> for HtmlMetadata {
|
|
|
2731
4347
|
}
|
|
2732
4348
|
}
|
|
2733
4349
|
|
|
4350
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2734
4351
|
impl From<ConversionOptions> for html_to_markdown_rs::options::ConversionOptions {
|
|
2735
4352
|
fn from(val: ConversionOptions) -> Self {
|
|
2736
4353
|
Self {
|
|
@@ -2772,10 +4389,13 @@ impl From<ConversionOptions> for html_to_markdown_rs::options::ConversionOptions
|
|
|
2772
4389
|
max_image_size: val.max_image_size,
|
|
2773
4390
|
capture_svg: val.capture_svg,
|
|
2774
4391
|
infer_dimensions: val.infer_dimensions,
|
|
4392
|
+
max_depth: val.max_depth,
|
|
4393
|
+
exclude_selectors: val.exclude_selectors,
|
|
2775
4394
|
}
|
|
2776
4395
|
}
|
|
2777
4396
|
}
|
|
2778
4397
|
|
|
4398
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2779
4399
|
impl From<html_to_markdown_rs::options::ConversionOptions> for ConversionOptions {
|
|
2780
4400
|
fn from(val: html_to_markdown_rs::options::ConversionOptions) -> Self {
|
|
2781
4401
|
Self {
|
|
@@ -2817,10 +4437,61 @@ impl From<html_to_markdown_rs::options::ConversionOptions> for ConversionOptions
|
|
|
2817
4437
|
max_image_size: val.max_image_size,
|
|
2818
4438
|
capture_svg: val.capture_svg,
|
|
2819
4439
|
infer_dimensions: val.infer_dimensions,
|
|
4440
|
+
max_depth: val.max_depth,
|
|
4441
|
+
exclude_selectors: val.exclude_selectors,
|
|
2820
4442
|
}
|
|
2821
4443
|
}
|
|
2822
4444
|
}
|
|
2823
4445
|
|
|
4446
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
4447
|
+
impl From<ConversionOptionsUpdate> for html_to_markdown_rs::options::ConversionOptionsUpdate {
|
|
4448
|
+
fn from(val: ConversionOptionsUpdate) -> Self {
|
|
4449
|
+
Self {
|
|
4450
|
+
heading_style: val.heading_style.map(Into::into),
|
|
4451
|
+
list_indent_type: val.list_indent_type.map(Into::into),
|
|
4452
|
+
list_indent_width: val.list_indent_width,
|
|
4453
|
+
bullets: val.bullets,
|
|
4454
|
+
strong_em_symbol: val.strong_em_symbol.and_then(|s| s.chars().next()),
|
|
4455
|
+
escape_asterisks: val.escape_asterisks,
|
|
4456
|
+
escape_underscores: val.escape_underscores,
|
|
4457
|
+
escape_misc: val.escape_misc,
|
|
4458
|
+
escape_ascii: val.escape_ascii,
|
|
4459
|
+
code_language: val.code_language,
|
|
4460
|
+
autolinks: val.autolinks,
|
|
4461
|
+
default_title: val.default_title,
|
|
4462
|
+
br_in_tables: val.br_in_tables,
|
|
4463
|
+
highlight_style: val.highlight_style.map(Into::into),
|
|
4464
|
+
extract_metadata: val.extract_metadata,
|
|
4465
|
+
whitespace_mode: val.whitespace_mode.map(Into::into),
|
|
4466
|
+
strip_newlines: val.strip_newlines,
|
|
4467
|
+
wrap: val.wrap,
|
|
4468
|
+
wrap_width: val.wrap_width,
|
|
4469
|
+
convert_as_inline: val.convert_as_inline,
|
|
4470
|
+
sub_symbol: val.sub_symbol,
|
|
4471
|
+
sup_symbol: val.sup_symbol,
|
|
4472
|
+
newline_style: val.newline_style.map(Into::into),
|
|
4473
|
+
code_block_style: val.code_block_style.map(Into::into),
|
|
4474
|
+
keep_inline_images_in: val.keep_inline_images_in,
|
|
4475
|
+
preprocessing: val.preprocessing.map(Into::into),
|
|
4476
|
+
encoding: val.encoding,
|
|
4477
|
+
debug: val.debug,
|
|
4478
|
+
strip_tags: val.strip_tags,
|
|
4479
|
+
preserve_tags: val.preserve_tags,
|
|
4480
|
+
skip_images: val.skip_images,
|
|
4481
|
+
link_style: val.link_style.map(Into::into),
|
|
4482
|
+
output_format: val.output_format.map(Into::into),
|
|
4483
|
+
include_document_structure: val.include_document_structure,
|
|
4484
|
+
extract_images: val.extract_images,
|
|
4485
|
+
max_image_size: val.max_image_size,
|
|
4486
|
+
capture_svg: val.capture_svg,
|
|
4487
|
+
infer_dimensions: val.infer_dimensions,
|
|
4488
|
+
max_depth: (val.max_depth).map(Some),
|
|
4489
|
+
exclude_selectors: val.exclude_selectors,
|
|
4490
|
+
}
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
|
|
4494
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2824
4495
|
impl From<html_to_markdown_rs::options::ConversionOptionsUpdate> for ConversionOptionsUpdate {
|
|
2825
4496
|
fn from(val: html_to_markdown_rs::options::ConversionOptionsUpdate) -> Self {
|
|
2826
4497
|
Self {
|
|
@@ -2862,10 +4533,13 @@ impl From<html_to_markdown_rs::options::ConversionOptionsUpdate> for ConversionO
|
|
|
2862
4533
|
max_image_size: val.max_image_size,
|
|
2863
4534
|
capture_svg: val.capture_svg,
|
|
2864
4535
|
infer_dimensions: val.infer_dimensions,
|
|
4536
|
+
max_depth: val.max_depth.flatten(),
|
|
4537
|
+
exclude_selectors: val.exclude_selectors,
|
|
2865
4538
|
}
|
|
2866
4539
|
}
|
|
2867
4540
|
}
|
|
2868
4541
|
|
|
4542
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2869
4543
|
impl From<PreprocessingOptions> for html_to_markdown_rs::options::PreprocessingOptions {
|
|
2870
4544
|
fn from(val: PreprocessingOptions) -> Self {
|
|
2871
4545
|
Self {
|
|
@@ -2877,6 +4551,7 @@ impl From<PreprocessingOptions> for html_to_markdown_rs::options::PreprocessingO
|
|
|
2877
4551
|
}
|
|
2878
4552
|
}
|
|
2879
4553
|
|
|
4554
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2880
4555
|
impl From<html_to_markdown_rs::options::PreprocessingOptions> for PreprocessingOptions {
|
|
2881
4556
|
fn from(val: html_to_markdown_rs::options::PreprocessingOptions) -> Self {
|
|
2882
4557
|
Self {
|
|
@@ -2888,6 +4563,19 @@ impl From<html_to_markdown_rs::options::PreprocessingOptions> for PreprocessingO
|
|
|
2888
4563
|
}
|
|
2889
4564
|
}
|
|
2890
4565
|
|
|
4566
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
4567
|
+
impl From<PreprocessingOptionsUpdate> for html_to_markdown_rs::options::PreprocessingOptionsUpdate {
|
|
4568
|
+
fn from(val: PreprocessingOptionsUpdate) -> Self {
|
|
4569
|
+
Self {
|
|
4570
|
+
enabled: val.enabled,
|
|
4571
|
+
preset: val.preset.map(Into::into),
|
|
4572
|
+
remove_navigation: val.remove_navigation,
|
|
4573
|
+
remove_forms: val.remove_forms,
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
|
|
4578
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2891
4579
|
impl From<html_to_markdown_rs::options::PreprocessingOptionsUpdate> for PreprocessingOptionsUpdate {
|
|
2892
4580
|
fn from(val: html_to_markdown_rs::options::PreprocessingOptionsUpdate) -> Self {
|
|
2893
4581
|
Self {
|
|
@@ -2899,6 +4587,7 @@ impl From<html_to_markdown_rs::options::PreprocessingOptionsUpdate> for Preproce
|
|
|
2899
4587
|
}
|
|
2900
4588
|
}
|
|
2901
4589
|
|
|
4590
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2902
4591
|
impl From<DocumentStructure> for html_to_markdown_rs::DocumentStructure {
|
|
2903
4592
|
fn from(val: DocumentStructure) -> Self {
|
|
2904
4593
|
Self {
|
|
@@ -2908,6 +4597,7 @@ impl From<DocumentStructure> for html_to_markdown_rs::DocumentStructure {
|
|
|
2908
4597
|
}
|
|
2909
4598
|
}
|
|
2910
4599
|
|
|
4600
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2911
4601
|
impl From<html_to_markdown_rs::DocumentStructure> for DocumentStructure {
|
|
2912
4602
|
fn from(val: html_to_markdown_rs::DocumentStructure) -> Self {
|
|
2913
4603
|
Self {
|
|
@@ -2917,6 +4607,7 @@ impl From<html_to_markdown_rs::DocumentStructure> for DocumentStructure {
|
|
|
2917
4607
|
}
|
|
2918
4608
|
}
|
|
2919
4609
|
|
|
4610
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2920
4611
|
impl From<DocumentNode> for html_to_markdown_rs::DocumentNode {
|
|
2921
4612
|
fn from(val: DocumentNode) -> Self {
|
|
2922
4613
|
Self {
|
|
@@ -2930,6 +4621,7 @@ impl From<DocumentNode> for html_to_markdown_rs::DocumentNode {
|
|
|
2930
4621
|
}
|
|
2931
4622
|
}
|
|
2932
4623
|
|
|
4624
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2933
4625
|
impl From<html_to_markdown_rs::DocumentNode> for DocumentNode {
|
|
2934
4626
|
fn from(val: html_to_markdown_rs::DocumentNode) -> Self {
|
|
2935
4627
|
Self {
|
|
@@ -2943,6 +4635,7 @@ impl From<html_to_markdown_rs::DocumentNode> for DocumentNode {
|
|
|
2943
4635
|
}
|
|
2944
4636
|
}
|
|
2945
4637
|
|
|
4638
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2946
4639
|
impl From<TextAnnotation> for html_to_markdown_rs::TextAnnotation {
|
|
2947
4640
|
fn from(val: TextAnnotation) -> Self {
|
|
2948
4641
|
Self {
|
|
@@ -2953,6 +4646,7 @@ impl From<TextAnnotation> for html_to_markdown_rs::TextAnnotation {
|
|
|
2953
4646
|
}
|
|
2954
4647
|
}
|
|
2955
4648
|
|
|
4649
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2956
4650
|
impl From<html_to_markdown_rs::TextAnnotation> for TextAnnotation {
|
|
2957
4651
|
fn from(val: html_to_markdown_rs::TextAnnotation) -> Self {
|
|
2958
4652
|
Self {
|
|
@@ -2964,6 +4658,7 @@ impl From<html_to_markdown_rs::TextAnnotation> for TextAnnotation {
|
|
|
2964
4658
|
}
|
|
2965
4659
|
|
|
2966
4660
|
#[allow(clippy::needless_update)]
|
|
4661
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2967
4662
|
impl From<ConversionResult> for html_to_markdown_rs::ConversionResult {
|
|
2968
4663
|
fn from(val: ConversionResult) -> Self {
|
|
2969
4664
|
Self {
|
|
@@ -2978,6 +4673,7 @@ impl From<ConversionResult> for html_to_markdown_rs::ConversionResult {
|
|
|
2978
4673
|
}
|
|
2979
4674
|
}
|
|
2980
4675
|
|
|
4676
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2981
4677
|
impl From<html_to_markdown_rs::ConversionResult> for ConversionResult {
|
|
2982
4678
|
fn from(val: html_to_markdown_rs::ConversionResult) -> Self {
|
|
2983
4679
|
Self {
|
|
@@ -2991,6 +4687,7 @@ impl From<html_to_markdown_rs::ConversionResult> for ConversionResult {
|
|
|
2991
4687
|
}
|
|
2992
4688
|
}
|
|
2993
4689
|
|
|
4690
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
2994
4691
|
impl From<TableGrid> for html_to_markdown_rs::TableGrid {
|
|
2995
4692
|
fn from(val: TableGrid) -> Self {
|
|
2996
4693
|
Self {
|
|
@@ -3001,6 +4698,7 @@ impl From<TableGrid> for html_to_markdown_rs::TableGrid {
|
|
|
3001
4698
|
}
|
|
3002
4699
|
}
|
|
3003
4700
|
|
|
4701
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
3004
4702
|
impl From<html_to_markdown_rs::TableGrid> for TableGrid {
|
|
3005
4703
|
fn from(val: html_to_markdown_rs::TableGrid) -> Self {
|
|
3006
4704
|
Self {
|
|
@@ -3011,6 +4709,7 @@ impl From<html_to_markdown_rs::TableGrid> for TableGrid {
|
|
|
3011
4709
|
}
|
|
3012
4710
|
}
|
|
3013
4711
|
|
|
4712
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
3014
4713
|
impl From<GridCell> for html_to_markdown_rs::GridCell {
|
|
3015
4714
|
fn from(val: GridCell) -> Self {
|
|
3016
4715
|
Self {
|
|
@@ -3024,6 +4723,7 @@ impl From<GridCell> for html_to_markdown_rs::GridCell {
|
|
|
3024
4723
|
}
|
|
3025
4724
|
}
|
|
3026
4725
|
|
|
4726
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
3027
4727
|
impl From<html_to_markdown_rs::GridCell> for GridCell {
|
|
3028
4728
|
fn from(val: html_to_markdown_rs::GridCell) -> Self {
|
|
3029
4729
|
Self {
|
|
@@ -3037,6 +4737,7 @@ impl From<html_to_markdown_rs::GridCell> for GridCell {
|
|
|
3037
4737
|
}
|
|
3038
4738
|
}
|
|
3039
4739
|
|
|
4740
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
3040
4741
|
impl From<TableData> for html_to_markdown_rs::TableData {
|
|
3041
4742
|
fn from(val: TableData) -> Self {
|
|
3042
4743
|
Self {
|
|
@@ -3046,6 +4747,7 @@ impl From<TableData> for html_to_markdown_rs::TableData {
|
|
|
3046
4747
|
}
|
|
3047
4748
|
}
|
|
3048
4749
|
|
|
4750
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
3049
4751
|
impl From<html_to_markdown_rs::TableData> for TableData {
|
|
3050
4752
|
fn from(val: html_to_markdown_rs::TableData) -> Self {
|
|
3051
4753
|
Self {
|
|
@@ -3055,6 +4757,7 @@ impl From<html_to_markdown_rs::TableData> for TableData {
|
|
|
3055
4757
|
}
|
|
3056
4758
|
}
|
|
3057
4759
|
|
|
4760
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
3058
4761
|
impl From<ProcessingWarning> for html_to_markdown_rs::ProcessingWarning {
|
|
3059
4762
|
fn from(val: ProcessingWarning) -> Self {
|
|
3060
4763
|
Self {
|
|
@@ -3064,6 +4767,7 @@ impl From<ProcessingWarning> for html_to_markdown_rs::ProcessingWarning {
|
|
|
3064
4767
|
}
|
|
3065
4768
|
}
|
|
3066
4769
|
|
|
4770
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
3067
4771
|
impl From<html_to_markdown_rs::ProcessingWarning> for ProcessingWarning {
|
|
3068
4772
|
fn from(val: html_to_markdown_rs::ProcessingWarning) -> Self {
|
|
3069
4773
|
Self {
|
|
@@ -3073,6 +4777,21 @@ impl From<html_to_markdown_rs::ProcessingWarning> for ProcessingWarning {
|
|
|
3073
4777
|
}
|
|
3074
4778
|
}
|
|
3075
4779
|
|
|
4780
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
4781
|
+
impl From<html_to_markdown_rs::NodeContext> for NodeContext {
|
|
4782
|
+
fn from(val: html_to_markdown_rs::NodeContext) -> Self {
|
|
4783
|
+
Self {
|
|
4784
|
+
node_type: val.node_type.into(),
|
|
4785
|
+
tag_name: val.tag_name,
|
|
4786
|
+
attributes: val.attributes.into_iter().collect(),
|
|
4787
|
+
depth: val.depth,
|
|
4788
|
+
index_in_parent: val.index_in_parent,
|
|
4789
|
+
parent_tag: val.parent_tag,
|
|
4790
|
+
is_inline: val.is_inline,
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4793
|
+
}
|
|
4794
|
+
|
|
3076
4795
|
impl From<TextDirection> for html_to_markdown_rs::metadata::TextDirection {
|
|
3077
4796
|
fn from(val: TextDirection) -> Self {
|
|
3078
4797
|
match val {
|
|
@@ -3358,7 +5077,7 @@ impl From<NodeContent> for html_to_markdown_rs::NodeContent {
|
|
|
3358
5077
|
NodeContent::DefinitionItem { term, definition } => Self::DefinitionItem { term, definition },
|
|
3359
5078
|
NodeContent::RawBlock { format, content } => Self::RawBlock { format, content },
|
|
3360
5079
|
NodeContent::MetadataBlock { entries } => Self::MetadataBlock {
|
|
3361
|
-
entries: serde_json::from_str(
|
|
5080
|
+
entries: entries.iter().filter_map(|s| serde_json::from_str(s).ok()).collect(),
|
|
3362
5081
|
},
|
|
3363
5082
|
NodeContent::Group {
|
|
3364
5083
|
label,
|
|
@@ -3398,7 +5117,7 @@ impl From<html_to_markdown_rs::NodeContent> for NodeContent {
|
|
|
3398
5117
|
}
|
|
3399
5118
|
html_to_markdown_rs::NodeContent::RawBlock { format, content } => Self::RawBlock { format, content },
|
|
3400
5119
|
html_to_markdown_rs::NodeContent::MetadataBlock { entries } => Self::MetadataBlock {
|
|
3401
|
-
entries:
|
|
5120
|
+
entries: entries.iter().map(|i| format!("{:?}", i)).collect(),
|
|
3402
5121
|
},
|
|
3403
5122
|
html_to_markdown_rs::NodeContent::Group {
|
|
3404
5123
|
label,
|
|
@@ -3453,6 +5172,7 @@ impl From<WarningKind> for html_to_markdown_rs::WarningKind {
|
|
|
3453
5172
|
WarningKind::TruncatedInput => Self::TruncatedInput,
|
|
3454
5173
|
WarningKind::MalformedHtml => Self::MalformedHtml,
|
|
3455
5174
|
WarningKind::SanitizationApplied => Self::SanitizationApplied,
|
|
5175
|
+
WarningKind::DepthLimitExceeded => Self::DepthLimitExceeded,
|
|
3456
5176
|
}
|
|
3457
5177
|
}
|
|
3458
5178
|
}
|
|
@@ -3465,6 +5185,114 @@ impl From<html_to_markdown_rs::WarningKind> for WarningKind {
|
|
|
3465
5185
|
html_to_markdown_rs::WarningKind::TruncatedInput => Self::TruncatedInput,
|
|
3466
5186
|
html_to_markdown_rs::WarningKind::MalformedHtml => Self::MalformedHtml,
|
|
3467
5187
|
html_to_markdown_rs::WarningKind::SanitizationApplied => Self::SanitizationApplied,
|
|
5188
|
+
html_to_markdown_rs::WarningKind::DepthLimitExceeded => Self::DepthLimitExceeded,
|
|
5189
|
+
}
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
5192
|
+
|
|
5193
|
+
impl From<html_to_markdown_rs::NodeType> for NodeType {
|
|
5194
|
+
fn from(val: html_to_markdown_rs::NodeType) -> Self {
|
|
5195
|
+
match val {
|
|
5196
|
+
html_to_markdown_rs::NodeType::Text => Self::Text,
|
|
5197
|
+
html_to_markdown_rs::NodeType::Element => Self::Element,
|
|
5198
|
+
html_to_markdown_rs::NodeType::Heading => Self::Heading,
|
|
5199
|
+
html_to_markdown_rs::NodeType::Paragraph => Self::Paragraph,
|
|
5200
|
+
html_to_markdown_rs::NodeType::Div => Self::Div,
|
|
5201
|
+
html_to_markdown_rs::NodeType::Blockquote => Self::Blockquote,
|
|
5202
|
+
html_to_markdown_rs::NodeType::Pre => Self::Pre,
|
|
5203
|
+
html_to_markdown_rs::NodeType::Hr => Self::Hr,
|
|
5204
|
+
html_to_markdown_rs::NodeType::List => Self::List,
|
|
5205
|
+
html_to_markdown_rs::NodeType::ListItem => Self::ListItem,
|
|
5206
|
+
html_to_markdown_rs::NodeType::DefinitionList => Self::DefinitionList,
|
|
5207
|
+
html_to_markdown_rs::NodeType::DefinitionTerm => Self::DefinitionTerm,
|
|
5208
|
+
html_to_markdown_rs::NodeType::DefinitionDescription => Self::DefinitionDescription,
|
|
5209
|
+
html_to_markdown_rs::NodeType::Table => Self::Table,
|
|
5210
|
+
html_to_markdown_rs::NodeType::TableRow => Self::TableRow,
|
|
5211
|
+
html_to_markdown_rs::NodeType::TableCell => Self::TableCell,
|
|
5212
|
+
html_to_markdown_rs::NodeType::TableHeader => Self::TableHeader,
|
|
5213
|
+
html_to_markdown_rs::NodeType::TableBody => Self::TableBody,
|
|
5214
|
+
html_to_markdown_rs::NodeType::TableHead => Self::TableHead,
|
|
5215
|
+
html_to_markdown_rs::NodeType::TableFoot => Self::TableFoot,
|
|
5216
|
+
html_to_markdown_rs::NodeType::Link => Self::Link,
|
|
5217
|
+
html_to_markdown_rs::NodeType::Image => Self::Image,
|
|
5218
|
+
html_to_markdown_rs::NodeType::Strong => Self::Strong,
|
|
5219
|
+
html_to_markdown_rs::NodeType::Em => Self::Em,
|
|
5220
|
+
html_to_markdown_rs::NodeType::Code => Self::Code,
|
|
5221
|
+
html_to_markdown_rs::NodeType::Strikethrough => Self::Strikethrough,
|
|
5222
|
+
html_to_markdown_rs::NodeType::Underline => Self::Underline,
|
|
5223
|
+
html_to_markdown_rs::NodeType::Subscript => Self::Subscript,
|
|
5224
|
+
html_to_markdown_rs::NodeType::Superscript => Self::Superscript,
|
|
5225
|
+
html_to_markdown_rs::NodeType::Mark => Self::Mark,
|
|
5226
|
+
html_to_markdown_rs::NodeType::Small => Self::Small,
|
|
5227
|
+
html_to_markdown_rs::NodeType::Br => Self::Br,
|
|
5228
|
+
html_to_markdown_rs::NodeType::Span => Self::Span,
|
|
5229
|
+
html_to_markdown_rs::NodeType::Article => Self::Article,
|
|
5230
|
+
html_to_markdown_rs::NodeType::Section => Self::Section,
|
|
5231
|
+
html_to_markdown_rs::NodeType::Nav => Self::Nav,
|
|
5232
|
+
html_to_markdown_rs::NodeType::Aside => Self::Aside,
|
|
5233
|
+
html_to_markdown_rs::NodeType::Header => Self::Header,
|
|
5234
|
+
html_to_markdown_rs::NodeType::Footer => Self::Footer,
|
|
5235
|
+
html_to_markdown_rs::NodeType::Main => Self::Main,
|
|
5236
|
+
html_to_markdown_rs::NodeType::Figure => Self::Figure,
|
|
5237
|
+
html_to_markdown_rs::NodeType::Figcaption => Self::Figcaption,
|
|
5238
|
+
html_to_markdown_rs::NodeType::Time => Self::Time,
|
|
5239
|
+
html_to_markdown_rs::NodeType::Details => Self::Details,
|
|
5240
|
+
html_to_markdown_rs::NodeType::Summary => Self::Summary,
|
|
5241
|
+
html_to_markdown_rs::NodeType::Form => Self::Form,
|
|
5242
|
+
html_to_markdown_rs::NodeType::Input => Self::Input,
|
|
5243
|
+
html_to_markdown_rs::NodeType::Select => Self::Select,
|
|
5244
|
+
html_to_markdown_rs::NodeType::Option => Self::Option,
|
|
5245
|
+
html_to_markdown_rs::NodeType::Button => Self::Button,
|
|
5246
|
+
html_to_markdown_rs::NodeType::Textarea => Self::Textarea,
|
|
5247
|
+
html_to_markdown_rs::NodeType::Label => Self::Label,
|
|
5248
|
+
html_to_markdown_rs::NodeType::Fieldset => Self::Fieldset,
|
|
5249
|
+
html_to_markdown_rs::NodeType::Legend => Self::Legend,
|
|
5250
|
+
html_to_markdown_rs::NodeType::Audio => Self::Audio,
|
|
5251
|
+
html_to_markdown_rs::NodeType::Video => Self::Video,
|
|
5252
|
+
html_to_markdown_rs::NodeType::Picture => Self::Picture,
|
|
5253
|
+
html_to_markdown_rs::NodeType::Source => Self::Source,
|
|
5254
|
+
html_to_markdown_rs::NodeType::Iframe => Self::Iframe,
|
|
5255
|
+
html_to_markdown_rs::NodeType::Svg => Self::Svg,
|
|
5256
|
+
html_to_markdown_rs::NodeType::Canvas => Self::Canvas,
|
|
5257
|
+
html_to_markdown_rs::NodeType::Ruby => Self::Ruby,
|
|
5258
|
+
html_to_markdown_rs::NodeType::Rt => Self::Rt,
|
|
5259
|
+
html_to_markdown_rs::NodeType::Rp => Self::Rp,
|
|
5260
|
+
html_to_markdown_rs::NodeType::Abbr => Self::Abbr,
|
|
5261
|
+
html_to_markdown_rs::NodeType::Kbd => Self::Kbd,
|
|
5262
|
+
html_to_markdown_rs::NodeType::Samp => Self::Samp,
|
|
5263
|
+
html_to_markdown_rs::NodeType::Var => Self::Var,
|
|
5264
|
+
html_to_markdown_rs::NodeType::Cite => Self::Cite,
|
|
5265
|
+
html_to_markdown_rs::NodeType::Q => Self::Q,
|
|
5266
|
+
html_to_markdown_rs::NodeType::Del => Self::Del,
|
|
5267
|
+
html_to_markdown_rs::NodeType::Ins => Self::Ins,
|
|
5268
|
+
html_to_markdown_rs::NodeType::Data => Self::Data,
|
|
5269
|
+
html_to_markdown_rs::NodeType::Meter => Self::Meter,
|
|
5270
|
+
html_to_markdown_rs::NodeType::Progress => Self::Progress,
|
|
5271
|
+
html_to_markdown_rs::NodeType::Output => Self::Output,
|
|
5272
|
+
html_to_markdown_rs::NodeType::Template => Self::Template,
|
|
5273
|
+
html_to_markdown_rs::NodeType::Slot => Self::Slot,
|
|
5274
|
+
html_to_markdown_rs::NodeType::Html => Self::Html,
|
|
5275
|
+
html_to_markdown_rs::NodeType::Head => Self::Head,
|
|
5276
|
+
html_to_markdown_rs::NodeType::Body => Self::Body,
|
|
5277
|
+
html_to_markdown_rs::NodeType::Title => Self::Title,
|
|
5278
|
+
html_to_markdown_rs::NodeType::Meta => Self::Meta,
|
|
5279
|
+
html_to_markdown_rs::NodeType::LinkTag => Self::LinkTag,
|
|
5280
|
+
html_to_markdown_rs::NodeType::Style => Self::Style,
|
|
5281
|
+
html_to_markdown_rs::NodeType::Script => Self::Script,
|
|
5282
|
+
html_to_markdown_rs::NodeType::Base => Self::Base,
|
|
5283
|
+
html_to_markdown_rs::NodeType::Custom => Self::Custom,
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
|
|
5288
|
+
impl From<html_to_markdown_rs::VisitResult> for VisitResult {
|
|
5289
|
+
fn from(val: html_to_markdown_rs::VisitResult) -> Self {
|
|
5290
|
+
match val {
|
|
5291
|
+
html_to_markdown_rs::VisitResult::Continue => Self::Continue,
|
|
5292
|
+
html_to_markdown_rs::VisitResult::Custom(_0) => Self::Custom { _0 },
|
|
5293
|
+
html_to_markdown_rs::VisitResult::Skip => Self::Skip,
|
|
5294
|
+
html_to_markdown_rs::VisitResult::PreserveHtml => Self::PreserveHtml,
|
|
5295
|
+
html_to_markdown_rs::VisitResult::Error(_0) => Self::Error { _0 },
|
|
3468
5296
|
}
|
|
3469
5297
|
}
|
|
3470
5298
|
}
|
|
@@ -3480,37 +5308,6 @@ fn conversion_error_to_magnus_err(e: html_to_markdown_rs::error::ConversionError
|
|
|
3480
5308
|
fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
3481
5309
|
let module = ruby.define_module("HtmlToMarkdownRs")?;
|
|
3482
5310
|
|
|
3483
|
-
let class = module.define_class("MetadataConfig", ruby.class_object())?;
|
|
3484
|
-
class.define_singleton_method("new", function!(MetadataConfig::new, 6))?;
|
|
3485
|
-
class.define_method("extract_document", method!(MetadataConfig::extract_document, 0))?;
|
|
3486
|
-
class.define_method("extract_headers", method!(MetadataConfig::extract_headers, 0))?;
|
|
3487
|
-
class.define_method("extract_links", method!(MetadataConfig::extract_links, 0))?;
|
|
3488
|
-
class.define_method("extract_images", method!(MetadataConfig::extract_images, 0))?;
|
|
3489
|
-
class.define_method(
|
|
3490
|
-
"extract_structured_data",
|
|
3491
|
-
method!(MetadataConfig::extract_structured_data, 0),
|
|
3492
|
-
)?;
|
|
3493
|
-
class.define_method(
|
|
3494
|
-
"max_structured_data_size",
|
|
3495
|
-
method!(MetadataConfig::max_structured_data_size, 0),
|
|
3496
|
-
)?;
|
|
3497
|
-
class.define_method("any_enabled", method!(MetadataConfig::any_enabled, 0))?;
|
|
3498
|
-
|
|
3499
|
-
let class = module.define_class("MetadataConfigUpdate", ruby.class_object())?;
|
|
3500
|
-
class.define_singleton_method("new", function!(MetadataConfigUpdate::new, 6))?;
|
|
3501
|
-
class.define_method("extract_document", method!(MetadataConfigUpdate::extract_document, 0))?;
|
|
3502
|
-
class.define_method("extract_headers", method!(MetadataConfigUpdate::extract_headers, 0))?;
|
|
3503
|
-
class.define_method("extract_links", method!(MetadataConfigUpdate::extract_links, 0))?;
|
|
3504
|
-
class.define_method("extract_images", method!(MetadataConfigUpdate::extract_images, 0))?;
|
|
3505
|
-
class.define_method(
|
|
3506
|
-
"extract_structured_data",
|
|
3507
|
-
method!(MetadataConfigUpdate::extract_structured_data, 0),
|
|
3508
|
-
)?;
|
|
3509
|
-
class.define_method(
|
|
3510
|
-
"max_structured_data_size",
|
|
3511
|
-
method!(MetadataConfigUpdate::max_structured_data_size, 0),
|
|
3512
|
-
)?;
|
|
3513
|
-
|
|
3514
5311
|
let class = module.define_class("DocumentMetadata", ruby.class_object())?;
|
|
3515
5312
|
class.define_singleton_method("new", function!(DocumentMetadata::new, 11))?;
|
|
3516
5313
|
class.define_method("title", method!(DocumentMetadata::title, 0))?;
|
|
@@ -3612,6 +5409,9 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
3612
5409
|
class.define_method("max_image_size", method!(ConversionOptions::max_image_size, 0))?;
|
|
3613
5410
|
class.define_method("capture_svg", method!(ConversionOptions::capture_svg, 0))?;
|
|
3614
5411
|
class.define_method("infer_dimensions", method!(ConversionOptions::infer_dimensions, 0))?;
|
|
5412
|
+
class.define_method("max_depth", method!(ConversionOptions::max_depth, 0))?;
|
|
5413
|
+
class.define_method("exclude_selectors", method!(ConversionOptions::exclude_selectors, 0))?;
|
|
5414
|
+
class.define_method("apply_update", method!(ConversionOptions::apply_update, 1))?;
|
|
3615
5415
|
|
|
3616
5416
|
let class = module.define_class("ConversionOptionsBuilder", ruby.class_object())?;
|
|
3617
5417
|
class.define_method("strip_tags", method!(ConversionOptionsBuilder::strip_tags, 1))?;
|
|
@@ -3620,6 +5420,10 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
3620
5420
|
"keep_inline_images_in",
|
|
3621
5421
|
method!(ConversionOptionsBuilder::keep_inline_images_in, 1),
|
|
3622
5422
|
)?;
|
|
5423
|
+
class.define_method(
|
|
5424
|
+
"exclude_selectors",
|
|
5425
|
+
method!(ConversionOptionsBuilder::exclude_selectors, 1),
|
|
5426
|
+
)?;
|
|
3623
5427
|
class.define_method("preprocessing", method!(ConversionOptionsBuilder::preprocessing, 1))?;
|
|
3624
5428
|
class.define_method("build", method!(ConversionOptionsBuilder::build, 0))?;
|
|
3625
5429
|
|
|
@@ -3696,6 +5500,11 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
3696
5500
|
"infer_dimensions",
|
|
3697
5501
|
method!(ConversionOptionsUpdate::infer_dimensions, 0),
|
|
3698
5502
|
)?;
|
|
5503
|
+
class.define_method("max_depth", method!(ConversionOptionsUpdate::max_depth, 0))?;
|
|
5504
|
+
class.define_method(
|
|
5505
|
+
"exclude_selectors",
|
|
5506
|
+
method!(ConversionOptionsUpdate::exclude_selectors, 0),
|
|
5507
|
+
)?;
|
|
3699
5508
|
|
|
3700
5509
|
let class = module.define_class("PreprocessingOptions", ruby.class_object())?;
|
|
3701
5510
|
class.define_singleton_method("new", function!(PreprocessingOptions::new, 4))?;
|
|
@@ -3703,6 +5512,7 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
3703
5512
|
class.define_method("preset", method!(PreprocessingOptions::preset, 0))?;
|
|
3704
5513
|
class.define_method("remove_navigation", method!(PreprocessingOptions::remove_navigation, 0))?;
|
|
3705
5514
|
class.define_method("remove_forms", method!(PreprocessingOptions::remove_forms, 0))?;
|
|
5515
|
+
class.define_method("apply_update", method!(PreprocessingOptions::apply_update, 1))?;
|
|
3706
5516
|
|
|
3707
5517
|
let class = module.define_class("PreprocessingOptionsUpdate", ruby.class_object())?;
|
|
3708
5518
|
class.define_singleton_method("new", function!(PreprocessingOptionsUpdate::new, 4))?;
|
|
@@ -3768,7 +5578,17 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
3768
5578
|
class.define_method("message", method!(ProcessingWarning::message, 0))?;
|
|
3769
5579
|
class.define_method("kind", method!(ProcessingWarning::kind, 0))?;
|
|
3770
5580
|
|
|
3771
|
-
module.
|
|
5581
|
+
let class = module.define_class("NodeContext", ruby.class_object())?;
|
|
5582
|
+
class.define_singleton_method("new", function!(NodeContext::new, 7))?;
|
|
5583
|
+
class.define_method("node_type", method!(NodeContext::node_type, 0))?;
|
|
5584
|
+
class.define_method("tag_name", method!(NodeContext::tag_name, 0))?;
|
|
5585
|
+
class.define_method("attributes", method!(NodeContext::attributes, 0))?;
|
|
5586
|
+
class.define_method("depth", method!(NodeContext::depth, 0))?;
|
|
5587
|
+
class.define_method("index_in_parent", method!(NodeContext::index_in_parent, 0))?;
|
|
5588
|
+
class.define_method("parent_tag", method!(NodeContext::parent_tag, 0))?;
|
|
5589
|
+
class.define_method("is_inline", method!(NodeContext::is_inline, 0))?;
|
|
5590
|
+
|
|
5591
|
+
module.define_module_function("convert", function!(convert, 3))?;
|
|
3772
5592
|
|
|
3773
5593
|
Ok(())
|
|
3774
5594
|
}
|