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