commonmarker 2.9.0 → 2.10.1

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.
@@ -13,6 +13,7 @@ module Commonmarker
13
13
  leave_footnote_definitions: false,
14
14
  ignore_setext: false,
15
15
  sourcepos_chars: false,
16
+ max_nesting_depth: 1000,
16
17
  }.freeze,
17
18
  render: {
18
19
  hardbreaks: true,
@@ -32,7 +33,6 @@ module Commonmarker
32
33
  }.freeze,
33
34
  extension: {
34
35
  strikethrough: true,
35
- tagfilter: true,
36
36
  table: true,
37
37
  autolink: true,
38
38
  tasklist: true,
@@ -68,8 +68,8 @@ module Commonmarker
68
68
  syntax_highlighter: {
69
69
  theme: "base16-ocean.dark",
70
70
  path: "",
71
- },
72
- }
71
+ }.freeze,
72
+ }.freeze
73
73
 
74
74
  class << self
75
75
  include Commonmarker::Utils
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Commonmarker
4
+ # Raised when a document nests more deeply than the `max_nesting_depth`
5
+ # parse option allows.
6
+ class NestingDepthExceededError < StandardError; end
7
+ end
@@ -28,10 +28,8 @@ module Commonmarker
28
28
  :fence_info,
29
29
  :alert_type,
30
30
  ].filter_map do |name|
31
- [name, __send__(name)]
32
- rescue StandardError
33
- nil
34
- end.compact
31
+ [name, __send__(name)] if respond_to?(name)
32
+ end
35
33
 
36
34
  printer.seplist(attrs) do |name, value|
37
35
  printer.text("#{name}=")
@@ -8,15 +8,40 @@ module Commonmarker
8
8
  include Enumerable
9
9
  include Inspect
10
10
 
11
- # Public: An iterator that "walks the tree," descending into children recursively.
11
+ # Public: Whether this node responds to the given method.
12
12
  #
13
- # blk - A {Proc} representing the action to take for each child
13
+ # name - A {Symbol} or {String} naming the method.
14
+ # include_all - A {Boolean} indicating whether to consider private methods.
15
+ #
16
+ # Returns a {Boolean}.
17
+ def respond_to?(name, include_all = false)
18
+ return false if node_supports?(name.to_sym) == false
19
+
20
+ super
21
+ end
22
+
23
+ # Public: An iterator that "walks the tree," yielding each node and then
24
+ # its descendants, in document order.
25
+ #
26
+ # The walk is iterative rather than recursive, so arbitrarily deep trees
27
+ # can't exhaust the stack.
28
+ #
29
+ # blk - A {Proc} representing the action to take for each node
14
30
  def walk(&block)
15
31
  return enum_for(:walk) unless block
16
32
 
17
33
  yield self
18
- each do |child|
19
- child.walk(&block)
34
+
35
+ # Like #each, the next sibling is captured before a node is yielded, so
36
+ # the block may detach or replace the node it is given. `pending` holds
37
+ # the sibling to resume at once each ancestor's subtree is done.
38
+ pending = []
39
+ node = first_child
40
+ while node
41
+ next_node = node.next_sibling
42
+ yield node
43
+ pending << next_node if next_node
44
+ node = node.first_child || pending.pop
20
45
  end
21
46
  end
22
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmarker
4
- VERSION = "2.9.0"
4
+ VERSION = "2.10.1"
5
5
  end
data/lib/commonmarker.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "commonmarker/extension"
4
4
 
5
+ require "commonmarker/errors"
5
6
  require "commonmarker/utils"
6
7
  require "commonmarker/node"
7
8
  require "commonmarker/config"
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.9.0
4
+ version: 2.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.9'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '13.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '13.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake-compiler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.2'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.2'
55
27
  description: A fast, safe, extensible parser for CommonMark. This wraps the comrak
56
28
  Rust crate.
57
29
  executables: []
@@ -67,14 +39,17 @@ files:
67
39
  - ext/commonmarker/build.rs
68
40
  - ext/commonmarker/extconf.rb
69
41
  - ext/commonmarker/src/lib.rs
42
+ - ext/commonmarker/src/nesting.rs
70
43
  - ext/commonmarker/src/node.rs
71
44
  - ext/commonmarker/src/options.rs
72
45
  - ext/commonmarker/src/plugins.rs
73
46
  - ext/commonmarker/src/plugins/syntax_highlighting.rs
47
+ - ext/commonmarker/src/rctree.rs
74
48
  - ext/commonmarker/src/utils.rs
75
49
  - lib/commonmarker.rb
76
50
  - lib/commonmarker/config.rb
77
51
  - lib/commonmarker/constants.rb
52
+ - lib/commonmarker/errors.rb
78
53
  - lib/commonmarker/extension.rb
79
54
  - lib/commonmarker/node.rb
80
55
  - lib/commonmarker/node/ast.rb
@@ -107,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
82
  - !ruby/object:Gem::Version
108
83
  version: '3.4'
109
84
  requirements: []
110
- rubygems_version: 4.0.10
85
+ rubygems_version: 4.0.20
111
86
  specification_version: 4
112
87
  summary: CommonMark parser and renderer. Written in Rust, wrapped in Ruby.
113
88
  test_files: []