rdiscount 1.6.3 → 1.6.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ require 'date'
1
2
  require 'rake/clean'
2
3
  require 'digest/md5'
3
4
 
@@ -152,31 +153,31 @@ if defined?(Gem)
152
153
  file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
153
154
  sh "git archive --format=tar HEAD | gzip > #{f.name}"
154
155
  end
156
+ end
155
157
 
156
- # GEMSPEC HELPERS ==========================================================
158
+ # GEMSPEC HELPERS ==========================================================
157
159
 
158
- def source_version
159
- line = File.read('lib/rdiscount.rb')[/^\s*VERSION = .*/]
160
- line.match(/.*VERSION = '(.*)'/)[1]
161
- end
160
+ def source_version
161
+ line = File.read('lib/rdiscount.rb')[/^\s*VERSION = .*/]
162
+ line.match(/.*VERSION = '(.*)'/)[1]
163
+ end
162
164
 
163
- file 'rdiscount.gemspec' => FileList['Rakefile','lib/rdiscount.rb'] do |f|
164
- # read spec file and split out manifest section
165
- spec = File.read(f.name)
166
- head, manifest, tail = spec.split(" # = MANIFEST =\n")
167
- head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
168
- head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
169
- # determine file list from git ls-files
170
- files = `git ls-files`.
171
- split("\n").
172
- sort.
173
- reject{ |file| file =~ /^\./ || file =~ /^test\/MarkdownTest/ }.
174
- map{ |file| " #{file}" }.
175
- join("\n")
176
- # piece file back together and write...
177
- manifest = " s.files = %w[\n#{files}\n ]\n"
178
- spec = [head,manifest,tail].join(" # = MANIFEST =\n")
179
- File.open(f.name, 'w') { |io| io.write(spec) }
180
- puts "updated #{f.name}"
181
- end
165
+ file 'rdiscount.gemspec' => FileList['Rakefile','lib/rdiscount.rb'] do |f|
166
+ # read spec file and split out manifest section
167
+ spec = File.read(f.name)
168
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
169
+ head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
170
+ head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
171
+ # determine file list from git ls-files
172
+ files = `git ls-files`.
173
+ split("\n").
174
+ sort.
175
+ reject{ |file| file =~ /^\./ || file =~ /^test\/MarkdownTest/ }.
176
+ map{ |file| " #{file}" }.
177
+ join("\n")
178
+ # piece file back together and write...
179
+ manifest = " s.files = %w[\n#{files}\n ]\n"
180
+ spec = [head,manifest,tail].join(" # = MANIFEST =\n")
181
+ File.open(f.name, 'w') { |io| io.write(spec) }
182
+ puts "updated #{f.name}"
182
183
  end
data/ext/rdiscount.c CHANGED
@@ -86,6 +86,35 @@ int rb_rdiscount__get_flags(VALUE ruby_obj)
86
86
  if ( rb_funcall(ruby_obj, rb_intern("generate_toc"), 0) == Qtrue)
87
87
  flags = flags | MKD_TOC;
88
88
 
89
+ /* no_image */
90
+ if ( rb_funcall(ruby_obj, rb_intern("no_image"), 0) == Qtrue)
91
+ flags = flags | MKD_NOIMAGE;
92
+
93
+ /* no_links */
94
+ if ( rb_funcall(ruby_obj, rb_intern("no_links"), 0) == Qtrue)
95
+ flags = flags | MKD_NOLINKS;
96
+
97
+ /* no_tables */
98
+ if ( rb_funcall(ruby_obj, rb_intern("no_tables"), 0) == Qtrue)
99
+ flags = flags | MKD_NOTABLES;
100
+
101
+ /* strict */
102
+ if ( rb_funcall(ruby_obj, rb_intern("strict"), 0) == Qtrue)
103
+ flags = flags | MKD_STRICT;
104
+
105
+ /* autolink */
106
+ if ( rb_funcall(ruby_obj, rb_intern("autolink"), 0) == Qtrue)
107
+ flags = flags | MKD_AUTOLINK;
108
+
109
+ /* safelink */
110
+ if ( rb_funcall(ruby_obj, rb_intern("safelink"), 0) == Qtrue)
111
+ flags = flags | MKD_SAFELINK;
112
+
113
+ /* no_pseudo_protocols */
114
+ if ( rb_funcall(ruby_obj, rb_intern("no_pseudo_protocols"), 0) == Qtrue)
115
+ flags = flags | MKD_NO_EXT;
116
+
117
+
89
118
  return flags;
90
119
  }
91
120
 
data/lib/rdiscount.rb CHANGED
@@ -24,7 +24,7 @@
24
24
  # end
25
25
  #
26
26
  class RDiscount
27
- VERSION = '1.6.3'
27
+ VERSION = '1.6.3.1'
28
28
 
29
29
  # Original Markdown formatted text.
30
30
  attr_reader :text
@@ -32,7 +32,7 @@ class RDiscount
32
32
  # Set true to have smarty-like quote translation performed.
33
33
  attr_accessor :smart
34
34
 
35
- # Do not output <style> tags included in the source text.
35
+ # Do not output <tt><style></tt> tags included in the source text.
36
36
  attr_accessor :filter_styles
37
37
 
38
38
  # Do not output any raw HTML included in the source text.
@@ -45,6 +45,27 @@ class RDiscount
45
45
  # Enable Table Of Contents generation
46
46
  attr_accessor :generate_toc
47
47
 
48
+ # Do not process <tt>![]</tt> and remove <tt><img></tt> tags from the output.
49
+ attr_accessor :no_image
50
+
51
+ # Do not process <tt>[]</tt> and remove <tt><a></tt> tags from the output.
52
+ attr_accessor :no_links
53
+
54
+ # Do not process tables
55
+ attr_accessor :no_tables
56
+
57
+ # Disable superscript and relaxed emphasis processing.
58
+ attr_accessor :strict
59
+
60
+ # Convert URL in links, even if they aren't encased in <tt><></tt>
61
+ attr_accessor :autolink
62
+
63
+ # Don't make hyperlinks from <tt>[][]</tt> links that have unknown URL types.
64
+ attr_accessor :safelink
65
+
66
+ # Do not process pseudo-protocols like <tt>[](id:name)</tt>
67
+ attr_accessor :no_pseudo_protocols
68
+
48
69
  # Create a RDiscount Markdown processor. The +text+ argument
49
70
  # should be a string containing Markdown text. Additional arguments may be
50
71
  # supplied to set various processing options:
@@ -54,14 +75,17 @@ class RDiscount
54
75
  # * <tt>:filter_html</tt> - Do not output any raw HTML tags included in
55
76
  # the source text.
56
77
  # * <tt>:fold_lines</tt> - RedCloth compatible line folding (not used).
78
+ # * <tt>:generate_toc</tt> - Enable Table Of Contents generation
79
+ # * <tt>:no_image</tt> - Do not output any <tt><img></tt> tags.
80
+ # * <tt>:no_links</tt> - Do not output any <tt><a></tt> tags.
81
+ # * <tt>:no_tables</tt> - Do not output any tables.
82
+ # * <tt>:strict</tt> - Disable superscript and relaxed emphasis processing.
83
+ # * <tt>:autolink</tt> - Greedily urlify links.
84
+ # * <tt>:safelink</tt> - Do not make links for unknown URL types.
85
+ # * <tt>:no_pseudo_protocols</tt> - Do not process pseudo-protocols.
57
86
  #
58
- # NOTE: The <tt>:filter_styles</tt> extension is not yet implemented.
59
87
  def initialize(text, *extensions)
60
88
  @text = text
61
- @smart = nil
62
- @filter_styles = nil
63
- @filter_html = nil
64
- @fold_lines = nil
65
89
  extensions.each { |e| send("#{e}=", true) }
66
90
  end
67
91
 
data/rdiscount.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rdiscount'
3
- s.version = '1.6.3'
3
+ s.version = '1.6.3.1'
4
4
  s.summary = "Fast Implementation of Gruber's Markdown in C"
5
- s.date = '2010-03-08'
5
+ s.date = '2010-04-20'
6
6
  s.email = 'r@tomayko.com'
7
7
  s.homepage = 'http://github.com/rtomayko/rdiscount'
8
8
  s.has_rdoc = true
@@ -64,4 +64,43 @@ class RDiscountTest < Test::Unit::TestCase
64
64
  assert_equal input.encoding.name, output.encoding.name
65
65
  end
66
66
  end
67
+
68
+ def test_that_no_image_flag_works
69
+ rd = RDiscount.new(%(![dust mite](http://dust.mite/image.png) <img src="image.png" />), :no_image)
70
+ assert rd.to_html !~ /<img/
71
+ end
72
+
73
+ def test_that_no_links_flag_works
74
+ rd = RDiscount.new(%([This link](http://example.net/) <a href="links.html">links</a>), :no_links)
75
+ assert rd.to_html !~ /<a /
76
+ end
77
+
78
+ def test_that_no_tables_flag_works
79
+ rd = RDiscount.new(<<EOS, :no_tables)
80
+ aaa | bbbb
81
+ -----|------
82
+ hello|sailor
83
+ EOS
84
+ assert rd.to_html !~ /<table/
85
+ end
86
+
87
+ def test_that_strict_flag_works
88
+ rd = RDiscount.new("foo_bar_baz", :strict)
89
+ assert_equal "<p>foo<em>bar</em>baz</p>\n", rd.to_html
90
+ end
91
+
92
+ def test_that_autolink_flag_works
93
+ rd = RDiscount.new("http://github.com/rtomayko/rdiscount", :autolink)
94
+ assert_equal "<p><a href=\"http://github.com/rtomayko/rdiscount\">http://github.com/rtomayko/rdiscount</a></p>\n", rd.to_html
95
+ end
96
+
97
+ def test_that_safelink_flag_works
98
+ rd = RDiscount.new("[IRC](irc://chat.freenode.org/#freenode)", :safelink)
99
+ assert_equal "<p>[IRC](irc://chat.freenode.org/#freenode)</p>\n", rd.to_html
100
+ end
101
+
102
+ def test_that_no_pseudo_protocols_flag_works
103
+ rd = RDiscount.new("[foo](id:bar)", :no_pseudo_protocols)
104
+ assert_equal "<p>[foo](id:bar)</p>\n", rd.to_html
105
+ end
67
106
  end
metadata CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 1
7
7
  - 6
8
8
  - 3
9
- version: 1.6.3
9
+ - 1
10
+ version: 1.6.3.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Ryan Tomayko
@@ -16,7 +17,7 @@ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2010-03-08 00:00:00 -08:00
20
+ date: 2010-04-20 00:00:00 -07:00
20
21
  default_executable:
21
22
  dependencies: []
22
23