module CustomTags #TODO - allow method specification instead of line numbers def source(opts) local_path, highlighted, range = /([^ :]*)(?::(\d+))?(?: (\d+-\d+))?/.match(opts[:text])[1..3] code = File.readlines(File.join(File.expand_path(File.dirname(__FILE__)), local_path)) if range start, finish = range.split("-").collect{|i| i.to_i} code = code[(start-1)..(finish-1)] end start ||= 1 indentation_level = /^ */.match(code[0])[0].size code.collect!{|l| l.sub(/^ {#{indentation_level}}/, '')} #remove indendation code = code.join html = "