如何使用bluecloth

bluecloth是一种ruby语言实现的text to html转换器。关于bluecloth的介绍如下:

BlueCloth is a Ruby implementation of Markdown, a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).
bluecloth作为老牌的著名rubygem扩展,其拥有稳定的性能和庞大的用户群体。最近bluecloth升级至2.0,其最大的改变为重写了转换核心,使得转换速度提升了不少。

bluecloth的使用非常简单,如下面代码所示

1 \#encoding: utf-8
2 require 'rubygems'
3 require 'bluecloth'
4
5 puts BlueCloth.new(ARGF.read).to_html

  ruby bluecloth.rb 1.txt > 1.html

这样就可以将1.txt转换成hmtl了。bluecloth的转换速度卓绝,哪怕是比较大的txt文档,其转换起来依然是轻松自然,效率高超。


Markdown语法简介

  • 标题(h1…h7):使用#号来标记。#表示h1, ##表示h2依次类推,如
    ## This is h2
  • 列表(li):使用*号来标记。如
    * this is the first item
  • 链接(a):[]表示链接文字,后跟()标明链接,如
    [google] (http://www.google.com)
  • code(code):缩进4个空格或1个tab即被当成是code处理
  • 引用(backquote):>表示
  • 加粗(strong):2个*号或者2个__

更多内容请参考这里

posted @ 2011-07-23 14:18  乙醇  阅读(407)  评论(0编辑  收藏  举报

友情链接 虫师的blog  测试教程网  重定向科技  省略