commonmarker 1.1.5 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68467a1bf2ae449bfb07febbb6559778974b81d6c6df5a2a1a7022efff846000
4
- data.tar.gz: a97250f78127cb2277e5727c573ca41482971f25df88e8516f6ba0176ea49ebd
3
+ metadata.gz: 7824257cc0655cb8eb286333f015e6542cc4666602675e86d969a4c565f8d4d9
4
+ data.tar.gz: 8eb3a39a2d10fc90e0cea2a578e4040a43a16771586bf8bb09a3706fe45b8eda
5
5
  SHA512:
6
- metadata.gz: 72709d354fc8d476285642e9a32ed575189f318941e736f4829470bf7bf42fc47506a6f2912d1f3c5a5f1b436f56c81ce251cd94937eb2907b659837621573a7
7
- data.tar.gz: bedc677e77ce171e5f0f8d40493178598af42aa27a59b5939adba35d1022f8cca957ab8153c2362d406d8df8962a558e88a8a2d52f4e7d30829c99be37ea4d0e
6
+ metadata.gz: b84b895cc30fc1817fc96639c774878127b82ff1e36e7cfc5ace170497bc2167bc734e212aab70cd6986df74ed7a223853e324c00bd51846a46107911da0f725
7
+ data.tar.gz: 723eef2b963100c97af949dd9b2db1b21bdd5a52b0dfb82f18b23c181c7b128681b96358dcb792554afd79b13cc2829bef543e26d506f7d803dfc62db8a598dd
data/Cargo.lock CHANGED
@@ -128,6 +128,31 @@ version = "2.6.0"
128
128
  source = "registry+https://github.com/rust-lang/crates.io-index"
129
129
  checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
130
130
 
131
+ [[package]]
132
+ name = "bon"
133
+ version = "3.0.2"
134
+ source = "registry+https://github.com/rust-lang/crates.io-index"
135
+ checksum = "a636f83af97c6946f3f5cf5c268ec02375bf5efd371110292dfd57961f57a509"
136
+ dependencies = [
137
+ "bon-macros",
138
+ "rustversion",
139
+ ]
140
+
141
+ [[package]]
142
+ name = "bon-macros"
143
+ version = "3.0.2"
144
+ source = "registry+https://github.com/rust-lang/crates.io-index"
145
+ checksum = "a7eaf1bfaa5b8d512abfd36d0c432591fef139d3de9ee54f1f839ea109d70d33"
146
+ dependencies = [
147
+ "darling",
148
+ "ident_case",
149
+ "prettyplease",
150
+ "proc-macro2",
151
+ "quote",
152
+ "rustversion",
153
+ "syn",
154
+ ]
155
+
131
156
  [[package]]
132
157
  name = "bumpalo"
133
158
  version = "3.16.0"
@@ -237,13 +262,13 @@ dependencies = [
237
262
 
238
263
  [[package]]
239
264
  name = "comrak"
240
- version = "0.26.0"
265
+ version = "0.30.0"
241
266
  source = "registry+https://github.com/rust-lang/crates.io-index"
242
- checksum = "395ab67843c57df5a4ee29d610740828dbc928cc64ecf0f2a1d5cd0e98e107a9"
267
+ checksum = "949f8e6b02ebac005a8be2df9ec0876cafc83fdb9c510796c37f0fadf92dcd0e"
243
268
  dependencies = [
269
+ "bon",
244
270
  "caseless",
245
271
  "clap",
246
- "derive_builder",
247
272
  "emojis",
248
273
  "entities",
249
274
  "memchr",
@@ -310,37 +335,6 @@ dependencies = [
310
335
  "powerfmt",
311
336
  ]
312
337
 
313
- [[package]]
314
- name = "derive_builder"
315
- version = "0.20.0"
316
- source = "registry+https://github.com/rust-lang/crates.io-index"
317
- checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7"
318
- dependencies = [
319
- "derive_builder_macro",
320
- ]
321
-
322
- [[package]]
323
- name = "derive_builder_core"
324
- version = "0.20.0"
325
- source = "registry+https://github.com/rust-lang/crates.io-index"
326
- checksum = "d48cda787f839151732d396ac69e3473923d54312c070ee21e9effcaa8ca0b1d"
327
- dependencies = [
328
- "darling",
329
- "proc-macro2",
330
- "quote",
331
- "syn",
332
- ]
333
-
334
- [[package]]
335
- name = "derive_builder_macro"
336
- version = "0.20.0"
337
- source = "registry+https://github.com/rust-lang/crates.io-index"
338
- checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b"
339
- dependencies = [
340
- "derive_builder_core",
341
- "syn",
342
- ]
343
-
344
338
  [[package]]
345
339
  name = "deunicode"
346
340
  version = "1.6.0"
@@ -642,11 +636,21 @@ version = "0.2.0"
642
636
  source = "registry+https://github.com/rust-lang/crates.io-index"
643
637
  checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
644
638
 
639
+ [[package]]
640
+ name = "prettyplease"
641
+ version = "0.2.25"
642
+ source = "registry+https://github.com/rust-lang/crates.io-index"
643
+ checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033"
644
+ dependencies = [
645
+ "proc-macro2",
646
+ "syn",
647
+ ]
648
+
645
649
  [[package]]
646
650
  name = "proc-macro2"
647
- version = "1.0.86"
651
+ version = "1.0.92"
648
652
  source = "registry+https://github.com/rust-lang/crates.io-index"
649
- checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
653
+ checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
650
654
  dependencies = [
651
655
  "unicode-ident",
652
656
  ]
@@ -671,18 +675,18 @@ dependencies = [
671
675
 
672
676
  [[package]]
673
677
  name = "rb-sys"
674
- version = "0.9.99"
678
+ version = "0.9.103"
675
679
  source = "registry+https://github.com/rust-lang/crates.io-index"
676
- checksum = "d83151cfea2b67db2444f68c53b119ff77cff235ad711c765072e4daf8f3185b"
680
+ checksum = "91dbe37ab6ac2fba187480fb6544b92445e41e5c6f553bf0c33743f3c450a1df"
677
681
  dependencies = [
678
682
  "rb-sys-build",
679
683
  ]
680
684
 
681
685
  [[package]]
682
686
  name = "rb-sys-build"
683
- version = "0.9.99"
687
+ version = "0.9.103"
684
688
  source = "registry+https://github.com/rust-lang/crates.io-index"
685
- checksum = "32d038214c118ad4a75db555ccb78672e17e1c5c10f344456cd129008dbaa7de"
689
+ checksum = "c4d56a49dcb646b70b758789c0d16c055a386a4f2a3346333abb69850fa860ce"
686
690
  dependencies = [
687
691
  "bindgen",
688
692
  "lazy_static",
@@ -753,6 +757,12 @@ dependencies = [
753
757
  "windows-sys 0.52.0",
754
758
  ]
755
759
 
760
+ [[package]]
761
+ name = "rustversion"
762
+ version = "1.0.18"
763
+ source = "registry+https://github.com/rust-lang/crates.io-index"
764
+ checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"
765
+
756
766
  [[package]]
757
767
  name = "ryu"
758
768
  version = "1.0.18"
@@ -842,9 +852,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
842
852
 
843
853
  [[package]]
844
854
  name = "syn"
845
- version = "2.0.72"
855
+ version = "2.0.89"
846
856
  source = "registry+https://github.com/rust-lang/crates.io-index"
847
- checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
857
+ checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
848
858
  dependencies = [
849
859
  "proc-macro2",
850
860
  "quote",
data/README.md CHANGED
@@ -4,7 +4,10 @@ Ruby wrapper for Rust's [comrak](https://github.com/kivikakk/comrak) crate.
4
4
 
5
5
  It passes all of the CommonMark test suite, and is therefore spec-complete. It also includes extensions to the CommonMark spec as documented in the [GitHub Flavored Markdown spec](http://github.github.com/gfm/), such as support for tables, strikethroughs, and autolinking.
6
6
 
7
- For more information on available extensions, see [the documentation below](#extension-options).
7
+ > [!NOTE]
8
+ > By default, several extensions not in any spec have been enabled, for the sake of end user convenience when generating HTML.
9
+ >
10
+ > For more information on the available options and extensions, see [the documentation below](#options-and-plugins).
8
11
 
9
12
  ## Installation
10
13
 
@@ -86,7 +89,7 @@ You can also modify the following attributes:
86
89
  You can use `walk` or `each` to iterate over nodes:
87
90
 
88
91
  - `walk` will iterate on a node and recursively iterate on a node's children.
89
- - `each` will iterate on a node and its children, but no further.
92
+ - `each` will iterate on a node's direct children, but no further.
90
93
 
91
94
  ```ruby
92
95
  require 'commonmarker'
@@ -147,16 +150,16 @@ Commonmarker.to_html('"Hi *there*"', options:{
147
150
  })
148
151
  ```
149
152
 
150
- Note that there is a distinction in comrak for "parse" options and "render" options, which are represented in the tables below.
153
+ Note that there is a distinction in comrak for "parse" options and "render" options, which are represented in the tables below. As well, if you wish to disable any-non boolean option, pass in `nil`.
151
154
 
152
155
  ### Parse options
153
156
 
154
- | Name | Description | Default |
155
- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
156
- | `smart` | Punctuation (quotes, full-stops and hyphens) are converted into 'smart' punctuation. | `false` |
157
- | `default_info_string` | The default info string for fenced code blocks. | `""` |
158
- | `relaxed_tasklist_matching` | Enables relaxing of the tasklist extension matching, allowing any non-space to be used for the "checked" state instead of only `x` and `X`. | `false` |
159
- | `relaxed_autolinks` | Enable relaxing of the autolink extension parsing, allowing links to be recognized when in brackets, as well as permitting any url scheme. | `false` |
157
+ | Name | Description | Default |
158
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
159
+ | `smart` | Punctuation (quotes, full-stops and hyphens) are converted into 'smart' punctuation. | `false` |
160
+ | `default_info_string` | The default info string for fenced code blocks. | `""` |
161
+ | `relaxed_tasklist_matching` | Enables relaxing of the tasklist extension matching, allowing any non-space to be used for the "checked" state instead of only `x` and `X`. | `false` |
162
+ | `relaxed_autolinks` | Enable relaxing of the autolink extension parsing, allowing links to be recognized when in brackets, as well as permitting any url scheme. | `false` |
160
163
 
161
164
  ### Render options
162
165
 
@@ -187,7 +190,7 @@ Commonmarker.to_html('"Hi *there*"', options: {
187
190
  ### Extension options
188
191
 
189
192
  | Name | Description | Default |
190
- | --------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------- |
193
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------- |
191
194
  | `strikethrough` | Enables the [strikethrough extension](https://github.github.com/gfm/#strikethrough-extension-) from the GFM spec. | `true` |
192
195
  | `tagfilter` | Enables the [tagfilter extension](https://github.github.com/gfm/#disallowed-raw-html-extension-) from the GFM spec. | `true` |
193
196
  | `table` | Enables the [table extension](https://github.github.com/gfm/#tables-extension-) from the GFM spec. | `true` |
@@ -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.26", features = ["shortcodes"] }
13
+ comrak = { version = "0.30", features = ["shortcodes"] }
14
14
  syntect = { version = "5.2", features = ["plist-load"] }
15
15
  typed-arena = "2.0"
16
16
  rctree = "0.6"
@@ -76,7 +76,7 @@ fn commonmark_to_html(args: &[Value]) -> Result<String, magnus::Error> {
76
76
  ))
77
77
  }
78
78
 
79
- fn format_options<'c>(rb_options: Option<RHash>) -> Result<comrak::Options<'c>, magnus::Error> {
79
+ fn format_options(rb_options: Option<RHash>) -> Result<comrak::Options, magnus::Error> {
80
80
  let mut comrak_options = ComrakOptions::default();
81
81
 
82
82
  if let Some(rb_options) = rb_options {
@@ -66,6 +66,7 @@ impl CommonmarkerNode {
66
66
  Option<String>,
67
67
  Option<u8>,
68
68
  Option<bool>,
69
+ Option<bool>,
69
70
  ),
70
71
  (),
71
72
  >(
@@ -78,11 +79,12 @@ impl CommonmarkerNode {
78
79
  "delimiter",
79
80
  "bullet_char",
80
81
  "tight",
82
+ "task_list",
81
83
  ],
82
84
  )?;
83
85
 
84
86
  let (list_type,) = kwargs.required;
85
- let (marker_offset, padding, start, delimiter, bullet_char, tight) =
87
+ let (marker_offset, padding, start, delimiter, bullet_char, tight, task_list) =
86
88
  kwargs.optional;
87
89
 
88
90
  let commonmark_list_type = list_type.to_string();
@@ -121,6 +123,7 @@ impl CommonmarkerNode {
121
123
  // Whether the list is [tight](https://github.github.com/gfm/#tight), i.e. whether the
122
124
  // paragraphs are wrapped in `<p>` tags when formatted as HTML.
123
125
  tight: tight.unwrap_or(false),
126
+ is_task_list: task_list.unwrap_or(false),
124
127
  })
125
128
  }
126
129
  "description_list" => ComrakNodeValue::DescriptionList,
@@ -335,6 +338,7 @@ impl CommonmarkerNode {
335
338
  "strong" => ComrakNodeValue::Strong,
336
339
  "strikethrough" => ComrakNodeValue::Strikethrough,
337
340
  "superscript" => ComrakNodeValue::Superscript,
341
+ "subscript" => ComrakNodeValue::Subscript,
338
342
  "link" => {
339
343
  let kwargs = scan_args::get_kwargs::<_, (String,), (Option<String>,), ()>(
340
344
  args.keywords,
@@ -462,6 +466,7 @@ impl CommonmarkerNode {
462
466
 
463
467
  ComrakNodeValue::WikiLink(NodeWikiLink { url })
464
468
  }
469
+
465
470
  _ => panic!("unknown node type {}", node_type),
466
471
  };
467
472
 
@@ -550,6 +555,7 @@ impl CommonmarkerNode {
550
555
  ComrakNodeValue::Math(..) => Symbol::new("math"),
551
556
  ComrakNodeValue::WikiLink(..) => Symbol::new("wikilink"),
552
557
  ComrakNodeValue::Underline => Symbol::new("underline"),
558
+ ComrakNodeValue::Subscript => Symbol::new("subscript"),
553
559
  ComrakNodeValue::SpoileredText => Symbol::new("spoilered_text"),
554
560
  ComrakNodeValue::EscapedTag(_) => Symbol::new("escaped_tag"),
555
561
  }
@@ -116,6 +116,7 @@ const EXTENSION_WIKILINKS_TITLE_BEFORE_PIPE: &str = "wikilinks_title_before_pipe
116
116
  const EXTENSION_UNDERLINE: &str = "underline";
117
117
  const EXTENSION_SPOILER: &str = "spoiler";
118
118
  const EXTENSION_GREENTEXT: &str = "greentext";
119
+ const EXTENSION_SUBSCRIPT: &str = "subscript";
119
120
 
120
121
  fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
121
122
  options_hash
@@ -185,6 +186,9 @@ fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: R
185
186
  Ok(Cow::Borrowed(EXTENSION_GREENTEXT)) => {
186
187
  comrak_options.extension.greentext = TryConvert::try_convert(value)?;
187
188
  }
189
+ Ok(Cow::Borrowed(EXTENSION_SUBSCRIPT)) => {
190
+ comrak_options.extension.subscript = TryConvert::try_convert(value)?;
191
+ }
188
192
  _ => {}
189
193
  }
190
194
  Ok(ForEach::Continue)
@@ -45,7 +45,8 @@ module Commonmarker
45
45
  underline: false,
46
46
  spoiler: false,
47
47
  greentext: false,
48
- },
48
+ subscript: false,
49
+ }.freeze,
49
50
  format: [:html].freeze,
50
51
  }.freeze
51
52
 
@@ -59,10 +60,6 @@ module Commonmarker
59
60
  class << self
60
61
  include Commonmarker::Utils
61
62
 
62
- def merged_with_defaults(options)
63
- Commonmarker::Config::OPTIONS.merge(process_options(options))
64
- end
65
-
66
63
  def process_options(options)
67
64
  {
68
65
  parse: process_parse_options(options[:parse]),
@@ -79,37 +76,30 @@ module Commonmarker
79
76
  end
80
77
 
81
78
  [:parse, :render, :extension].each do |type|
82
- define_singleton_method :"process_#{type}_options" do |option|
79
+ define_singleton_method :"process_#{type}_options" do |options|
83
80
  Commonmarker::Config::OPTIONS[type].each_with_object({}) do |(key, value), hash|
84
- if option.nil? # option not provided, go for the default
81
+ if options.nil? || !options.key?(key) # option not provided, use the default
85
82
  hash[key] = value
86
83
  next
87
84
  end
88
85
 
89
- # option explicitly not included, remove it
90
- next if option[key].nil?
86
+ if options[key].nil? # # option explicitly not included, remove it
87
+ options.delete(key)
88
+ next
89
+ end
91
90
 
92
- hash[key] = fetch_kv(option, key, value, type)
91
+ hash[key] = fetch_kv(options, key, value, type)
93
92
  end
94
93
  end
95
94
  end
96
95
 
97
- [:syntax_highlighter].each do |type|
98
- define_singleton_method :"process_#{type}_plugin" do |plugin|
99
- return if plugin.nil? # plugin explicitly nil, remove it
96
+ define_singleton_method :process_syntax_highlighter_plugin do |options|
97
+ return if options.nil? # plugin explicitly nil, remove it
100
98
 
101
- Commonmarker::Config::PLUGINS[type].each_with_object({}) do |(key, value), hash|
102
- if plugin.nil? # option not provided, go for the default
103
- hash[key] = value
104
- next
105
- end
99
+ raise TypeError, "Expected a Hash for syntax_highlighter plugin, got #{options.class}" unless options.is_a?(Hash)
100
+ raise TypeError, "Expected a Hash for syntax_highlighter plugin, got nothing" if options.empty?
106
101
 
107
- # option explicitly not included, remove it
108
- next if plugin[key].nil?
109
-
110
- hash[key] = fetch_kv(plugin, key, value, type)
111
- end
112
- end
102
+ Commonmarker::Config::PLUGINS[:syntax_highlighter].merge(options)
113
103
  end
114
104
  end
115
105
  end
@@ -6,16 +6,16 @@ module Commonmarker
6
6
  module Utils
7
7
  include Commonmarker::Constants
8
8
 
9
- def fetch_kv(option, key, value, type)
9
+ def fetch_kv(options, key, value, type)
10
10
  value_klass = value.class
11
11
 
12
- if Constants::BOOLS.include?(value) && BOOLS.include?(option[key])
13
- option[key]
14
- elsif option[key].is_a?(value_klass)
15
- option[key]
12
+ if Constants::BOOLS.include?(value) && BOOLS.include?(options[key])
13
+ options[key]
14
+ elsif options[key].is_a?(value_klass)
15
+ options[key]
16
16
  else
17
17
  expected_type = Constants::BOOLS.include?(value) ? "Boolean" : value_klass.to_s
18
- raise TypeError, "#{type} option `:#{key}` must be #{expected_type}; got #{option[key].class}"
18
+ raise TypeError, "#{type} option `:#{key}` must be #{expected_type}; got #{options[key].class}"
19
19
  end
20
20
  end
21
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmarker
4
- VERSION = "1.1.5"
4
+ VERSION = "2.0.0"
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: 1.1.5
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-07-29 00:00:00.000000000 Z
12
+ date: 2024-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rb_sys