lib/docxify/element/paragraph.rb in docxify-0.1.0 vs lib/docxify/element/paragraph.rb in docxify-0.1.1

- old
+ new

@@ -19,14 +19,14 @@ @hanging_cm = options[:hanging_cm] || 0 end def to_s(_container = nil) nodes = if @inline_styling - parse_simple_html(@text) - else - [@text.gsub("<", "&lt;").gsub(">", "&gt;")] - end + parse_simple_html(@text) + else + [@text.gsub("<", "&lt;").gsub(">", "&gt;")] + end xml = "<w:p>" xml << "<w:pPr>" xml << "<w:jc w:val=\"#{@align}\"/>" if @align != :left @@ -56,12 +56,12 @@ <w:rFonts w:ascii="#{@font}" w:cs="#{@font}" w:hAnsi="#{@font}"/> <w:color w:val="#{@color.gsub("#", "")}"/> <w:sz w:val="#{DocXify.pt2halfpt(@size)}"/> <w:szCs w:val="#{DocXify.pt2halfpt(@size)}"/> #{"<w:highlight w:val=\"yellow\"/>" if @highlight} - #{"<w:b/><w:bCs/>" if node.is_a?(Hash) && node[:tag] == "b"} - #{"<w:i/><w:iCs/>" if node.is_a?(Hash) && node[:tag] == "i"} - #{"<w:u w:val=\"single\"/>" if node.is_a?(Hash) && (node[:tag] == "u" || node[:tag] == "a")} + #{"<w:b/><w:bCs/>" if node.is_a?(Hash) && node[:tag].match?("b")} + #{"<w:i/><w:iCs/>" if node.is_a?(Hash) && node[:tag].match?("i")} + #{"<w:u w:val=\"single\"/>" if node.is_a?(Hash) && (node[:tag].match?("u") || node[:tag] == "a")} #{"<w:rStyle w:val=\"Hyperlink\"/>" if node.is_a?(Hash) && node[:tag] == "a"} </w:rPr> XML content = node.is_a?(Hash) ? node[:content] : node