This module is included in the output String of the HTML Encoder.
It provides methods like wrap, div, page etc.
Remember to use clone instead of dup to keep the modules the object was extended with.
TODO: Rewrite this without monkey patching.
# File lib/coderay/encoders/html/output.rb, line 57 def apply_title! title self.sub!(%r(<title>)(<\/title>)/) { $1 + title + $2 } self end
# File lib/coderay/encoders/html/output.rb, line 88 def stylesheet in_tag = false Output.make_stylesheet @css, in_tag end
# File lib/coderay/encoders/html/output.rb, line 62 def wrap! element, *args return self if not element or element == wrapped_in case element when :div raise "Can't wrap %p in %p" % [wrapped_in, element] unless wrapped_in? nil wrap_in! DIV when :span raise "Can't wrap %p in %p" % [wrapped_in, element] unless wrapped_in? nil wrap_in! SPAN when :page wrap! :div if wrapped_in? nil raise "Can't wrap %p in %p" % [wrapped_in, element] unless wrapped_in? :div wrap_in! Output.page_template_for_css(@css) if args.first.is_a?(Hash) && title = args.first[:title] apply_title! title end self when nil return self else raise "Unknown value %p for :wrap" % element end @wrapped_in = element self end
# File lib/coderay/encoders/html/output.rb, line 52 def wrap_in! template Template.wrap! self, template, 'CONTENT' self end
# File lib/coderay/encoders/html/output.rb, line 47 def wrapped_in @wrapped_in ||= nil end
# File lib/coderay/encoders/html/output.rb, line 43 def wrapped_in? element wrapped_in == element end