我使用 RedCloth 将纯文本保存在一个表单中并将其转换为 HTML。例如,在我的表单中编写并保存它,将使它以与我编写它的方式完全相同的方式显示:
This sentence
gets inserted into it
proper html syntax
to preserve line breakage.
使用此代码:
def parse_code
self.text = RedCloth.new(text).to_html
end
然后我可以用这个重新显示它:
= raw post.text
但是当我想编辑它时,它会返回给我:
<p>This sentence</p>
<p>gets inserted into it</p>
<p>proper html syntax</p>
<p>to preserve line breakage</p>
我怎样才能制作它,这样当我编辑它时,它看起来和我去保存它之前的样子一样?
谢谢!