Commit ae9d7481 authored by Tobias Schmidt's avatar Tobias Schmidt

Handle embedded images in repository docs

parent b20ed77d
...@@ -33,6 +33,14 @@ route '/assets/*' do ...@@ -33,6 +33,14 @@ route '/assets/*' do
end end
end end
# TODO(ts): Remove these hacks once the nanoc4 upgrade is done.
compile '*/images/*' do
end
route '*/images/*' do
item.identifier.chop + '.' + item[:extension]
end
route '/README/' do route '/README/' do
'/README.md' '/README.md'
end end
......
...@@ -9,9 +9,8 @@ class NormalizeLinks < ::Nanoc::Filter ...@@ -9,9 +9,8 @@ class NormalizeLinks < ::Nanoc::Filter
def run(content, config = {}) def run(content, config = {})
doc = Nokogiri::HTML(content) doc = Nokogiri::HTML(content)
links = doc.xpath('//a')
links.each do |link| doc.xpath('//a').each do |link|
link['href'] = link['href'] =
case case
when link['href'].start_with?(DOMAIN) when link['href'].start_with?(DOMAIN)
...@@ -26,6 +25,11 @@ class NormalizeLinks < ::Nanoc::Filter ...@@ -26,6 +25,11 @@ class NormalizeLinks < ::Nanoc::Filter
end end
end end
doc.xpath('//img').each do |img|
next if img['src'].start_with?('/') || img['src'].start_with?('http')
img['src'] = File.join("../", img['src'])
end
doc.to_s doc.to_s
end end
......
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