Use XPath for searching link nodes
This is a tad faster than letting Nokogiri figure out whether it should evaluate the query as CSS or XPath and then actually evaluating it.
This commit is contained in:
parent
ab08321be8
commit
3077cb52d9
1 changed files with 2 additions and 2 deletions
|
@ -124,7 +124,7 @@ module Banzai
|
||||||
def replace_link_nodes_with_text(pattern)
|
def replace_link_nodes_with_text(pattern)
|
||||||
return doc if project.nil?
|
return doc if project.nil?
|
||||||
|
|
||||||
doc.search('a').each do |node|
|
doc.xpath('descendant-or-self::a').each do |node|
|
||||||
klass = node.attr('class')
|
klass = node.attr('class')
|
||||||
next if klass && klass.include?('gfm')
|
next if klass && klass.include?('gfm')
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ module Banzai
|
||||||
def replace_link_nodes_with_href(pattern)
|
def replace_link_nodes_with_href(pattern)
|
||||||
return doc if project.nil?
|
return doc if project.nil?
|
||||||
|
|
||||||
doc.search('a').each do |node|
|
doc.xpath('descendant-or-self::a').each do |node|
|
||||||
klass = node.attr('class')
|
klass = node.attr('class')
|
||||||
next if klass && klass.include?('gfm')
|
next if klass && klass.include?('gfm')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue