Class RDiscount

  1. lib/rdiscount.rb
Parent: Object

Discount is an implementation of John Gruber‘s Markdown markup language in C. It implements all of the language as described in Markdown Syntax and passes the Markdown 1.0 test suite. The RDiscount extension makes the Discount processor available via a Ruby C Extension library.

Usage

RDiscount implements the basic protocol popularized by RedCloth and adopted by BlueCloth:

  require 'rdiscount'
  markdown = RDiscount.new("Hello World!")
  puts markdown.to_html

Replacing BlueCloth

Inject RDiscount into your BlueCloth-using code by replacing your bluecloth require statements with the following:

  begin
    require 'rdiscount'
    BlueCloth = RDiscount
  rescue LoadError
    require 'bluecloth'
  end

Methods

public class

  1. new

public instance

  1. to_html

Public class methods

new (text, *extensions)

Create a RDiscount Markdown processor. The text argument should be a string containing Markdown text. Additional arguments may be supplied to set various processing options:

  • :smart - Enable SmartyPants processing.
  • :filter_styles - Do not output <style> tags.
  • :filter_html - Do not output any raw HTML tags included in the source text.
  • :fold_lines - RedCloth compatible line folding (not used).

NOTE: The :filter_styles and :filter_html extensions are not yet implemented.

[show source]
    # File lib/rdiscount.rb, line 53
53:   def initialize(text, *extensions)
54:     @text  = text
55:     @smart = nil
56:     @filter_styles = nil
57:     @filter_html = nil
58:     @fold_lines = nil
59:     extensions.each { |e| send("#{e}=", true) }
60:   end

Public instance methods

to_html ()

Convert the Markdown text to HTML.

[show source]
    # File lib/rdiscount.rb, line 65
65:   def to_html
66:     raise NotImplemented
67:   end