有誰知道我可以如何將html轉換爲純文本。那麼我真的需要將RedCloth轉換爲純文本,無論哪種方式都可以。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以純文本格式