commonmarker 2.8.1 → 2.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efc158460a8c17d141cc58e3d71a486822c4f39bac2b5b841fa81e3b13b5a6de
4
- data.tar.gz: 1f5f719a27463327633f998b1dfda7a5f6e71d04808590f1118f8c98e7883591
3
+ metadata.gz: 19a56463af3eab1d8eaaf826922ef056e82bac12c681e79d4072c5df48b00799
4
+ data.tar.gz: 5a9fa46b145eb9839f19511e1bbd8c7ad80e36a8d9450302ea717bfbc1acece3
5
5
  SHA512:
6
- metadata.gz: 652acc6dc51a950f168e861c5cf467953720c5559d78f5dacb407c741bf49d93b8db083dc7323a1580d25e6764585a52d4fb0285cd6ccd973dd651a5299195ad
7
- data.tar.gz: afff28e5195708beb64beab601f1f88772053565d69d8ba3960f24d09feba8cf68b1f58d31f9be202e15fd13e54117264e91e548ba12111c10c3eda10fc19926
6
+ metadata.gz: 3f6defcf19681e9cd13c55a923017dcd9dc6cdf6187309cd67af3e2a6d833de436738ac933ee156e7f61818efaabffdbf6b137696fd3e4b42ea9ca074a1d8d03
7
+ data.tar.gz: 7ece8faae54b250e7883b6ed16752bf8d9140e52508aacf6a755aea21f48e1f659527e2bb7a39b84da9f69620150d43f3b8397d9404015d9ecf7b574ccc8a01b
data/Cargo.lock CHANGED
@@ -717,18 +717,18 @@ dependencies = [
717
717
 
718
718
  [[package]]
719
719
  name = "rb-sys"
720
- version = "0.9.126"
720
+ version = "0.9.127"
721
721
  source = "registry+https://github.com/rust-lang/crates.io-index"
722
- checksum = "284799e73e899fe946fd77c7211b83bff61a1356e039ade7a2516a779e3212d0"
722
+ checksum = "d7d7c9560fe42dcffa576941394075f18a17dce89fcf718a2fa90b7dc2134d12"
723
723
  dependencies = [
724
724
  "rb-sys-build",
725
725
  ]
726
726
 
727
727
  [[package]]
728
728
  name = "rb-sys-build"
729
- version = "0.9.126"
729
+ version = "0.9.127"
730
730
  source = "registry+https://github.com/rust-lang/crates.io-index"
731
- checksum = "855fc1ad8943d12c89ef12f9147f1cc531f5bf19fb744112fdd317bb6ee7b5c5"
731
+ checksum = "f1688e8f32967ba48c89e4dfa283b57f901075f542fc7ee9c3d7c5f9091ca1d9"
732
732
  dependencies = [
733
733
  "bindgen",
734
734
  "lazy_static",
data/README.md CHANGED
@@ -85,6 +85,7 @@ You can also modify the following attributes:
85
85
  - `list_start`
86
86
  - `list_tight`
87
87
  - `fence_info`
88
+ - `alert_type`
88
89
 
89
90
  #### Example: Walking the AST
90
91
 
@@ -522,10 +522,11 @@ impl CommonmarkerNode {
522
522
  "tip" => AlertType::Tip,
523
523
  "important" => AlertType::Important,
524
524
  "warning" => AlertType::Warning,
525
+ "caution" => AlertType::Caution,
525
526
  _ => {
526
527
  return Err(magnus::Error::new(
527
528
  ruby.exception_arg_error(),
528
- "alert type must be `note`, `tip`, `important`, or `warning`",
529
+ "alert type must be `note`, `tip`, `important`, `warning`, or `caution`",
529
530
  ));
530
531
  }
531
532
  };
@@ -980,6 +981,50 @@ impl CommonmarkerNode {
980
981
  }
981
982
  }
982
983
 
984
+ fn get_alert_type(ruby: &Ruby, rb_self: &Self) -> Result<Symbol, magnus::Error> {
985
+ let node = rb_self.inner.borrow();
986
+
987
+ match &node.data.value {
988
+ ComrakNodeValue::Alert(alert) => match alert.alert_type {
989
+ AlertType::Note => Ok(ruby.to_symbol("note")),
990
+ AlertType::Tip => Ok(ruby.to_symbol("tip")),
991
+ AlertType::Important => Ok(ruby.to_symbol("important")),
992
+ AlertType::Warning => Ok(ruby.to_symbol("warning")),
993
+ AlertType::Caution => Ok(ruby.to_symbol("caution")),
994
+ },
995
+ _ => Err(magnus::Error::new(
996
+ ruby.exception_type_error(),
997
+ "node is not an alert node",
998
+ )),
999
+ }
1000
+ }
1001
+
1002
+ fn set_alert_type(
1003
+ ruby: &Ruby,
1004
+ rb_self: &Self,
1005
+ new_type: Symbol,
1006
+ ) -> Result<bool, magnus::Error> {
1007
+ let mut node = rb_self.inner.borrow_mut();
1008
+
1009
+ match node.data.value {
1010
+ ComrakNodeValue::Alert(ref mut alert) => {
1011
+ match new_type.to_string().as_str() {
1012
+ "note" => alert.alert_type = AlertType::Note,
1013
+ "tip" => alert.alert_type = AlertType::Tip,
1014
+ "important" => alert.alert_type = AlertType::Important,
1015
+ "warning" => alert.alert_type = AlertType::Warning,
1016
+ "caution" => alert.alert_type = AlertType::Caution,
1017
+ _ => return Ok(false),
1018
+ }
1019
+ Ok(true)
1020
+ }
1021
+ _ => Err(magnus::Error::new(
1022
+ ruby.exception_type_error(),
1023
+ "node is not an alert node",
1024
+ )),
1025
+ }
1026
+ }
1027
+
983
1028
  fn to_html(ruby: &Ruby, rb_self: &Self, args: &[Value]) -> Result<String, magnus::Error> {
984
1029
  let args = scan_args::scan_args::<(), (), (), (), _, ()>(args)?;
985
1030
 
@@ -1258,6 +1303,8 @@ pub fn init(ruby: &Ruby, m_commonmarker: RModule) -> Result<(), magnus::Error> {
1258
1303
  c_node.define_method("fenced=", method!(CommonmarkerNode::set_fenced, 1))?;
1259
1304
  c_node.define_method("fence_info", method!(CommonmarkerNode::get_fence_info, 0))?;
1260
1305
  c_node.define_method("fence_info=", method!(CommonmarkerNode::set_fence_info, 1))?;
1306
+ c_node.define_method("alert_type", method!(CommonmarkerNode::get_alert_type, 0))?;
1307
+ c_node.define_method("alert_type=", method!(CommonmarkerNode::set_alert_type, 1))?;
1261
1308
 
1262
1309
  Ok(())
1263
1310
  }
@@ -26,6 +26,7 @@ module Commonmarker
26
26
  :list_start,
27
27
  :list_tight,
28
28
  :fence_info,
29
+ :alert_type,
29
30
  ].filter_map do |name|
30
31
  [name, __send__(name)]
31
32
  rescue StandardError
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmarker
4
- VERSION = "2.8.1"
4
+ VERSION = "2.8.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commonmarker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.1
4
+ version: 2.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian