Class: Prezio::SyntaxHighlighter

Inherits:
Object
  • Object
show all
Defined in:
lib/prezio/syntax_highlighter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ SyntaxHighlighter

Returns a new instance of SyntaxHighlighter.



10
11
12
# File 'lib/prezio/syntax_highlighter.rb', line 10

def initialize(html)
  @html = html
end

Class Method Details

.highlight(html) ⇒ Object



6
7
8
# File 'lib/prezio/syntax_highlighter.rb', line 6

def self.highlight(html)
  new(html).to_s
end

Instance Method Details

#to_sObject



14
15
16
17
18
19
20
21
# File 'lib/prezio/syntax_highlighter.rb', line 14

def to_s
  doc = Nokogiri::HTML.fragment(@html)

  replace_code_tags(doc)
  add_highliting_styles(doc)

  doc.to_s
end