class Typo class Textfilter class TMCode < TextFilterPlugin::MacroPre plugin_display_name "TMCode" plugin_description "Ensures the CSS files for TextMate syntax highlighting are included." def self.help_text %{ You can use `` to include blocks of HTML code output by TextMate. Optionally you can default the block to hidden, to be expanded with a `` reference. Expand or collapse my code. You can also provide the optional attribute `theme` which specifies which theme to use for colorizing. The list of available themes can be seen in the config screen, where you can also pick a theme to use if the `theme` attribute isn't specified. The HTML code that you enclose with this macro can be generated by selecting a block of text in TextMate and selecting the TextMate->Create HTML From Document command. } end def self.macrofilter(blog,content,attrib,params,text="") isHidden = attrib['hidden'] || 'false' blockID = attrib['id'] theme = (attrib['theme'] || config_value(params, 'default-theme')).downcase.gsub(' ', '_') isHidden = ["yes", "true", "1", "hidden"].include?(isHidden.downcase) set_whiteboard blog, content, isHidden, theme unless content.nil? %{
\n#{text}\n
} end def self.default_config {"default-theme" => {:default => "twilight", :description => "Default theme for tmcode snippets", :options => ["Twilight", "iPlastic", "Dawn", 'Space Cadet']}} end def self.set_whiteboard(blog, content, isHidden, theme) content.whiteboard['page_header_tmcode'] = <<-HTML HTML content.whiteboard["page_header_tmcode_#{theme}"] = <<-HTML unless theme.blank? HTML TMCodeRef.set_whiteboard blog, content if isHidden end end class TMCodeRef < TextFilterPlugin::MacroPost plugin_display_name "TMCodeRef" plugin_description "Adds expand/collapse links for TMCode sections." def self.help_text %{ Use `text` to cause `text` to be a hyperlink which toggles the collapsed state of the `` block referenced by the `id`. } end def self.macrofilter(blog,content,attrib,params,text="") blockID = attrib['id'] set_whiteboard blog, content %{#{text}} end def self.set_whiteboard(blog, content) content.whiteboard['page_header_codecollapse'] = <<-HTML HTML end end end end