Class: HtmlMe::Converter
- Inherits:
-
Object
- Object
- HtmlMe::Converter
- Defined in:
- lib/html_me.rb
Instance Attribute Summary collapse
-
#code_converter ⇒ Object
Returns the value of attribute code_converter.
-
#in_source ⇒ Object
Returns the value of attribute in_source.
-
#out_source ⇒ Object
Returns the value of attribute out_source.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(&block) ⇒ Converter
constructor
A new instance of Converter.
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_converter ⇒ Object
Returns the value of attribute code_converter.
7 8 9 |
# File 'lib/html_me.rb', line 7 def code_converter @code_converter end |
#in_source ⇒ Object
Returns the value of attribute in_source.
7 8 9 |
# File 'lib/html_me.rb', line 7 def in_source @in_source end |
#out_source ⇒ Object
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
#convert ⇒ Object
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 |