降价到Ruby中的纯文本?
问题描述:
我目前正在使用BlueCloth在Ruby中处理Markdown并将其显示为HTML,但是在一个位置,我需要将其作为纯文本(没有Markdown的一部分).有办法实现吗?
I'm currently using BlueCloth to process Markdown in Ruby and show it as HTML, but in one location I need it as plain text (without some of the Markdown). Is there a way to achieve that?
是否存在降级到纯文本的方法?有没有一种我可以感觉到BlueCloth的结果的html-to-plain-text方法?
Is there a markdown-to-plain-text method? Is there an html-to-plain-text method that I could feel the result of BlueCloth?
答
RedCarpet gem具有 Redcarpet :: Render :: StripDown 渲染器,可将Markdown转换为纯文本.
RedCarpet gem has a Redcarpet::Render::StripDown renderer which "turns Markdown into plaintext".
复制并修改它以满足您的需求.
Copy and modify it to suit your needs.
或者像这样使用它:
Redcarpet::Markdown.new(Redcarpet::Render::StripDown).render(markdown)