Class: HtmlMe::Converter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Converter



9
10
11
# File 'lib/html_me.rb', line 9

def initialize( &block )
  instance_eval &block if block_given?
end

Instance Attribute Details

#code_converterObject

Returns the value of attribute code_converter.



7
8
9
# File 'lib/html_me.rb', line 7

def code_converter
  @code_converter
end

#in_sourceObject

Returns the value of attribute in_source.



7
8
9
# File 'lib/html_me.rb', line 7

def in_source
  @in_source
end

#out_sourceObject

Returns the value of attribute out_source.



7
8
9
# File 'lib/html_me.rb', line 7

def out_source
  @out_source
end

Instance Method Details

#convertObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/html_me.rb', line 14

def convert
  require 'redcloth'
  require 'hpricot'
  
  doc = RedCloth.new( in_source.read )
  html = Hpricot( doc.to_html )
  ( html/"pre" ).each do | code_block |
    code_block.inner_html = code_converter.convert code_block.inner_html, false # no additional pre tags needed
  end

  out_source.puts html.to_s
end