我正在用虾创建表格。我尝试了各种各样的东西,但是我无法摆脱输出中的html标签。
这是我的报告代码:
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
我的post_decorator.rb如下所示:
def text
h.simple_format(object.text)
end
当我运行报告时,“Nachricht”列中的文字如下所示:
p&gt; Lorem ipsum dolor坐下来,念念 adipiscing elit。 Quamvis enim depravatae 非sint,pravae tamen esse possunt。桑达 ad bona praeterita redeamus。 Graece donan,Latine voluptatem vocant。双核 Reges:constructio interrete。 Quod quidem 我喜欢学术界的etiam。 Idemque 在animum等人的diviserunt naturam hominis 语料库。 Eadem fortitudinis比率reperietur。 Ita relinquet duas,de quibus etiam atque etiam thoughtfulret./p>
为什么我有这些“half-”标签(例如:p&gt;)以及如何摆脱它们?
谢谢!