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.
Methods
Constants
| SPAN | = | Template.new '<span class="CodeRay"><%CONTENT%></span>' |
| DIV | = | Template.new <<-DIV <div class="CodeRay"> <div class="code"><pre><%CONTENT%></pre></div> </div> DIV |
| TABLE | = | Template.new <<-TABLE <table class="CodeRay"><tr> <td class="line-numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre><%LINE_NUMBERS%></pre></td> <td class="code"><pre><%CONTENT%></pre></td> </tr></table> TABLE |
| PAGE | = | Template.new <<-PAGE <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> .CodeRay .line-numbers a { text-decoration: inherit; color: inherit; } <%CSS%> </style> </head> <body style="background-color: white;"> <%CONTENT%> </body> </html> PAGE |
Attributes
| [RW] | css | |
| [W] | wrapped_in |
Public Instance methods
# File lib/coderay/encoders/html/output.rb, line 58 def apply_title! title self.sub!(/(<title>)(<\/title>)/) { $1 + title + $2 } self end
# File lib/coderay/encoders/html/output.rb, line 89 def stylesheet in_tag = false Output.make_stylesheet @css, in_tag end
# File lib/coderay/encoders/html/output.rb, line 63 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 53 def wrap_in! template Template.wrap! self, template, 'CONTENT' self end
# File lib/coderay/encoders/html/output.rb, line 48 def wrapped_in @wrapped_in ||= nil end
# File lib/coderay/encoders/html/output.rb, line 44 def wrapped_in? element wrapped_in == element end
