Module: TmSyntaxHighlighting::Helper

Defined in:
lib/tm_syntax_highlighting.rb

Instance Method Summary collapse

Instance Method Details

#code(code, options = {}) ⇒ Object



3
4
5
6
7
8
# File 'lib/tm_syntax_highlighting.rb', line 3

def code(code, options = {})
  options = TmSyntaxHighlighting.defaults.merge_with(options)
  TmSyntaxHighlighting.defaults[:current_themes] << options[:theme]
  options[:lang] = "plain_text" unless Uv.syntaxes.include?(options[:lang])
  Uv.parse(code, "xhtml", options[:lang], options[:line_numbers], options[:theme])
end

#syntax_css(theme = nil) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/tm_syntax_highlighting.rb', line 10

def syntax_css(theme = nil)
  themes = [theme || TmSyntaxHighlighting.defaults.options[:theme]].flatten
  themes = (themes & TmSyntaxHighlighting.defaults[:current_themes]) if theme.nil? && TmSyntaxHighlighting.defaults[:current_themes]
  themes.uniq.collect do |theme|
    stylesheet_link_tag "syntax/#{theme}"
  end.join("\n")
end