Commit 3077cb52 authored by Yorick Peterse's avatar Yorick Peterse

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.
parent ab08321b
...@@ -124,7 +124,7 @@ module Banzai ...@@ -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 ...@@ -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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment