module CodeRay::Encoders::HTML::Output
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.
Constants
- DIV
- PAGE
- SPAN
- TABLE
Attributes
css[RW]
wrapped_in[W]
Public Instance Methods
apply_title!(title)
click to toggle source
# File lib/coderay/encoders/html/output.rb, line 57 def apply_title! title self.sub!(/(<title>)(<\/title>)/) { $1 + title + $2 } self end
stylesheet(in_tag = false)
click to toggle source
# File lib/coderay/encoders/html/output.rb, line 88 def stylesheet in_tag = false Output.make_stylesheet @css, in_tag end
wrap!(element, *args)
click to toggle source
# 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
wrap_in!(template)
click to toggle source
# File lib/coderay/encoders/html/output.rb, line 52 def wrap_in! template Template.wrap! self, template, 'CONTENT' self end
wrapped_in()
click to toggle source
# File lib/coderay/encoders/html/output.rb, line 47 def wrapped_in @wrapped_in ||= nil end
wrapped_in?(element)
click to toggle source
# File lib/coderay/encoders/html/output.rb, line 43 def wrapped_in? element wrapped_in == element end