# Discount is an implementation of John Gruber's Markdown markup
# language in C. It implements all of the language as described in
# {Markdown Syntax}[http://daringfireball.net/projects/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
#
class RDiscount
VERSION = '2.2.0.2'
# Original Markdown formatted text.
attr_reader :text
# Set true to have smarty-like quote translation performed.
attr_accessor :smart
# Do not output tags included in the source text.
attr_accessor :filter_styles
# Do not output any raw HTML included in the source text.
attr_accessor :filter_html
# RedCloth compatible line folding -- not used for Markdown but
# included for compatibility.
attr_accessor :fold_lines
# Enable php markdown extra-style footnotes
attr_accessor :footnotes
# Enable Table Of Contents generation
attr_accessor :generate_toc
# Do not process ![] and remove tags from the output.
attr_accessor :no_image
# Do not process [] and remove tags from the output.
attr_accessor :no_links
# Do not process tables
attr_accessor :no_tables
# Disable superscript and relaxed emphasis processing.
attr_accessor :strict
# Convert URL in links, even if they aren't encased in <>
attr_accessor :autolink
# Don't make hyperlinks from [][] links that have unknown URL types.
attr_accessor :safelink
# Do not process pseudo-protocols like [](id:name)
attr_accessor :no_pseudo_protocols
# Disable superscript processing.
attr_accessor :no_superscript
# Disable strikethrough processing.
attr_accessor :no_strikethrough
# 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 tags.
# * :filter_html - Do not output any raw HTML tags included in
# the source text.
# * :fold_lines - RedCloth compatible line folding (not used).
# * :footnotes - PHP markdown extra-style footnotes.
# * :generate_toc - Enable Table Of Contents generation
# * :no_image - Do not output any tags.
# * :no_links - Do not output any tags.
# * :no_tables - Do not output any tables.
# * :strict - Disable superscript and relaxed emphasis processing.
# * :autolink - Greedily urlify links.
# * :safelink - Do not make links for unknown URL types.
# * :no_pseudo_protocols - Do not process pseudo-protocols.
# * :no_superscript - Disable superscript processing.
# * :no_strikethrough - Disable strikethrough processing.
#
def initialize(text, *extensions)
@text = text
extensions.each { |e| send("#{e}=", true) }
end
end
Markdown = RDiscount unless defined? Markdown
require 'rdiscount.so'