Text in prawn table shows with html tags

446 Views Asked by At

I'm creating table in prawn. I've tried all sorts of things, but I can't get rid of the html tags in the output.

Here my report code:

class ReportPost
  include Prawn::View
  require "prawn/measurement_extensions"

  #Color Codes
  DARK_BLUE =  "111f6a";
  LIGHT_BLUE = "009de0";
  DARK_GREY =  "a0a0a0";
  BLACK =      "000000";
  LIGHT_GREY = "f4f4f4";
  WHITE =      "ffffff";

  #Text Sizes
  SIZE_TITLE =  18;
  SIZE_NORMAL=  9;
  LEADING = 2.5;

  #SPACING
  MARGIN_LEFT = 20.mm;
  MARGIN_TOP = 20.mm;

  def initialize(current_case)
   super()
   @posts = current_case.posts
   settings
   posts_section
  end

  def heja_table(data, last_column,old_y,column_widths)
   bounding_box([bounds.left, bounds.top-MARGIN_TOP],
   :width => bounds.width, :height => bounds.height) do
    self.y = old_y
    table(data,
    :header => true,
    :position => MARGIN_LEFT,
    :column_widths => column_widths,
    :row_colors => [LIGHT_GREY, WHITE],
    :cell_style => {:padding => [2.mm,2.mm,2.mm,2.mm], :size => SIZE_NORMAL, :leading => LEADING, :border_width => 0.5,:inline_format => true}) do
      style(columns(0), :borders => [:top, :bottom, :right])
      style(columns(last_column), :borders => [:top, :left, :bottom])
      style(row(0), :text_color => LIGHT_BLUE)
    end
  end
end

def settings
 font_families.update(
  "Bill Corp" => {
    :normal => "#{Rails.root}/app/assets/fonts/BillCorpMedium.ttf",
    :bold => "#{Rails.root}/app/assets/fonts/BillCorpBold.ttf"
  }
 )

 font "Bill Corp"
 fallback_fonts ["Courier"]
end

def posts_section
 if @posts.any?
  data = [[I18n.t(:'pdf.posts.author'),I18n.t(:'pdf.posts.subject'),I18n.t(:'pdf.posts.confirmation'),I18n.t(:'pdf.posts.message')]] +
        @posts.map do |post|
          [post.author.fullname + "<br><color rgb='#{DARK_GREY}'>#{post.time}</color>", post.subject.to_s, list_confirmations(post), post.decorate.text.to_s]
        end
        move_down 40.mm
        old_y = y
        heja_table(data, 3, old_y,[30.mm,35.mm,30.mm,65.mm])
 end
end

def list_confirmations(post)
 post.confirmations.decorate.map do |confirmation|
  name, time = confirmation.user_confirmed_or_confirmation_missing
  name.to_s + "<br><color rgb='#{DARK_GREY}'>#{time.to_s}</color>"
  end.join("\n")
 end
end

My post_decorator.rb looks as follows:

def text
    h.simple_format(object.text)
end

When I run the report, the text in the column "Nachricht" looks as follows:

p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quamvis enim depravatae non sint, pravae tamen esse possunt. Sed ad bona praeterita redeamus. Graece donan, Latine voluptatem vocant. Duo Reges: constructio interrete. Quod quidem iam fit etiam in Academia. Idemque diviserunt naturam hominis in animum et corpus. Eadem fortitudinis ratio reperietur. Ita relinquet duas, de quibus etiam atque etiam consideret./p>

Why do I have these "half-" tags (example: p>) and how can I get rid of them?

Thanks!

0

There are 0 best solutions below