Class: Redcarpet
- Inherits:
-
Object
- Object
- Redcarpet
- Defined in:
- lib/redcarpet.rb,
ext/redcarpet.c
Overview
Upskirt is an implementation of John Gruber’s Markdown markup language. Upskirt is safe, fast and production ready.
Redcarpet is Upskirt with a touch of Ruby. It is mostly based on Ryan Tomayko’s RDiscount, and inspired by Rick Astley wearing a kilt.
Redcarpet is a drop-in replacement for BlueCloth, RedCloth and RDiscount.
Usage
Redcarpet implements the basic protocol popularized by RedCloth and adopted by BlueCloth:
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
Replacing BlueCloth
Inject Redcarpet into your BlueCloth-using code by replacing your bluecloth require statements with the following:
begin
require 'redcarpet'
BlueCloth = Redcarpet
rescue LoadError
require 'bluecloth'
end
Direct Known Subclasses
Constant Summary collapse
- VERSION =
'1.9.0'
Instance Attribute Summary collapse
-
#autolink ⇒ Object
Enable the Autolinking extension.
-
#fenced_code ⇒ Object
Enable PHP-Markdown fenced code extension.
-
#filter_html ⇒ Object
Do not output any raw HTML included in the source text.
-
#filter_styles ⇒ Object
Do not output
<style>
tags included in the source text. -
#generate_toc ⇒ Object
Add TOC anchors to every header.
-
#hard_wrap ⇒ Object
Treat newlines in paragraphs as real line breaks, GitHub style.
-
#lax_htmlblock ⇒ Object
Allow HTML blocks inside of paragraphs without being surrounded by newlines.
-
#no_image ⇒ Object
Do not process
![]
and remove<img>
tags from the output. -
#no_links ⇒ Object
Do not process
[]
and remove<a>
tags from the output. -
#safelink ⇒ Object
Don’t make hyperlinks from
[][]
links that have unknown URL types. -
#smart ⇒ Object
Set true to have smarty-like quote translation performed.
-
#strict ⇒ Object
Disable superscript and relaxed emphasis processing.
-
#strikethrough ⇒ Object
Enable PHP-Markdown ~~strikethrough~~ extension.
-
#tables ⇒ Object
Enable PHP-Markdown tables extension.
-
#text ⇒ Object
readonly
Original Markdown formatted text.
Instance Method Summary collapse
-
#initialize(text, *extensions) ⇒ Redcarpet
constructor
A new instance of Redcarpet.
- #to_html(*args) ⇒ Object
- #toc_content(*args) ⇒ Object
Constructor Details
#initialize(text, *extensions) ⇒ Redcarpet
Returns a new instance of Redcarpet.
76 77 78 79 |
# File 'lib/redcarpet.rb', line 76 def initialize(text, *extensions) @text = text extensions.each { |e| send("#{e}=", true) } end |
Instance Attribute Details
#autolink ⇒ Object
Enable the Autolinking extension
62 63 64 |
# File 'lib/redcarpet.rb', line 62 def autolink @autolink end |
#fenced_code ⇒ Object
Enable PHP-Markdown fenced code extension
71 72 73 |
# File 'lib/redcarpet.rb', line 71 def fenced_code @fenced_code end |
#filter_html ⇒ Object
Do not output any raw HTML included in the source text.
41 42 43 |
# File 'lib/redcarpet.rb', line 41 def filter_html @filter_html end |
#filter_styles ⇒ Object
Do not output <style>
tags included in the source text.
38 39 40 |
# File 'lib/redcarpet.rb', line 38 def filter_styles @filter_styles end |
#generate_toc ⇒ Object
Add TOC anchors to every header
59 60 61 |
# File 'lib/redcarpet.rb', line 59 def generate_toc @generate_toc end |
#hard_wrap ⇒ Object
Treat newlines in paragraphs as real line breaks, GitHub style
50 51 52 |
# File 'lib/redcarpet.rb', line 50 def hard_wrap @hard_wrap end |
#lax_htmlblock ⇒ Object
Allow HTML blocks inside of paragraphs without being surrounded by newlines
74 75 76 |
# File 'lib/redcarpet.rb', line 74 def lax_htmlblock @lax_htmlblock end |
#no_image ⇒ Object
Do not process ![]
and remove <img>
tags from the output.
44 45 46 |
# File 'lib/redcarpet.rb', line 44 def no_image @no_image end |
#no_links ⇒ Object
Do not process []
and remove <a>
tags from the output.
47 48 49 |
# File 'lib/redcarpet.rb', line 47 def no_links @no_links end |
#safelink ⇒ Object
Don’t make hyperlinks from [][]
links that have unknown URL types.
56 57 58 |
# File 'lib/redcarpet.rb', line 56 def safelink @safelink end |
#smart ⇒ Object
Set true to have smarty-like quote translation performed.
35 36 37 |
# File 'lib/redcarpet.rb', line 35 def smart @smart end |
#strict ⇒ Object
Disable superscript and relaxed emphasis processing.
53 54 55 |
# File 'lib/redcarpet.rb', line 53 def strict @strict end |
#strikethrough ⇒ Object
Enable PHP-Markdown ~~strikethrough~~ extension
68 69 70 |
# File 'lib/redcarpet.rb', line 68 def strikethrough @strikethrough end |
#tables ⇒ Object
Enable PHP-Markdown tables extension
65 66 67 |
# File 'lib/redcarpet.rb', line 65 def tables @tables end |
#text ⇒ Object (readonly)
Original Markdown formatted text.
32 33 34 |
# File 'lib/redcarpet.rb', line 32 def text @text end |
Instance Method Details
#to_html(*args) ⇒ Object
131 132 133 134 135 |
# File 'ext/redcarpet.c', line 131
static VALUE
rb_redcarpet_to_html(int argc, VALUE *argv, VALUE self)
{
return rb_redcarpet__render(self, REDCARPET_RENDER_XHTML);
}
|
#toc_content(*args) ⇒ Object
125 126 127 128 129 |
# File 'ext/redcarpet.c', line 125
static VALUE
rb_redcarpet_toc(int argc, VALUE *argv, VALUE self)
{
return rb_redcarpet__render(self, REDCARPET_RENDER_TOC);
}
|