降价到Ruby中的纯文本? [英] Markdown to plain text in Ruby?

查看:87
本文介绍了降价到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)

这篇关于降价到Ruby中的纯文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆