module Dionysus::Redcarpet::Includes
Public Instance Methods
preprocess_with_includes(full_document)
click to toggle source
# File lib/dionysus/redcarpet/includes.rb, line 19 def preprocess_with_includes(full_document) lines = full_document.split($/) lines.each_with_index do |ln, i| if m = ln.match(LINE_DIRECTIVE_REGEXP) path = Pathname.new(m[1]) if path.file? newlines = path.readlines newlines.collect! {|ln| ln.chomp} newlines.shift while(newlines.first.blank?) newlines.pop while(newlines.last.blank?) lines[i] = newlines else warn "[WARNING] Cannot find path %s to include"%[path.to_s] end end end full_document = lines.flatten.join("\n") if respond_to? :preprocess_without_includes preprocess_without_includes(full_document) else full_document end end