html-to-markdown 3.14.3 → 3.15.0

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.
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated by alef. DO NOT EDIT.
2
- // alef:hash:b89f28165748578716b78d7870c438b5394d9c847ec7718f9620057ca8fb0688
2
+ // alef:hash:adcf6160cdf7035806744fc3efe8b3116ce330a5c164ade234e6c2fe49fbe748
3
3
  // Re-generate with: alef generate
4
4
  #![allow(dead_code, unused_imports, unused_variables)]
5
5
  #![allow(
@@ -105,6 +105,7 @@ pub struct ConversionOptions {
105
105
  max_depth: Option<usize>,
106
106
  exclude_selectors: Vec<String>,
107
107
  tier_strategy: TierStrategy,
108
+ base_url: Option<String>,
108
109
  }
109
110
 
110
111
  unsafe impl IntoValueFromNative for ConversionOptions {}
@@ -535,6 +536,15 @@ impl ConversionOptions {
535
536
  })?,
536
537
  None => TierStrategy::Auto,
537
538
  },
539
+ base_url: match kwargs.get(ruby.to_symbol("base_url")).filter(|v| !v.is_nil()) {
540
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
541
+ magnus::Error::new(
542
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
543
+ format!("invalid value for `base_url`: {}", e),
544
+ )
545
+ })?),
546
+ None => None,
547
+ },
538
548
  })
539
549
  }
540
550
 
@@ -709,6 +719,10 @@ impl ConversionOptions {
709
719
  fn tier_strategy(&self) -> TierStrategy {
710
720
  self.tier_strategy.clone()
711
721
  }
722
+
723
+ fn base_url(&self) -> Option<String> {
724
+ self.base_url.clone()
725
+ }
712
726
  }
713
727
 
714
728
  #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
@@ -758,6 +772,7 @@ pub struct ConversionOptionsUpdate {
758
772
  max_depth: Option<usize>,
759
773
  exclude_selectors: Option<Vec<String>>,
760
774
  tier_strategy: Option<TierStrategy>,
775
+ base_url: Option<String>,
761
776
  }
762
777
 
763
778
  unsafe impl IntoValueFromNative for ConversionOptionsUpdate {}
@@ -1194,6 +1209,15 @@ impl ConversionOptionsUpdate {
1194
1209
  })?),
1195
1210
  None => None,
1196
1211
  },
1212
+ base_url: match kwargs.get(ruby.to_symbol("base_url")).filter(|v| !v.is_nil()) {
1213
+ Some(v) => Some(String::try_convert(v).map_err(|e| {
1214
+ magnus::Error::new(
1215
+ unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
1216
+ format!("invalid value for `base_url`: {}", e),
1217
+ )
1218
+ })?),
1219
+ None => None,
1220
+ },
1197
1221
  })
1198
1222
  }
1199
1223
 
@@ -1368,6 +1392,10 @@ impl ConversionOptionsUpdate {
1368
1392
  fn tier_strategy(&self) -> Option<TierStrategy> {
1369
1393
  self.tier_strategy.clone()
1370
1394
  }
1395
+
1396
+ fn base_url(&self) -> Option<String> {
1397
+ self.base_url.clone()
1398
+ }
1371
1399
  }
1372
1400
 
1373
1401
  #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
@@ -3642,7 +3670,8 @@ impl magnus::IntoValue for AnnotationKind {
3642
3670
 
3643
3671
  impl magnus::TryConvert for AnnotationKind {
3644
3672
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
3645
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
3673
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
3674
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
3646
3675
  // For unit enums or when passed as a string, fall back to string-based conversion.
3647
3676
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
3648
3677
  s
@@ -3674,9 +3703,10 @@ impl magnus::TryConvert for AnnotationKind {
3674
3703
 
3675
3704
  unsafe impl IntoValueFromNative for AnnotationKind {}
3676
3705
  unsafe impl TryConvertOwned for AnnotationKind {}
3706
+
3677
3707
  impl AnnotationKind {}
3678
3708
 
3679
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
3709
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
3680
3710
  pub enum CodeBlockStyle {
3681
3711
  Indented,
3682
3712
  Backticks,
@@ -3702,7 +3732,14 @@ impl magnus::IntoValue for CodeBlockStyle {
3702
3732
 
3703
3733
  impl magnus::TryConvert for CodeBlockStyle {
3704
3734
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
3705
- let s: String = magnus::TryConvert::try_convert(val)?;
3735
+ // IntoValue emits Symbols, including when this enum is a Hash key.
3736
+ // Accept that exact representation as well as String inputs; do not
3737
+ // coerce arbitrary objects through to_s.
3738
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
3739
+ symbol.name()?.into_owned()
3740
+ } else {
3741
+ magnus::TryConvert::try_convert(val)?
3742
+ };
3706
3743
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
3707
3744
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
3708
3745
  // existing consumer code written in any of those styles keep working.
@@ -3721,7 +3758,7 @@ impl magnus::TryConvert for CodeBlockStyle {
3721
3758
  unsafe impl IntoValueFromNative for CodeBlockStyle {}
3722
3759
  unsafe impl TryConvertOwned for CodeBlockStyle {}
3723
3760
 
3724
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
3761
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
3725
3762
  pub enum HeadingStyle {
3726
3763
  Underlined,
3727
3764
  Atx,
@@ -3747,7 +3784,14 @@ impl magnus::IntoValue for HeadingStyle {
3747
3784
 
3748
3785
  impl magnus::TryConvert for HeadingStyle {
3749
3786
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
3750
- let s: String = magnus::TryConvert::try_convert(val)?;
3787
+ // IntoValue emits Symbols, including when this enum is a Hash key.
3788
+ // Accept that exact representation as well as String inputs; do not
3789
+ // coerce arbitrary objects through to_s.
3790
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
3791
+ symbol.name()?.into_owned()
3792
+ } else {
3793
+ magnus::TryConvert::try_convert(val)?
3794
+ };
3751
3795
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
3752
3796
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
3753
3797
  // existing consumer code written in any of those styles keep working.
@@ -3766,7 +3810,7 @@ impl magnus::TryConvert for HeadingStyle {
3766
3810
  unsafe impl IntoValueFromNative for HeadingStyle {}
3767
3811
  unsafe impl TryConvertOwned for HeadingStyle {}
3768
3812
 
3769
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
3813
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
3770
3814
  pub enum HighlightStyle {
3771
3815
  DoubleEqual,
3772
3816
  Html,
@@ -3794,7 +3838,14 @@ impl magnus::IntoValue for HighlightStyle {
3794
3838
 
3795
3839
  impl magnus::TryConvert for HighlightStyle {
3796
3840
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
3797
- let s: String = magnus::TryConvert::try_convert(val)?;
3841
+ // IntoValue emits Symbols, including when this enum is a Hash key.
3842
+ // Accept that exact representation as well as String inputs; do not
3843
+ // coerce arbitrary objects through to_s.
3844
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
3845
+ symbol.name()?.into_owned()
3846
+ } else {
3847
+ magnus::TryConvert::try_convert(val)?
3848
+ };
3798
3849
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
3799
3850
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
3800
3851
  // existing consumer code written in any of those styles keep working.
@@ -3814,7 +3865,7 @@ impl magnus::TryConvert for HighlightStyle {
3814
3865
  unsafe impl IntoValueFromNative for HighlightStyle {}
3815
3866
  unsafe impl TryConvertOwned for HighlightStyle {}
3816
3867
 
3817
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
3868
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
3818
3869
  #[serde(rename_all = "snake_case")]
3819
3870
  pub enum ImageType {
3820
3871
  DataUri,
@@ -3843,7 +3894,14 @@ impl magnus::IntoValue for ImageType {
3843
3894
 
3844
3895
  impl magnus::TryConvert for ImageType {
3845
3896
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
3846
- let s: String = magnus::TryConvert::try_convert(val)?;
3897
+ // IntoValue emits Symbols, including when this enum is a Hash key.
3898
+ // Accept that exact representation as well as String inputs; do not
3899
+ // coerce arbitrary objects through to_s.
3900
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
3901
+ symbol.name()?.into_owned()
3902
+ } else {
3903
+ magnus::TryConvert::try_convert(val)?
3904
+ };
3847
3905
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
3848
3906
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
3849
3907
  // existing consumer code written in any of those styles keep working.
@@ -3863,7 +3921,7 @@ impl magnus::TryConvert for ImageType {
3863
3921
  unsafe impl IntoValueFromNative for ImageType {}
3864
3922
  unsafe impl TryConvertOwned for ImageType {}
3865
3923
 
3866
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
3924
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
3867
3925
  pub enum LinkStyle {
3868
3926
  Inline,
3869
3927
  Reference,
@@ -3887,7 +3945,14 @@ impl magnus::IntoValue for LinkStyle {
3887
3945
 
3888
3946
  impl magnus::TryConvert for LinkStyle {
3889
3947
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
3890
- let s: String = magnus::TryConvert::try_convert(val)?;
3948
+ // IntoValue emits Symbols, including when this enum is a Hash key.
3949
+ // Accept that exact representation as well as String inputs; do not
3950
+ // coerce arbitrary objects through to_s.
3951
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
3952
+ symbol.name()?.into_owned()
3953
+ } else {
3954
+ magnus::TryConvert::try_convert(val)?
3955
+ };
3891
3956
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
3892
3957
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
3893
3958
  // existing consumer code written in any of those styles keep working.
@@ -3905,7 +3970,7 @@ impl magnus::TryConvert for LinkStyle {
3905
3970
  unsafe impl IntoValueFromNative for LinkStyle {}
3906
3971
  unsafe impl TryConvertOwned for LinkStyle {}
3907
3972
 
3908
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
3973
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
3909
3974
  #[serde(rename_all = "snake_case")]
3910
3975
  pub enum LinkType {
3911
3976
  Anchor,
@@ -3938,7 +4003,14 @@ impl magnus::IntoValue for LinkType {
3938
4003
 
3939
4004
  impl magnus::TryConvert for LinkType {
3940
4005
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
3941
- let s: String = magnus::TryConvert::try_convert(val)?;
4006
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4007
+ // Accept that exact representation as well as String inputs; do not
4008
+ // coerce arbitrary objects through to_s.
4009
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4010
+ symbol.name()?.into_owned()
4011
+ } else {
4012
+ magnus::TryConvert::try_convert(val)?
4013
+ };
3942
4014
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
3943
4015
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
3944
4016
  // existing consumer code written in any of those styles keep working.
@@ -3960,7 +4032,7 @@ impl magnus::TryConvert for LinkType {
3960
4032
  unsafe impl IntoValueFromNative for LinkType {}
3961
4033
  unsafe impl TryConvertOwned for LinkType {}
3962
4034
 
3963
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4035
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
3964
4036
  pub enum ListIndentType {
3965
4037
  Spaces,
3966
4038
  Tabs,
@@ -3984,7 +4056,14 @@ impl magnus::IntoValue for ListIndentType {
3984
4056
 
3985
4057
  impl magnus::TryConvert for ListIndentType {
3986
4058
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
3987
- let s: String = magnus::TryConvert::try_convert(val)?;
4059
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4060
+ // Accept that exact representation as well as String inputs; do not
4061
+ // coerce arbitrary objects through to_s.
4062
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4063
+ symbol.name()?.into_owned()
4064
+ } else {
4065
+ magnus::TryConvert::try_convert(val)?
4066
+ };
3988
4067
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
3989
4068
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
3990
4069
  // existing consumer code written in any of those styles keep working.
@@ -4002,7 +4081,7 @@ impl magnus::TryConvert for ListIndentType {
4002
4081
  unsafe impl IntoValueFromNative for ListIndentType {}
4003
4082
  unsafe impl TryConvertOwned for ListIndentType {}
4004
4083
 
4005
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4084
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4006
4085
  pub enum NewlineStyle {
4007
4086
  Spaces,
4008
4087
  Backslash,
@@ -4026,7 +4105,14 @@ impl magnus::IntoValue for NewlineStyle {
4026
4105
 
4027
4106
  impl magnus::TryConvert for NewlineStyle {
4028
4107
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4029
- let s: String = magnus::TryConvert::try_convert(val)?;
4108
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4109
+ // Accept that exact representation as well as String inputs; do not
4110
+ // coerce arbitrary objects through to_s.
4111
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4112
+ symbol.name()?.into_owned()
4113
+ } else {
4114
+ magnus::TryConvert::try_convert(val)?
4115
+ };
4030
4116
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4031
4117
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4032
4118
  // existing consumer code written in any of those styles keep working.
@@ -4113,7 +4199,8 @@ impl magnus::IntoValue for NodeContent {
4113
4199
 
4114
4200
  impl magnus::TryConvert for NodeContent {
4115
4201
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4116
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
4202
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
4203
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
4117
4204
  // For unit enums or when passed as a string, fall back to string-based conversion.
4118
4205
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
4119
4206
  s
@@ -4145,9 +4232,10 @@ impl magnus::TryConvert for NodeContent {
4145
4232
 
4146
4233
  unsafe impl IntoValueFromNative for NodeContent {}
4147
4234
  unsafe impl TryConvertOwned for NodeContent {}
4235
+
4148
4236
  impl NodeContent {}
4149
4237
 
4150
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4238
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4151
4239
  pub enum NodeType {
4152
4240
  Text,
4153
4241
  Element,
@@ -4343,7 +4431,14 @@ impl magnus::IntoValue for NodeType {
4343
4431
 
4344
4432
  impl magnus::TryConvert for NodeType {
4345
4433
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4346
- let s: String = magnus::TryConvert::try_convert(val)?;
4434
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4435
+ // Accept that exact representation as well as String inputs; do not
4436
+ // coerce arbitrary objects through to_s.
4437
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4438
+ symbol.name()?.into_owned()
4439
+ } else {
4440
+ magnus::TryConvert::try_convert(val)?
4441
+ };
4347
4442
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4348
4443
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4349
4444
  // existing consumer code written in any of those styles keep working.
@@ -4447,7 +4542,7 @@ impl magnus::TryConvert for NodeType {
4447
4542
  unsafe impl IntoValueFromNative for NodeType {}
4448
4543
  unsafe impl TryConvertOwned for NodeType {}
4449
4544
 
4450
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4545
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4451
4546
  pub enum OutputFormat {
4452
4547
  Markdown,
4453
4548
  Djot,
@@ -4473,7 +4568,14 @@ impl magnus::IntoValue for OutputFormat {
4473
4568
 
4474
4569
  impl magnus::TryConvert for OutputFormat {
4475
4570
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4476
- let s: String = magnus::TryConvert::try_convert(val)?;
4571
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4572
+ // Accept that exact representation as well as String inputs; do not
4573
+ // coerce arbitrary objects through to_s.
4574
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4575
+ symbol.name()?.into_owned()
4576
+ } else {
4577
+ magnus::TryConvert::try_convert(val)?
4578
+ };
4477
4579
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4478
4580
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4479
4581
  // existing consumer code written in any of those styles keep working.
@@ -4492,7 +4594,7 @@ impl magnus::TryConvert for OutputFormat {
4492
4594
  unsafe impl IntoValueFromNative for OutputFormat {}
4493
4595
  unsafe impl TryConvertOwned for OutputFormat {}
4494
4596
 
4495
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4597
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4496
4598
  pub enum PreprocessingPreset {
4497
4599
  Minimal,
4498
4600
  Standard,
@@ -4518,7 +4620,14 @@ impl magnus::IntoValue for PreprocessingPreset {
4518
4620
 
4519
4621
  impl magnus::TryConvert for PreprocessingPreset {
4520
4622
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4521
- let s: String = magnus::TryConvert::try_convert(val)?;
4623
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4624
+ // Accept that exact representation as well as String inputs; do not
4625
+ // coerce arbitrary objects through to_s.
4626
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4627
+ symbol.name()?.into_owned()
4628
+ } else {
4629
+ magnus::TryConvert::try_convert(val)?
4630
+ };
4522
4631
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4523
4632
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4524
4633
  // existing consumer code written in any of those styles keep working.
@@ -4537,7 +4646,7 @@ impl magnus::TryConvert for PreprocessingPreset {
4537
4646
  unsafe impl IntoValueFromNative for PreprocessingPreset {}
4538
4647
  unsafe impl TryConvertOwned for PreprocessingPreset {}
4539
4648
 
4540
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4649
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4541
4650
  #[serde(rename_all = "snake_case")]
4542
4651
  pub enum StructuredDataType {
4543
4652
  #[serde(rename = "json_ld")]
@@ -4566,7 +4675,14 @@ impl magnus::IntoValue for StructuredDataType {
4566
4675
 
4567
4676
  impl magnus::TryConvert for StructuredDataType {
4568
4677
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4569
- let s: String = magnus::TryConvert::try_convert(val)?;
4678
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4679
+ // Accept that exact representation as well as String inputs; do not
4680
+ // coerce arbitrary objects through to_s.
4681
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4682
+ symbol.name()?.into_owned()
4683
+ } else {
4684
+ magnus::TryConvert::try_convert(val)?
4685
+ };
4570
4686
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4571
4687
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4572
4688
  // existing consumer code written in any of those styles keep working.
@@ -4585,7 +4701,7 @@ impl magnus::TryConvert for StructuredDataType {
4585
4701
  unsafe impl IntoValueFromNative for StructuredDataType {}
4586
4702
  unsafe impl TryConvertOwned for StructuredDataType {}
4587
4703
 
4588
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4704
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4589
4705
  pub enum TextDirection {
4590
4706
  #[serde(rename = "ltr")]
4591
4707
  LeftToRight,
@@ -4614,7 +4730,14 @@ impl magnus::IntoValue for TextDirection {
4614
4730
 
4615
4731
  impl magnus::TryConvert for TextDirection {
4616
4732
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4617
- let s: String = magnus::TryConvert::try_convert(val)?;
4733
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4734
+ // Accept that exact representation as well as String inputs; do not
4735
+ // coerce arbitrary objects through to_s.
4736
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4737
+ symbol.name()?.into_owned()
4738
+ } else {
4739
+ magnus::TryConvert::try_convert(val)?
4740
+ };
4618
4741
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4619
4742
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4620
4743
  // existing consumer code written in any of those styles keep working.
@@ -4633,7 +4756,7 @@ impl magnus::TryConvert for TextDirection {
4633
4756
  unsafe impl IntoValueFromNative for TextDirection {}
4634
4757
  unsafe impl TryConvertOwned for TextDirection {}
4635
4758
 
4636
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4759
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4637
4760
  #[serde(rename_all = "snake_case")]
4638
4761
  pub enum TierStrategy {
4639
4762
  Auto,
@@ -4660,7 +4783,14 @@ impl magnus::IntoValue for TierStrategy {
4660
4783
 
4661
4784
  impl magnus::TryConvert for TierStrategy {
4662
4785
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4663
- let s: String = magnus::TryConvert::try_convert(val)?;
4786
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4787
+ // Accept that exact representation as well as String inputs; do not
4788
+ // coerce arbitrary objects through to_s.
4789
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4790
+ symbol.name()?.into_owned()
4791
+ } else {
4792
+ magnus::TryConvert::try_convert(val)?
4793
+ };
4664
4794
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4665
4795
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4666
4796
  // existing consumer code written in any of those styles keep working.
@@ -4679,7 +4809,7 @@ impl magnus::TryConvert for TierStrategy {
4679
4809
  unsafe impl IntoValueFromNative for TierStrategy {}
4680
4810
  unsafe impl TryConvertOwned for TierStrategy {}
4681
4811
 
4682
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4812
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4683
4813
  pub enum UrlEscapeStyle {
4684
4814
  Angle,
4685
4815
  Percent,
@@ -4703,7 +4833,14 @@ impl magnus::IntoValue for UrlEscapeStyle {
4703
4833
 
4704
4834
  impl magnus::TryConvert for UrlEscapeStyle {
4705
4835
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4706
- let s: String = magnus::TryConvert::try_convert(val)?;
4836
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4837
+ // Accept that exact representation as well as String inputs; do not
4838
+ // coerce arbitrary objects through to_s.
4839
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4840
+ symbol.name()?.into_owned()
4841
+ } else {
4842
+ magnus::TryConvert::try_convert(val)?
4843
+ };
4707
4844
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4708
4845
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4709
4846
  // existing consumer code written in any of those styles keep working.
@@ -4749,7 +4886,8 @@ impl magnus::IntoValue for VisitResult {
4749
4886
 
4750
4887
  impl magnus::TryConvert for VisitResult {
4751
4888
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4752
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
4889
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
4890
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
4753
4891
  // For unit enums or when passed as a string, fall back to string-based conversion.
4754
4892
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
4755
4893
  s
@@ -4781,6 +4919,7 @@ impl magnus::TryConvert for VisitResult {
4781
4919
 
4782
4920
  unsafe impl IntoValueFromNative for VisitResult {}
4783
4921
  unsafe impl TryConvertOwned for VisitResult {}
4922
+
4784
4923
  impl VisitResult {
4785
4924
  pub fn custom(&self) -> Option<&String> {
4786
4925
  match self {
@@ -4796,7 +4935,7 @@ impl VisitResult {
4796
4935
  }
4797
4936
  }
4798
4937
 
4799
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
4938
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4800
4939
  #[serde(rename_all = "snake_case")]
4801
4940
  pub enum WarningKind {
4802
4941
  ImageExtractionFailed,
@@ -4829,7 +4968,14 @@ impl magnus::IntoValue for WarningKind {
4829
4968
 
4830
4969
  impl magnus::TryConvert for WarningKind {
4831
4970
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4832
- let s: String = magnus::TryConvert::try_convert(val)?;
4971
+ // IntoValue emits Symbols, including when this enum is a Hash key.
4972
+ // Accept that exact representation as well as String inputs; do not
4973
+ // coerce arbitrary objects through to_s.
4974
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
4975
+ symbol.name()?.into_owned()
4976
+ } else {
4977
+ magnus::TryConvert::try_convert(val)?
4978
+ };
4833
4979
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4834
4980
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4835
4981
  // existing consumer code written in any of those styles keep working.
@@ -4851,7 +4997,7 @@ impl magnus::TryConvert for WarningKind {
4851
4997
  unsafe impl IntoValueFromNative for WarningKind {}
4852
4998
  unsafe impl TryConvertOwned for WarningKind {}
4853
4999
 
4854
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
5000
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
4855
5001
  pub enum WhitespaceMode {
4856
5002
  Normalized,
4857
5003
  Strict,
@@ -4875,7 +5021,14 @@ impl magnus::IntoValue for WhitespaceMode {
4875
5021
 
4876
5022
  impl magnus::TryConvert for WhitespaceMode {
4877
5023
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4878
- let s: String = magnus::TryConvert::try_convert(val)?;
5024
+ // IntoValue emits Symbols, including when this enum is a Hash key.
5025
+ // Accept that exact representation as well as String inputs; do not
5026
+ // coerce arbitrary objects through to_s.
5027
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
5028
+ symbol.name()?.into_owned()
5029
+ } else {
5030
+ magnus::TryConvert::try_convert(val)?
5031
+ };
4879
5032
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
4880
5033
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
4881
5034
  // existing consumer code written in any of those styles keep working.
@@ -6675,12 +6828,13 @@ impl From<ConversionOptions> for html_to_markdown_rs::options::ConversionOptions
6675
6828
  max_depth: val.max_depth,
6676
6829
  exclude_selectors: val.exclude_selectors.into_iter().collect(),
6677
6830
  tier_strategy: val.tier_strategy.into(),
6831
+ base_url: val.base_url,
6678
6832
  ..Default::default()
6679
6833
  }
6680
6834
  }
6681
6835
  }
6682
6836
 
6683
- #[allow(clippy::useless_conversion)]
6837
+ #[allow(clippy::redundant_closure, clippy::useless_conversion)]
6684
6838
  impl From<html_to_markdown_rs::options::ConversionOptions> for ConversionOptions {
6685
6839
  fn from(val: html_to_markdown_rs::options::ConversionOptions) -> Self {
6686
6840
  Self {
@@ -6727,6 +6881,7 @@ impl From<html_to_markdown_rs::options::ConversionOptions> for ConversionOptions
6727
6881
  max_depth: val.max_depth,
6728
6882
  exclude_selectors: val.exclude_selectors.into_iter().collect(),
6729
6883
  tier_strategy: val.tier_strategy.into(),
6884
+ base_url: val.base_url.map(|v| v.to_string()),
6730
6885
  }
6731
6886
  }
6732
6887
  }
@@ -6778,6 +6933,7 @@ impl From<html_to_markdown_rs::options::ConversionOptionsUpdate> for ConversionO
6778
6933
  max_depth: val.max_depth.flatten(),
6779
6934
  exclude_selectors: val.exclude_selectors.map(|v| v.into_iter().collect()),
6780
6935
  tier_strategy: val.tier_strategy.map(Into::into),
6936
+ base_url: val.base_url.flatten().map(|v| v.to_string()),
6781
6937
  }
6782
6938
  }
6783
6939
  }
@@ -7889,6 +8045,19 @@ impl From<html_to_markdown_rs::options::UrlEscapeStyle> for UrlEscapeStyle {
7889
8045
  }
7890
8046
  }
7891
8047
 
8048
+ #[cfg(feature = "visitor")]
8049
+ impl From<VisitResult> for html_to_markdown_rs::VisitResult {
8050
+ fn from(val: VisitResult) -> Self {
8051
+ match val {
8052
+ VisitResult::Continue => Self::Continue,
8053
+ VisitResult::Custom(_0) => Self::Custom(_0),
8054
+ VisitResult::Skip => Self::Skip,
8055
+ VisitResult::PreserveHtml => Self::PreserveHtml,
8056
+ VisitResult::Error(_0) => Self::Error(_0),
8057
+ }
8058
+ }
8059
+ }
8060
+
7892
8061
  #[cfg(feature = "visitor")]
7893
8062
  impl From<html_to_markdown_rs::VisitResult> for VisitResult {
7894
8063
  fn from(val: html_to_markdown_rs::VisitResult) -> Self {
@@ -8056,6 +8225,8 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
8056
8225
 
8057
8226
  class.define_method("tier_strategy", method!(ConversionOptions::tier_strategy, 0))?;
8058
8227
 
8228
+ class.define_method("base_url", method!(ConversionOptions::base_url, 0))?;
8229
+
8059
8230
  let class = module.define_class("ConversionOptionsUpdate", ruby.class_object())?;
8060
8231
 
8061
8232
  class.define_singleton_method("new", function!(ConversionOptionsUpdate::new, -1))?;
@@ -8185,6 +8356,8 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
8185
8356
 
8186
8357
  class.define_method("tier_strategy", method!(ConversionOptionsUpdate::tier_strategy, 0))?;
8187
8358
 
8359
+ class.define_method("base_url", method!(ConversionOptionsUpdate::base_url, 0))?;
8360
+
8188
8361
  let class = module.define_class("ConversionResult", ruby.class_object())?;
8189
8362
 
8190
8363
  class.define_singleton_method("new", function!(ConversionResult::new, -1))?;