Method: MyDocx#to_html
- Defined in:
- lib/simple_docx_generator/mydocx.rb
#to_html(class_name = '') ⇒ Object
to_html
ydocxというパーサーを介して<div>タグで囲んだhtmlを返しますオプションで<div>タグのclass名を指定できます
79 80 81 82 83 84 85 86 87 |
# File 'lib/simple_docx_generator/mydocx.rb', line 79 def to_html(class_name='') ydocx = YDocx::Document.open File.join(@dir, @filename) html = Nokogiri::HTML ydocx.to_html nodes = html.xpath("//body").children myhtml = Nokogiri::HTML::DocumentFragment.parse "<div></div>" myhtml.child['class'] = class_name unless class_name.empty? myhtml.child << nodes myhtml.to_s end |