Markdown to plain text in Ruby?

后端 未结 3 1825
盖世英雄少女心
盖世英雄少女心 2021-01-07 21:26

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

3条回答
  •  盖世英雄少女心
    2021-01-07 21:45

    Converting HTML to plain text with Ruby is not a problem, but of course you'll lose all markup. If you only want to get rid of some of the Markdown syntax, it probably won't yield the result you're looking for.

    The bottom line is that unrendered Markdown is intended to be used as plain text, therefore converting it to plain text doesn't really make sense. All Ruby implementations that I have seen follow the same interface, which does not offer a way to strip syntax (only including to_html, and text, which returns the original Markdown text).

提交回复
热议问题