commonmarker 2.0.2 → 2.0.3

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: 73e1d9c4e91ca5fb9893cd8bb03bcf03e54da4559a7ba52a5b1b3ef6cb7555bf
4
- data.tar.gz: 67d17b0f34a1998be46b6bd2c8d66e4803927ee1efa70eec0e4d24d05a69d8ee
3
+ metadata.gz: a4ab3a70e7aa82b2c88a175c36ef94fd409fb3a91be9191fa099bfbc28fe5a27
4
+ data.tar.gz: 27c42b0189637b01ba86b8328619dc182f7c5227a7462b46aa98e68af5a2ed39
5
5
  SHA512:
6
- metadata.gz: 5c7ef5978420fa74186844e56257235f8763db16a8529f7be3473d8f5100bb6180854826505140c3e19240f134ddd21e8c2668f126394248d19792914da1f25e
7
- data.tar.gz: 58ee5dd1ba2c33be012668350e6d55b23148d52fbaf314e876271d833318d40748815aa8098872dbec99eb38596250635e4cbbee48814379ce1b239752a53b69
6
+ metadata.gz: 23621b4b3798dc46558b3112849323e4d7fafc18509f2e14fda62dc5f23176efc24f41fa233401b40feed2e9015e4a9157403f6b032c688091694a669d243ec7
7
+ data.tar.gz: c3331cc6c4068b0154989121a7007af72011a74abb5aaaff4be547e45385c56485d657fcdab32f5a74ec53746c9095389b1844edddff55e3234a1525bf9b954b
data/Cargo.lock CHANGED
@@ -265,9 +265,9 @@ dependencies = [
265
265
 
266
266
  [[package]]
267
267
  name = "comrak"
268
- version = "0.32.0"
268
+ version = "0.34.0"
269
269
  source = "registry+https://github.com/rust-lang/crates.io-index"
270
- checksum = "48ae8f3e7e3f3d424cbb33354fc36943d507327d210aa5794b0192f4be726c6d"
270
+ checksum = "1664eb8abab93a9c09d1e85df10b4de6af0b4c738f267750b211a77a771447fe"
271
271
  dependencies = [
272
272
  "bon",
273
273
  "caseless",
@@ -275,8 +275,6 @@ dependencies = [
275
275
  "emojis",
276
276
  "entities",
277
277
  "memchr",
278
- "once_cell",
279
- "regex",
280
278
  "shell-words",
281
279
  "slug",
282
280
  "syntect",
@@ -678,18 +676,18 @@ dependencies = [
678
676
 
679
677
  [[package]]
680
678
  name = "rb-sys"
681
- version = "0.9.105"
679
+ version = "0.9.108"
682
680
  source = "registry+https://github.com/rust-lang/crates.io-index"
683
- checksum = "4b3a1f3ce8e7c36d777d52fe7a99039fe4fea7c8ec355a4c4f3a17f92a14029f"
681
+ checksum = "1e955384e1a4dc64b71d1e4b39ed0edbd77c7bde4a10dfd5ad208e1160fddfa7"
684
682
  dependencies = [
685
683
  "rb-sys-build",
686
684
  ]
687
685
 
688
686
  [[package]]
689
687
  name = "rb-sys-build"
690
- version = "0.9.105"
688
+ version = "0.9.108"
691
689
  source = "registry+https://github.com/rust-lang/crates.io-index"
692
- checksum = "3e6b246c29c0809e1cbe60a1ba9e093da72a4676d02adc68469297d1e589bbf0"
690
+ checksum = "c167c6571889b2550d6fcb315e8aa60bdb95e47e4b64793e3f65a30dc25afc85"
693
691
  dependencies = [
694
692
  "bindgen",
695
693
  "lazy_static",
data/README.md CHANGED
@@ -209,6 +209,8 @@ Commonmarker.to_html('"Hi *there*"', options: {
209
209
  | `underline` | Enables the underline extension. | `false` |
210
210
  | `spoiler` | Enables the spoiler extension. | `false` |
211
211
  | `greentext` | Enables the greentext extension. | `false` |
212
+ | `subscript` | Enables the subscript extension. | `false` |
213
+ | `alerts` | Enables the alerts extension. | `false` |
212
214
 
213
215
  For more information on these options, see [the comrak documentation](https://github.com/kivikakk/comrak#usage).
214
216
 
@@ -10,7 +10,7 @@ magnus = { version = "0.7", features = ["rb-sys"] }
10
10
  rb-sys = { version = "*", default-features = false, features = [
11
11
  "stable-api-compiled-fallback",
12
12
  ] }
13
- comrak = { version = "0.32", features = ["shortcodes"] }
13
+ comrak = { version = "0.34", features = ["shortcodes"] }
14
14
  syntect = { version = "5.2", features = ["plist-load"] }
15
15
  typed-arena = "2.0"
16
16
  rctree = "0.6"
@@ -1,9 +1,9 @@
1
1
  use comrak::arena_tree::Node as ComrakNode;
2
2
  use comrak::nodes::{
3
- Ast as ComrakAst, AstNode as ComrakAstNode, ListDelimType, ListType, NodeCode, NodeCodeBlock,
4
- NodeDescriptionItem, NodeFootnoteDefinition, NodeFootnoteReference, NodeHeading, NodeHtmlBlock,
5
- NodeLink, NodeList, NodeMath, NodeMultilineBlockQuote, NodeShortCode, NodeTable,
6
- NodeValue as ComrakNodeValue, NodeWikiLink, TableAlignment,
3
+ AlertType, Ast as ComrakAst, AstNode as ComrakAstNode, ListDelimType, ListType, NodeAlert,
4
+ NodeCode, NodeCodeBlock, NodeDescriptionItem, NodeFootnoteDefinition, NodeFootnoteReference,
5
+ NodeHeading, NodeHtmlBlock, NodeLink, NodeList, NodeMath, NodeMultilineBlockQuote,
6
+ NodeShortCode, NodeTable, NodeValue as ComrakNodeValue, NodeWikiLink, TableAlignment,
7
7
  };
8
8
  use magnus::RArray;
9
9
  use magnus::{function, method, scan_args, Module, Object, RHash, RModule, Symbol, Value};
@@ -473,6 +473,59 @@ impl CommonmarkerNode {
473
473
  ComrakNodeValue::WikiLink(NodeWikiLink { url })
474
474
  }
475
475
 
476
+ "raw" => {
477
+ let kwargs = scan_args::get_kwargs::<_, (), (Option<String>,), ()>(
478
+ args.keywords,
479
+ &[],
480
+ &["content"],
481
+ )?;
482
+
483
+ let (content,) = kwargs.optional;
484
+
485
+ ComrakNodeValue::Raw(content.unwrap_or_default())
486
+ }
487
+
488
+ "alert" => {
489
+ let kwargs = scan_args::get_kwargs::<
490
+ _,
491
+ (Symbol,),
492
+ (Option<String>, Option<bool>, Option<usize>, Option<usize>),
493
+ (),
494
+ >(
495
+ args.keywords,
496
+ &["type"],
497
+ &["title", "multiline", "fence_length", "fence_offset"],
498
+ )?;
499
+
500
+ let (alert_name,) = kwargs.required;
501
+ let (title, multiline, fence_length, fence_offset) = kwargs.optional;
502
+
503
+ let alert_type = match alert_name.to_string().as_str() {
504
+ "note" => AlertType::Note,
505
+ "tip" => AlertType::Tip,
506
+ "important" => AlertType::Important,
507
+ "warning" => AlertType::Warning,
508
+ _ => {
509
+ return Err(magnus::Error::new(
510
+ magnus::exception::arg_error(),
511
+ "alert type must be `note`, `tip`, `important`, or `warning`",
512
+ ));
513
+ }
514
+ };
515
+
516
+ ComrakNodeValue::Alert(NodeAlert {
517
+ alert_type,
518
+ // Overridden title. If None, then use the default title.
519
+ title,
520
+ // Originated from a multiline blockquote.
521
+ multiline: multiline.unwrap_or(false),
522
+ // The length of the fence (multiline only).
523
+ fence_length: fence_length.unwrap_or(0),
524
+ // The indentation level of the fence marker (multiline only)
525
+ fence_offset: fence_offset.unwrap_or(0),
526
+ })
527
+ }
528
+
476
529
  _ => panic!("unknown node type {}", node_type),
477
530
  };
478
531
 
@@ -565,6 +618,7 @@ impl CommonmarkerNode {
565
618
  ComrakNodeValue::Subscript => Symbol::new("subscript"),
566
619
  ComrakNodeValue::SpoileredText => Symbol::new("spoilered_text"),
567
620
  ComrakNodeValue::EscapedTag(_) => Symbol::new("escaped_tag"),
621
+ ComrakNodeValue::Alert(..) => Symbol::new("alert"),
568
622
  }
569
623
  }
570
624
 
@@ -117,6 +117,7 @@ const EXTENSION_UNDERLINE: &str = "underline";
117
117
  const EXTENSION_SPOILER: &str = "spoiler";
118
118
  const EXTENSION_GREENTEXT: &str = "greentext";
119
119
  const EXTENSION_SUBSCRIPT: &str = "subscript";
120
+ const EXTENSION_ALERTS: &str = "alerts";
120
121
 
121
122
  fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
122
123
  options_hash
@@ -189,6 +190,9 @@ fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: R
189
190
  Ok(Cow::Borrowed(EXTENSION_SUBSCRIPT)) => {
190
191
  comrak_options.extension.subscript = TryConvert::try_convert(value)?;
191
192
  }
193
+ Ok(Cow::Borrowed(EXTENSION_ALERTS)) => {
194
+ comrak_options.extension.alerts = TryConvert::try_convert(value)?;
195
+ }
192
196
  _ => {}
193
197
  }
194
198
  Ok(ForEach::Continue)
@@ -46,6 +46,7 @@ module Commonmarker
46
46
  spoiler: false,
47
47
  greentext: false,
48
48
  subscript: false,
49
+ alerts: false,
49
50
  }.freeze,
50
51
  format: [:html].freeze,
51
52
  }.freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmarker
4
- VERSION = "2.0.2"
4
+ VERSION = "2.0.3"
5
5
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commonmarker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  - Ashe Connor
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2024-12-29 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rb_sys
@@ -25,7 +24,6 @@ dependencies:
25
24
  - - "~>"
26
25
  - !ruby/object:Gem::Version
27
26
  version: '0.9'
28
- force_ruby_platform: false
29
27
  - !ruby/object:Gem::Dependency
30
28
  name: rake
31
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,7 +54,6 @@ dependencies:
56
54
  version: '1.2'
57
55
  description: A fast, safe, extensible parser for CommonMark. This wraps the comrak
58
56
  Rust crate.
59
- email:
60
57
  executables: []
61
58
  extensions:
62
59
  - ext/commonmarker/extconf.rb
@@ -92,7 +89,6 @@ metadata:
92
89
  funding_uri: https://github.com/sponsors/gjtorikian/
93
90
  source_code_uri: https://github.com/gjtorikian/commonmarker
94
91
  rubygems_mfa_required: 'true'
95
- post_install_message:
96
92
  rdoc_options: []
97
93
  require_paths:
98
94
  - lib
@@ -100,15 +96,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
96
  requirements:
101
97
  - - "~>"
102
98
  - !ruby/object:Gem::Version
103
- version: '3.1'
99
+ version: '3.2'
104
100
  required_rubygems_version: !ruby/object:Gem::Requirement
105
101
  requirements:
106
102
  - - "~>"
107
103
  - !ruby/object:Gem::Version
108
104
  version: '3.4'
109
105
  requirements: []
110
- rubygems_version: 3.5.3
111
- signing_key:
106
+ rubygems_version: 3.6.2
112
107
  specification_version: 4
113
108
  summary: CommonMark parser and renderer. Written in Rust, wrapped in Ruby.
114
109
  test_files: []