Skip to content

Commit

Permalink
Fix Nokogiri deprecation warning
Browse files Browse the repository at this point in the history
Nokogiri warning:

```
warning: Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in a future release of Nokogiri.
```

Please see the following for more details:
sparklemotion/nokogiri#975
  • Loading branch information
mishina2228 committed Mar 25, 2022
1 parent 6836467 commit 42d6aaa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/gollum-lib/filter/toc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def generate_anchor_name(header)
# Creates an anchor element with the given name and adds it before
# the given header element.
def add_anchor_to_header(header, name)
a = Nokogiri::XML::Node.new('a', @doc)
a = Nokogiri::XML::Node.new('a', @doc.document)
a['class'] = 'anchor'
a['id'] = name
a['href'] = "##{name}"
Expand All @@ -143,17 +143,17 @@ def add_entry_to_toc(header, name)

if @tail_level < level
while @tail_level < level
list = Nokogiri::XML::Node.new('ul', @doc)
list = Nokogiri::XML::Node.new('ul', @doc.document)
@tail.add_child(list)
@tail = list.add_child(Nokogiri::XML::Node.new('li', @doc))
@tail = list.add_child(Nokogiri::XML::Node.new('li', @doc.document))
@tail_level += 1
end
else
while @tail_level > level
@tail = @tail.parent.parent
@tail_level -= 1
end
@tail = @tail.parent.add_child(Nokogiri::XML::Node.new('li', @doc))
@tail = @tail.parent.add_child(Nokogiri::XML::Node.new('li', @doc.document))
end

# % -> %25 so anchors work on Firefox. See issue #475
Expand Down

0 comments on commit 42d6aaa

Please sign in to comment.