commonmarker 2.10.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,
@@ -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
@@ -20,15 +20,28 @@ module Commonmarker
20
20
  super
21
21
  end
22
22
 
23
- # Public: An iterator that "walks the tree," descending into children recursively.
23
+ # Public: An iterator that "walks the tree," yielding each node and then
24
+ # its descendants, in document order.
24
25
  #
25
- # blk - A {Proc} representing the action to take for each child
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
26
30
  def walk(&block)
27
31
  return enum_for(:walk) unless block
28
32
 
29
33
  yield self
30
- each do |child|
31
- 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
32
45
  end
33
46
  end
34
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmarker
4
- VERSION = "2.10.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.10.0
4
+ version: 2.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
@@ -39,14 +39,17 @@ files:
39
39
  - ext/commonmarker/build.rs
40
40
  - ext/commonmarker/extconf.rb
41
41
  - ext/commonmarker/src/lib.rs
42
+ - ext/commonmarker/src/nesting.rs
42
43
  - ext/commonmarker/src/node.rs
43
44
  - ext/commonmarker/src/options.rs
44
45
  - ext/commonmarker/src/plugins.rs
45
46
  - ext/commonmarker/src/plugins/syntax_highlighting.rs
47
+ - ext/commonmarker/src/rctree.rs
46
48
  - ext/commonmarker/src/utils.rs
47
49
  - lib/commonmarker.rb
48
50
  - lib/commonmarker/config.rb
49
51
  - lib/commonmarker/constants.rb
52
+ - lib/commonmarker/errors.rb
50
53
  - lib/commonmarker/extension.rb
51
54
  - lib/commonmarker/node.rb
52
55
  - lib/commonmarker/node/ast.rb
@@ -79,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
82
  - !ruby/object:Gem::Version
80
83
  version: '3.4'
81
84
  requirements: []
82
- rubygems_version: 4.0.10
85
+ rubygems_version: 4.0.20
83
86
  specification_version: 4
84
87
  summary: CommonMark parser and renderer. Written in Rust, wrapped in Ruby.
85
88
  test_files: []