What is RedCloth

RedCloth is a module for using Textile in Ruby. Textile is a text format. A very simple text format. Another stab at making readable text that can be converted to HTML .

What is Textile?

Textile is a simple markup language.

textiletohtml
_a phrase_ ->a phrase
*a phrase* ->a phrase
_*a phrase*_ ->a phrase
"Google":http://google.com ->Google

No need to use verbose HTML to build your docs, your blogs, your pages. Textile gives you readable text while you’re writing and beautiful text for your readers. And if you need to break out into HTML , Textile will allow you to do so.

Textile also handles some subtleties of formatting which will enhance your document’s readability:

  • Single- and double-quotes around words or phrases are converted to curly quotations, much easier on the eye. “Observe!”
  • Double hyphens are replaced with an em-dash. Observe—very nice!
  • Single hyphens are replaced with en-dashes. Observe – so cute!
  • Triplets of periods become an ellipsis. Observe…
  • The letter ‘x’ becomes a dimension sign when used alone. Observe: 2×2.
  • Conversion of (TM) to™, (R) to®, (C) to©.

For more on Textile’s language, hop over to A Textile Reference .

Using RedCloth

The RedCloth class is an extension of Ruby’s String class. Use it like you would a String:

  >> r = RedCloth.new "*strong text* and _emphasized text_" 
  => "*strong text* and _emphasized text_" 
  >> r.gsub!( 'text', 'words' )
  => "*strong words* and _emphasized words_" 

To generate HTML from your RedCloth object, use the RedCloth#to_html method:

  >> r.to_html
  => "

strong words and emphasized words

"

Installing RedCloth

To install RedCloth via RubyGems:

  gem install RedCloth

Or download RedCloth and simply run the install.rb like so:

  ruby install.rb config
  ruby install.rb setup
  sudo ruby install.rb install
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值