17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/jekyll-file-protocol/jekyll/filters/relative_path.rb', line 17
def relative_tag(input)
return input if input.nil?
node = Nokogiri::HTML.parse(input)
tags = nil
if (tags = node.css('link').to_a).size > 0
return tags.map do |tag|
tag['href'] = ::JekyllFileProtocol::RelativePathRenderer.new(@context, tag['href']).render
tag
end.map(&:to_html)
end
if (tags = node.css('script').to_a).size > 0
return tags.map do |tag|
tag['src'] = ::JekyllFileProtocol::RelativePathRenderer.new(@context, tag['src']).render
tag
end.map(&:to_html)
end
if (tags = node.css('img').to_a).size > 0
return tags.map do |tag|
tag['src'] = ::JekyllFileProtocol::RelativePathRenderer.new(@context, tag['src']).render
tag
end.map(&:to_html)
end
input
end
|