From 730d12ee48c6966f7c96aca4f6917bf67261b5b0 Mon Sep 17 00:00:00 2001
From: "Suraj N. Kurapati"
Date: Tue, 12 Jul 2011 14:31:03 -0700
Subject: [PATCH 1/3] extconf: assume long is doubleword & short is word
---
ext/extconf.rb | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/ext/extconf.rb b/ext/extconf.rb
index 1bbfe49..f9a9b5d 100644
--- a/ext/extconf.rb
+++ b/ext/extconf.rb
@@ -7,13 +7,8 @@
HAVE_RAND = have_func('rand')
HAVE_SRAND = have_func('srand')
-def sized_int(size, types)
- types.find { |type| check_sizeof(type) == 4 } ||
- abort("no int with size #{size}")
-end
-
-DWORD = sized_int(4, ["unsigned long", "unsigned int"])
-WORD = sized_int(2, ["unsigned int", "unsigned short"])
+DWORD = "unsigned long"
+WORD = "unsigned short"
BYTE = "unsigned char"
$defs.push("-DDWORD='#{DWORD}'")
From b03f0172270a3b4b2429fdb7739acf37a10e0495 Mon Sep 17 00:00:00 2001
From: "Suraj N. Kurapati"
Date: Wed, 13 Jul 2011 09:56:54 -0700
Subject: [PATCH 2/3] use Discount flags instead of custom attributes
---
ext/rdiscount.c | 69 ++++++++++++-----------------------
lib/rdiscount.rb | 83 +++++++++++++++++++-----------------------
test/markdown_test.rb | 51 +++++++++++++-------------
test/rdiscount_test.rb | 36 +++++++++---------
4 files changed, 104 insertions(+), 135 deletions(-)
diff --git a/ext/rdiscount.c b/ext/rdiscount.c
index 86167ff..dd38f2d 100644
--- a/ext/rdiscount.c
+++ b/ext/rdiscount.c
@@ -71,57 +71,34 @@ rb_rdiscount_toc_content(int argc, VALUE *argv, VALUE self)
int rb_rdiscount__get_flags(VALUE ruby_obj)
{
- /* compile flags */
- int flags = MKD_TABSTOP | MKD_NOHEADER;
-
- /* smart */
- if ( rb_funcall(ruby_obj, rb_intern("smart"), 0) != Qtrue )
- flags = flags | MKD_NOPANTS;
-
- /* filter_html */
- if ( rb_funcall(ruby_obj, rb_intern("filter_html"), 0) == Qtrue )
- flags = flags | MKD_NOHTML;
-
- /* generate_toc */
- if ( rb_funcall(ruby_obj, rb_intern("generate_toc"), 0) == Qtrue)
- flags = flags | MKD_TOC;
-
- /* no_image */
- if ( rb_funcall(ruby_obj, rb_intern("no_image"), 0) == Qtrue)
- flags = flags | MKD_NOIMAGE;
-
- /* no_links */
- if ( rb_funcall(ruby_obj, rb_intern("no_links"), 0) == Qtrue)
- flags = flags | MKD_NOLINKS;
-
- /* no_tables */
- if ( rb_funcall(ruby_obj, rb_intern("no_tables"), 0) == Qtrue)
- flags = flags | MKD_NOTABLES;
-
- /* strict */
- if ( rb_funcall(ruby_obj, rb_intern("strict"), 0) == Qtrue)
- flags = flags | MKD_STRICT;
-
- /* autolink */
- if ( rb_funcall(ruby_obj, rb_intern("autolink"), 0) == Qtrue)
- flags = flags | MKD_AUTOLINK;
-
- /* safelink */
- if ( rb_funcall(ruby_obj, rb_intern("safelink"), 0) == Qtrue)
- flags = flags | MKD_SAFELINK;
-
- /* no_pseudo_protocols */
- if ( rb_funcall(ruby_obj, rb_intern("no_pseudo_protocols"), 0) == Qtrue)
- flags = flags | MKD_NO_EXT;
-
-
- return flags;
+ VALUE flags = rb_funcall(ruby_obj, rb_intern("flags"), 0);
+ return NUM2INT(rb_funcall(flags, rb_intern("to_i"), 0));
}
-
void Init_rdiscount()
{
rb_cRDiscount = rb_define_class("RDiscount", rb_cObject);
+ rb_define_const(rb_cRDiscount, "MKD_NOLINKS", INT2NUM(MKD_NOLINKS));
+ rb_define_const(rb_cRDiscount, "MKD_NOIMAGE", INT2NUM(MKD_NOIMAGE));
+ rb_define_const(rb_cRDiscount, "MKD_NOPANTS", INT2NUM(MKD_NOPANTS));
+ rb_define_const(rb_cRDiscount, "MKD_NOHTML", INT2NUM(MKD_NOHTML));
+ rb_define_const(rb_cRDiscount, "MKD_STRICT", INT2NUM(MKD_STRICT));
+ rb_define_const(rb_cRDiscount, "MKD_TAGTEXT", INT2NUM(MKD_TAGTEXT));
+ rb_define_const(rb_cRDiscount, "MKD_NO_EXT", INT2NUM(MKD_NO_EXT));
+ rb_define_const(rb_cRDiscount, "MKD_CDATA", INT2NUM(MKD_CDATA));
+ rb_define_const(rb_cRDiscount, "MKD_NOSUPERSCRIPT", INT2NUM(MKD_NOSUPERSCRIPT));
+ rb_define_const(rb_cRDiscount, "MKD_NORELAXED", INT2NUM(MKD_NORELAXED));
+ rb_define_const(rb_cRDiscount, "MKD_NOTABLES", INT2NUM(MKD_NOTABLES));
+ rb_define_const(rb_cRDiscount, "MKD_NOSTRIKETHROUGH", INT2NUM(MKD_NOSTRIKETHROUGH));
+ rb_define_const(rb_cRDiscount, "MKD_TOC", INT2NUM(MKD_TOC));
+ rb_define_const(rb_cRDiscount, "MKD_1_COMPAT", INT2NUM(MKD_1_COMPAT));
+ rb_define_const(rb_cRDiscount, "MKD_AUTOLINK", INT2NUM(MKD_AUTOLINK));
+ rb_define_const(rb_cRDiscount, "MKD_SAFELINK", INT2NUM(MKD_SAFELINK));
+ rb_define_const(rb_cRDiscount, "MKD_NOHEADER", INT2NUM(MKD_NOHEADER));
+ rb_define_const(rb_cRDiscount, "MKD_TABSTOP", INT2NUM(MKD_TABSTOP));
+ rb_define_const(rb_cRDiscount, "MKD_NODIVQUOTE", INT2NUM(MKD_NODIVQUOTE));
+ rb_define_const(rb_cRDiscount, "MKD_NOALPHALIST", INT2NUM(MKD_NOALPHALIST));
+ rb_define_const(rb_cRDiscount, "MKD_NODLIST", INT2NUM(MKD_NODLIST));
rb_define_method(rb_cRDiscount, "to_html", rb_rdiscount_to_html, -1);
rb_define_method(rb_cRDiscount, "toc_content", rb_rdiscount_toc_content, -1);
}
diff --git a/lib/rdiscount.rb b/lib/rdiscount.rb
index c732704..d9ac4db 100644
--- a/lib/rdiscount.rb
+++ b/lib/rdiscount.rb
@@ -29,64 +29,55 @@ class RDiscount
# Original Markdown formatted text.
attr_reader :text
- # Set true to have smarty-like quote translation performed.
- attr_accessor :smart
+ # Integer containing bit flags for the underlying Discount library.
+ attr_accessor :flags
# 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 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
-
- # 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:
+ # 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).
- # * :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.
+ # * :filter_styles - Do not output tags.
+ # * :fold_lines - RedCloth compatible line folding (not used).
+ # * :MKD_NOLINKS - Don't do link processing, block tags
+ # * :MKD_NOIMAGE - Don't do image processing, block
+ # * :MKD_NOPANTS - Don't run smartypants()
+ # * :MKD_NOHTML - Don't allow raw html through AT ALL
+ # * :MKD_STRICT - Disable SUPERSCRIPT, RELAXED_EMPHASIS
+ # * :MKD_TAGTEXT - Process text inside an html tag; no , no , no html or [] expansion
+ # * :MKD_NO_EXT - Don't allow pseudo-protocols
+ # * :MKD_CDATA - Generate code for xml ![CDATA[...]]
+ # * :MKD_NOSUPERSCRIPT - No A^B
+ # * :MKD_NORELAXED - Emphasis happens everywhere
+ # * :MKD_NOTABLES - Don't process PHP Markdown Extra tables.
+ # * :MKD_NOSTRIKETHROUGH - Forbid ~~strikethrough~~
+ # * :MKD_TOC - Do table-of-contents processing
+ # * :MKD_1_COMPAT - Compatability with MarkdownTest_1.0
+ # * :MKD_AUTOLINK - Make http://foo.com a link even without <>s
+ # * :MKD_SAFELINK - Paranoid check for link protocol
+ # * :MKD_NOHEADER - Don't process document headers
+ # * :MKD_TABSTOP - Expand tabs to 4 spaces
+ # * :MKD_NODIVQUOTE - Forbid >%class% blocks
+ # * :MKD_NOALPHALIST - Forbid alphabetic lists
+ # * :MKD_NODLIST - Forbid definition lists
#
def initialize(text, *extensions)
@text = text
- extensions.each { |e| send("#{e}=", true) }
+ @flags = 0
+ extensions.each do |ext|
+ writer = "#{ext}="
+ if respond_to? writer
+ send writer, true
+ else
+ @flags |= RDiscount.const_get(ext)
+ end
+ end
end
end
diff --git a/test/markdown_test.rb b/test/markdown_test.rb
index 4fe1e72..1a400d8 100644
--- a/test/markdown_test.rb
+++ b/test/markdown_test.rb
@@ -14,88 +14,88 @@ def test_that_extension_methods_are_present_on_markdown_class
end
def test_that_simple_one_liner_goes_to_html
- markdown = Markdown.new('Hello World.')
+ markdown = Markdown.new('Hello World.', :MKD_NOPANTS)
assert_respond_to markdown, :to_html
assert_equal "Hello World.
", markdown.to_html.strip
end
def test_that_inline_markdown_goes_to_html
- markdown = Markdown.new('_Hello World_!')
+ markdown = Markdown.new('_Hello World_!', :MKD_NOPANTS)
assert_equal "Hello World!
", markdown.to_html.strip
end
def test_that_inline_markdown_starts_and_ends_correctly
- markdown = Markdown.new('_start _ foo_bar bar_baz _ end_ *italic* **bold** _blah_')
+ markdown = Markdown.new('_start _ foo_bar bar_baz _ end_ *italic* **bold** _blah_', :MKD_NOPANTS)
assert_respond_to markdown, :to_html
assert_equal "start _ foo_bar bar_baz _ end italic bold blah
", markdown.to_html.strip
- markdown = Markdown.new("Run 'rake radiant:extensions:rbac_base:migrate'")
+ markdown = Markdown.new("Run 'rake radiant:extensions:rbac_base:migrate'", :MKD_NOPANTS)
assert_equal "Run 'rake radiant:extensions:rbac_base:migrate'
", markdown.to_html.strip
end
def test_that_filter_html_works
- markdown = Markdown.new('Through NO ', :filter_html)
+ markdown = Markdown.new('Through NO ', :MKD_NOPANTS, :MKD_NOHTML)
assert_equal "Through <em>NO</em> <script>DOUBLE NO</script>
", markdown.to_html.strip
end
def test_that_bluecloth_restrictions_are_supported
- markdown = Markdown.new('Hello World.')
- [:filter_html, :filter_styles].each do |restriction|
+ markdown = Markdown.new('Hello World.', :MKD_NOPANTS)
+ [:filter_styles].each do |restriction|
assert_respond_to markdown, restriction
assert_respond_to markdown, "#{restriction}="
end
- assert_not_equal true, markdown.filter_html
+ assert_not_equal RDiscount::MKD_NOHTML, markdown.flags & RDiscount::MKD_NOHTML
assert_not_equal true, markdown.filter_styles
- markdown = Markdown.new('Hello World.', :filter_html, :filter_styles)
- assert_equal true, markdown.filter_html
+ markdown = Markdown.new('Hello World.', :MKD_NOPANTS, :MKD_NOHTML, :filter_styles)
+ assert_equal RDiscount::MKD_NOHTML, markdown.flags & RDiscount::MKD_NOHTML
assert_equal true, markdown.filter_styles
end
def test_that_redcloth_attributes_are_supported
- markdown = Markdown.new('Hello World.')
+ markdown = Markdown.new('Hello World.', :MKD_NOPANTS)
assert_respond_to markdown, :fold_lines
assert_respond_to markdown, :fold_lines=
assert_not_equal true, markdown.fold_lines
- markdown = Markdown.new('Hello World.', :fold_lines)
+ markdown = Markdown.new('Hello World.', :MKD_NOPANTS, :fold_lines)
assert_equal true, markdown.fold_lines
end
def test_that_redcloth_to_html_with_single_arg_is_supported
- markdown = Markdown.new('Hello World.')
+ markdown = Markdown.new('Hello World.', :MKD_NOPANTS)
assert_nothing_raised(ArgumentError) { markdown.to_html(true) }
end
def test_that_smart_converts_single_quotes_in_words_that_end_in_re
- markdown = Markdown.new("They're not for sale.", :smart)
+ markdown = Markdown.new("They're not for sale.")
assert_equal "They’re not for sale.
\n", markdown.to_html
end
def test_that_smart_converts_single_quotes_in_words_that_end_in_ll
- markdown = Markdown.new("Well that'll be the day", :smart)
+ markdown = Markdown.new("Well that'll be the day")
assert_equal "Well that’ll be the day
\n", markdown.to_html
end
def test_that_urls_are_not_doubly_escaped
- markdown = Markdown.new('[Page 2](/search?query=Markdown+Test&page=2)')
+ markdown = Markdown.new('[Page 2](/search?query=Markdown+Test&page=2)', :MKD_NOPANTS)
assert_equal "Page 2
\n", markdown.to_html
end
def test_simple_inline_html
- markdown = Markdown.new("before\n\n\n foo\n
\nafter")
+ markdown = Markdown.new("before\n\n\n foo\n
\nafter", :MKD_NOPANTS)
assert_equal "before
\n\n\n foo\n
\n\n\nafter
\n",
markdown.to_html
end
def test_that_html_blocks_do_not_require_their_own_end_tag_line
- markdown = Markdown.new("Para 1\n\n\n\nPara 2 [Link](#anchor)")
+ markdown = Markdown.new("Para 1\n\n\n\nPara 2 [Link](#anchor)", :MKD_NOPANTS)
assert_equal "Para 1
\n\n\n\n\nPara 2 Link
\n",
markdown.to_html
end
def test_filter_html_doesnt_break_two_space_hard_break
- markdown = Markdown.new("Lorem, \nipsum\n", :filter_html)
+ markdown = Markdown.new("Lorem, \nipsum\n", :MKD_NOPANTS, :MKD_NOHTML)
assert_equal "Lorem,
\nipsum
\n",
markdown.to_html
end
@@ -104,7 +104,8 @@ def test_filter_html_doesnt_break_two_space_hard_break
def test_block_quotes_preceded_by_spaces
markdown = Markdown.new(
"A wise man once said:\n\n" +
- " > Isn't it wonderful just to be alive.\n"
+ " > Isn't it wonderful just to be alive.\n",
+ :MKD_NOPANTS
)
assert_equal "A wise man once said:
\n\n" +
"Isn't it wonderful just to be alive.
\n",
@@ -112,13 +113,13 @@ def test_block_quotes_preceded_by_spaces
end
def test_ul_with_zero_space_indent
- markdown = Markdown.new("- foo\n\n- bar\n\n baz\n")
+ markdown = Markdown.new("- foo\n\n- bar\n\n baz\n", :MKD_NOPANTS)
assert_equal "",
markdown.to_html.gsub("\n", "")
end
def test_ul_with_single_space_indent
- markdown = Markdown.new(" - foo\n\n - bar\n\n baz\n")
+ markdown = Markdown.new(" - foo\n\n - bar\n\n baz\n", :MKD_NOPANTS)
assert_equal "",
markdown.to_html.gsub("\n", "")
end
@@ -128,7 +129,7 @@ def test_headings_with_trailing_space
text = "The Ant-Sugar Tales \n" +
"=================== \n\n" +
"By Candice Yellowflower \n"
- markdown = Markdown.new(text)
+ markdown = Markdown.new(text, :MKD_NOPANTS)
assert_equal "The Ant-Sugar Tales
\n\nBy Candice Yellowflower
\n",
markdown.to_html
end
@@ -142,13 +143,13 @@ def test_headings_with_trailing_space
method_name = basename.gsub(/[-,()]/, '').gsub(/\s+/, '_').downcase
define_method "test_#{method_name}" do
- markdown = Markdown.new(File.read(text_file))
+ markdown = Markdown.new(File.read(text_file), :MKD_NOPANTS)
actual_html = markdown.to_html
assert_not_nil actual_html
end
define_method "test_#{method_name}_smart" do
- markdown = Markdown.new(File.read(text_file), :smart)
+ markdown = Markdown.new(File.read(text_file))
actual_html = markdown.to_html
assert_not_nil actual_html
end
diff --git a/test/rdiscount_test.rb b/test/rdiscount_test.rb
index 34c2c4e..d80c23e 100644
--- a/test/rdiscount_test.rb
+++ b/test/rdiscount_test.rb
@@ -12,47 +12,47 @@ def test_that_discount_does_not_blow_up_with_weird_formatting_case
1.
TEXT
- RDiscount.new(text).to_html
+ RDiscount.new(text, :MKD_NOPANTS).to_html
end
def test_that_smart_converts_double_quotes_to_curly_quotes
- rd = RDiscount.new(%("Quoted text"), :smart)
+ rd = RDiscount.new(%("Quoted text"))
assert_equal %(“Quoted text”
\n), rd.to_html
end
def test_that_smart_converts_double_quotes_to_curly_quotes_before_a_heading
- rd = RDiscount.new(%("Quoted text"\n\n# Heading), :smart)
+ rd = RDiscount.new(%("Quoted text"\n\n# Heading))
assert_equal %(“Quoted text”
\n\nHeading
\n), rd.to_html
end
def test_that_smart_converts_double_quotes_to_curly_quotes_after_a_heading
- rd = RDiscount.new(%(# Heading\n\n"Quoted text"), :smart)
+ rd = RDiscount.new(%(# Heading\n\n"Quoted text"))
assert_equal %(Heading
\n\n“Quoted text”
\n), rd.to_html
end
def test_that_smart_gives_ve_suffix_a_rsquo
- rd = RDiscount.new("I've been meaning to tell you ..", :smart)
+ rd = RDiscount.new("I've been meaning to tell you ..")
assert_equal "I’ve been meaning to tell you ..
\n", rd.to_html
end
def test_that_smart_gives_m_suffix_a_rsquo
- rd = RDiscount.new("I'm not kidding", :smart)
+ rd = RDiscount.new("I'm not kidding")
assert_equal "I’m not kidding
\n", rd.to_html
end
def test_that_smart_gives_d_suffix_a_rsquo
- rd = RDiscount.new("what'd you say?", :smart)
+ rd = RDiscount.new("what'd you say?")
assert_equal "what’d you say?
\n", rd.to_html
end
def test_that_generate_toc_sets_toc_ids
- rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc)
- assert rd.generate_toc
+ rd = RDiscount.new("# Level 1\n\n## Level 2", :MKD_NOPANTS, :MKD_TOC)
+ assert_equal RDiscount::MKD_TOC, rd.flags & RDiscount::MKD_TOC
assert_equal %(\nLevel 1
\n\n\nLevel 2
\n), rd.to_html
end
def test_should_get_the_generated_toc
- rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc)
+ rd = RDiscount.new("# Level 1\n\n## Level 2", :MKD_NOPANTS, :MKD_TOC)
exp = %()
assert_equal exp, rd.toc_content.strip
end
@@ -66,17 +66,17 @@ def test_should_return_string_in_same_encoding_as_input
end
def test_that_no_image_flag_works
- rd = RDiscount.new(%(
), :no_image)
+ rd = RDiscount.new(%(
), :MKD_NOPANTS, :MKD_NOIMAGE)
assert rd.to_html !~ /
links), :no_links)
+ rd = RDiscount.new(%([This link](http://example.net/) links), :MKD_NOPANTS, :MKD_NOLINKS)
assert rd.to_html !~ /foobarbaz
\n", rd.to_html
end
def test_that_autolink_flag_works
- rd = RDiscount.new("http://github.com/rtomayko/rdiscount", :autolink)
+ rd = RDiscount.new("http://github.com/rtomayko/rdiscount", :MKD_NOPANTS, :MKD_AUTOLINK)
assert_equal "http://github.com/rtomayko/rdiscount
\n", rd.to_html
end
def test_that_safelink_flag_works
- rd = RDiscount.new("[IRC](irc://chat.freenode.org/#freenode)", :safelink)
+ rd = RDiscount.new("[IRC](irc://chat.freenode.org/#freenode)", :MKD_NOPANTS, :MKD_SAFELINK)
assert_equal "[IRC](irc://chat.freenode.org/#freenode)
\n", rd.to_html
end
def test_that_no_pseudo_protocols_flag_works
- rd = RDiscount.new("[foo](id:bar)", :no_pseudo_protocols)
+ rd = RDiscount.new("[foo](id:bar)", :MKD_NOPANTS, :MKD_NO_EXT)
assert_equal "[foo](id:bar)
\n", rd.to_html
end
def test_that_tags_can_have_dashes_and_underscores
- rd = RDiscount.new("foo bar and baz")
+ rd = RDiscount.new("foo bar and baz", :MKD_NOPANTS)
assert_equal "foo bar and baz
\n", rd.to_html
end
end
From df32724534bde580743591818a82d1304d285d7e Mon Sep 17 00:00:00 2001
From: "Suraj N. Kurapati"
Date: Wed, 13 Jul 2011 10:46:28 -0700
Subject: [PATCH 3/3] add RDISCOUNT_EXTENSIONS environment variable
This is necessary to enable the MKD_NOPANTS flag in the underlying
Discount library; otherwise the Markdown test suite will fail.
---
Rakefile | 2 +-
bin/rdiscount | 14 ++++--
man/rdiscount.1 | 107 +++++++++++++++++++++++++++++++++++++++++--
man/rdiscount.1.ronn | 78 ++++++++++++++++++++++++++++++-
4 files changed, 189 insertions(+), 12 deletions(-)
diff --git a/Rakefile b/Rakefile
index c4a670a..9a30ac7 100644
--- a/Rakefile
+++ b/Rakefile
@@ -63,7 +63,7 @@ task 'test:conformance' => [:build] do |t|
test_version = ENV['MARKDOWN_TEST_VER'] || '1.0.3'
lib_dir = "#{pwd}/lib"
chdir("test/MarkdownTest_#{test_version}") do
- sh "RUBYLIB=#{lib_dir} ./MarkdownTest.pl --script='#{script}' --tidy"
+ sh "env RDISCOUNT_EXTENSIONS='MKD_NOPANTS' RUBYLIB=#{lib_dir} ./MarkdownTest.pl --script='#{script}' --tidy"
end
end
diff --git a/bin/rdiscount b/bin/rdiscount
index 3e3a638..636de30 100755
--- a/bin/rdiscount
+++ b/bin/rdiscount
@@ -1,7 +1,12 @@
#!/usr/bin/env ruby
-# Usage: rdiscount [...]
-# Convert one or more Markdown files to HTML and write to standard output. With
-# no or when is '-', read Markdown source text from standard input.
+#
+# Usage: [env RDISCOUNT_EXTENSIONS=',...'] rdiscount [...]
+#
+# Convert one or more Markdown files to HTML and write to standard output.
+# With no or when is '-', read Markdown source text from
+# standard input. Optionally, the RDISCOUNT_EXTENSIONS environment variable
+# can specify a comma-separated list of extensions to enable in RDiscount.
+#
if ARGV.include?('--help')
File.read(__FILE__).split("\n").grep(/^# /).each do |line|
puts line[2..-1]
@@ -10,4 +15,5 @@ if ARGV.include?('--help')
end
require 'rdiscount'
-STDOUT.write(RDiscount.new(ARGF.read).to_html)
+extensions = ENV['RDISCOUNT_EXTENSIONS'].to_s.split(',')
+STDOUT.write(RDiscount.new(ARGF.read, *extensions).to_html)
diff --git a/man/rdiscount.1 b/man/rdiscount.1
index 3d38ac5..eb4328c 100644
--- a/man/rdiscount.1
+++ b/man/rdiscount.1
@@ -1,22 +1,119 @@
-.\" generated with Ronn/v0.6.8
-.\" http://github.com/rtomayko/ronn/
+.\" generated with Ronn/v0.7.3
+.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
-.TH "RDISCOUNT" "1" "April 2010" "" "RUBY"
+.TH "RDISCOUNT" "1" "July 2011" "" "RUBY"
.
.SH "NAME"
\fBrdiscount\fR \- humane markup to HTML conversion tool
.
.SH "SYNOPSIS"
-\fBrdiscount\fR [\fIfile\fR\.\.\.]
+[\fBenv\fR RDISCOUNT_EXTENSIONS=\'\fIextension\fR,\.\.\.\'] \fBrdiscount\fR [\fIfile\fR\.\.\.]
.
.SH "DESCRIPTION"
The \fBrdiscount\fR utility reads one or more markdown(7)\-formatted text \fIfile\fRs and writes HTML to standard output\. With no \fIfile\fR, or when \fIfile\fR is \'\-\', \fBrdiscount\fR reads source text from standard input\.
.
+.P
+The \fBRDISCOUNT_EXTENSIONS\fR environment variable can specify a comma\-separated list of Markdown processing \fIextension\fRs to enable (see \fBEXTENSIONS\fR below)\.
+.
+.SH "EXTENSIONS"
+.
+.TP
+\fBfilter_styles\fR
+Do not output \fB