Im using prawn to create pdfs that contain much data in table format and some lists. The problem with the lists is that Im just using text as lists because there is no semantic
I think a better approach is pre-processing the HTML string using Nokogiri, leaving only basics tags that Prawn could manage with "inline_format" option, as in this code:
def self.render_html_text(instr)
# Replacing tag
outstr = instr.gsub('
',"\n")
outstr.gsub!('
',"\n")
# Replacing & - tags
doc = Nokogiri::HTML(outstr)
doc.search('//ul').each do |ul|
content = Nokogiri::HTML(ul.inner_html).xpath('//li').map{|n| "• #{n.inner_html}\n"}.join
ul.replace(content)
end
#removing some tags inserted by Nokogiri
doc.at_xpath('//body').inner_html
end