• 如何使用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个__

    更多内容请参考这里

  • 相关阅读:
    JavaScript中的几种继承方式对比
    JavaScript垃圾收集-标记清除和引用计数
    PHP安装sqlsrv扩展步骤,PHP如何连接上SQL
    HTML5的应用缓存
    实现跨域请求的4种方法
    JSON的详细介绍
    Ajax的方法和使用代码
    git常用命令
    关于BOM
    DOM之表格与表单基础分享
  • 原文地址:https://www.cnblogs.com/nbkhic/p/2114840.html
Copyright © 2020-2023  润新知