diff --git a/doc/_support/converter/lib/processor.rb b/doc/_support/converter/lib/processor.rb index 9387cb8f..88a996e6 100644 --- a/doc/_support/converter/lib/processor.rb +++ b/doc/_support/converter/lib/processor.rb @@ -3,6 +3,7 @@ module Processor; end require_relative "processor/base" require_relative "processor/article" require_relative "processor/footer" +require_relative "processor/head" require_relative "processor/header" require_relative "processor/page" require_relative "processor/rss" diff --git a/doc/_support/converter/lib/processor/head.rb b/doc/_support/converter/lib/processor/head.rb new file mode 100644 index 00000000..b12fb985 --- /dev/null +++ b/doc/_support/converter/lib/processor/head.rb @@ -0,0 +1,28 @@ +module Processor + class Head + attr_reader :page + attr_reader :root_relative + + def initialize(page, root_relative) + @page = page + @root_relative = root_relative + end + + def head() + [ + '', + ].join("") + end + + def append_to_head(document) + output = document.split("\n") + idx = output.find_index do |line| + line.match(/<\/head>/) + end + output.insert(idx, head) + output.join("\n") + end + end +end diff --git a/doc/_support/converter/lib/processor/header.rb b/doc/_support/converter/lib/processor/header.rb index a4d159d8..76200083 100644 --- a/doc/_support/converter/lib/processor/header.rb +++ b/doc/_support/converter/lib/processor/header.rb @@ -16,12 +16,13 @@ module Processor ].join("") end - def append_header(document) + def header() header = ERB.new(File.read(File.join($options["root"], "_support/header.erb"))) rootrel = root_relative + header.result(binding) + end - header = header.result(binding) - + def append_header(document) output = document.split("\n") idx = output.find_index do |line| line.match(/ + @output = Processor::Head.new(@page, @root_relative).append_to_head(@output) + # Force the site header on the generated page. @output = Processor::Header.new(@page, @root_relative).append_header(@output)