【发布时间】:2009-06-05 09:33:05
【问题描述】:
有谁知道我如何使用 Ruby 将 html 转换为纯文本。好吧,我真的需要将 RedCloth 转换为纯文本,无论哪种方式都可以。
我不是在谈论仅仅删除标签(这就是我到目前为止所做的一切)。例如,我想要一个有序列表来保留数字,无序列表使用星号表示项目符号等。
def red_cloth_to_plain_text(s)
s = RedCloth.new(s).to_html
s = strip_tags(s)
s = html_unescape(s) # reverse of html_escape
s = undo_red_cloths_html_codes(s)
return s
end
也许我必须尝试将 RedCloth 转换为纯文本格式化程序
【问题讨论】:
标签: ruby formatting