markdownizer 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdownizer (0.3.1)
4
+ markdownizer (0.3.2)
5
5
  activerecord (>= 3.0.3)
6
6
  coderay
7
7
  rdiscount
@@ -9,17 +9,17 @@ PATH
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
- activemodel (3.0.3)
13
- activesupport (= 3.0.3)
12
+ activemodel (3.0.4)
13
+ activesupport (= 3.0.4)
14
14
  builder (~> 2.1.2)
15
15
  i18n (~> 0.4)
16
- activerecord (3.0.3)
17
- activemodel (= 3.0.3)
18
- activesupport (= 3.0.3)
16
+ activerecord (3.0.4)
17
+ activemodel (= 3.0.4)
18
+ activesupport (= 3.0.4)
19
19
  arel (~> 2.0.2)
20
20
  tzinfo (~> 0.3.23)
21
- activesupport (3.0.3)
22
- arel (2.0.7)
21
+ activesupport (3.0.4)
22
+ arel (2.0.8)
23
23
  builder (2.1.2)
24
24
  coderay (0.9.7)
25
25
  diff-lcs (1.1.2)
@@ -31,14 +31,14 @@ GEM
31
31
  rocco (0.5)
32
32
  mustache
33
33
  rdiscount
34
- rspec (2.4.0)
35
- rspec-core (~> 2.4.0)
36
- rspec-expectations (~> 2.4.0)
37
- rspec-mocks (~> 2.4.0)
38
- rspec-core (2.4.0)
39
- rspec-expectations (2.4.0)
34
+ rspec (2.5.0)
35
+ rspec-core (~> 2.5.0)
36
+ rspec-expectations (~> 2.5.0)
37
+ rspec-mocks (~> 2.5.0)
38
+ rspec-core (2.5.1)
39
+ rspec-expectations (2.5.0)
40
40
  diff-lcs (~> 1.1.2)
41
- rspec-mocks (2.4.0)
41
+ rspec-mocks (2.5.0)
42
42
  tzinfo (0.3.24)
43
43
 
44
44
  PLATFORMS
@@ -52,4 +52,4 @@ DEPENDENCIES
52
52
  pygments
53
53
  rdiscount
54
54
  rocco
55
- rspec (~> 2.4.0)
55
+ rspec (~> 2.5.0)
data/lib/markdownizer.rb CHANGED
@@ -86,8 +86,8 @@ module Markdownizer
86
86
  # To parse the markdown in a coherent hierarchical context, you must provide it
87
87
  # with the current hierarchical level of the text to be parsed.
88
88
  def markdown(text, hierarchy = 0)
89
- text.gsub! %r[(#+)([\w\s]+)] do
90
- ('#' * hierarchy) << $1 << $2
89
+ text.gsub! %r[^(\s*)(#+)([\w\s]+)$] do
90
+ $1 << ('#' * hierarchy) << $2 << $3
91
91
  end
92
92
  RDiscount.new(text).to_html
93
93
  end
@@ -132,7 +132,7 @@ module Markdownizer
132
132
 
133
133
  def extract_caption_from(code, options)
134
134
  caption = nil
135
- code.gsub!(%r[\{% caption '([\w\s]+)' %\}]) do
135
+ code.gsub!(%r[\{% caption '([^']+)' %\}]) do
136
136
  options.merge!({:caption => $1.strip}) if $1
137
137
  caption = $1.strip
138
138
  ''
@@ -1,3 +1,3 @@
1
1
  module Markdownizer
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
data/markdownizer.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency 'rocco'
22
22
  s.add_development_dependency 'git'
23
23
  s.add_development_dependency 'pygments'
24
- s.add_development_dependency 'rspec', '~> 2.4.0'
24
+ s.add_development_dependency 'rspec', '~> 2.5.0'
25
25
 
26
26
  s.files = `git ls-files`.split("\n")
27
27
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -20,7 +20,7 @@ describe Markdownizer do
20
20
  ##This is an H2
21
21
  ###This is an H3
22
22
  """
23
- result = double :result, to_html: true
23
+ result = double :result, :to_html => true
24
24
  RDiscount.should_receive(:new).with do |t|
25
25
  t.should =~ /###This is an H1/
26
26
  t.should =~ /####This is an H2/
@@ -28,6 +28,26 @@ describe Markdownizer do
28
28
  end.and_return result
29
29
  subject.markdown(my_text, 2)
30
30
  end
31
+ it 'still does not convert anything that is not a header' do
32
+ my_text = """
33
+ #This is an H1
34
+ I am talking about my #method
35
+ {% code ruby %}
36
+ \\#My comment
37
+ {% endcode %}
38
+ ###This is an H3
39
+ """
40
+ result = double :result, :to_html => true
41
+ RDiscount.should_receive(:new).with do |t|
42
+ t.should =~ /###This is an H1/
43
+ t.should =~ /#method/
44
+ t.should_not =~ /###method/
45
+ t.should =~ /#My comment/
46
+ t.should_not =~ /###My comment/
47
+ t.should =~ /#####This is an H3/
48
+ end.and_return result
49
+ subject.markdown(my_text, 2)
50
+ end
31
51
  end
32
52
  end
33
53
  describe ".coderay(text)" do
@@ -52,6 +72,18 @@ describe Markdownizer do
52
72
  end
53
73
  {% endcode %}
54
74
 
75
+ """
76
+ }
77
+ let(:text_with_weird_caption) { """
78
+ #My markdown text
79
+
80
+ {% code ruby %}
81
+ {% caption 'This will become an h5, with some/strange.characters\yo' %}
82
+ def function(*args)
83
+ puts 'result'
84
+ end
85
+ {% endcode %}
86
+
55
87
  """
56
88
  }
57
89
  let(:text_with_array_highlights) { """
@@ -93,6 +125,9 @@ describe Markdownizer do
93
125
  it 'accepts a caption option inside the code' do
94
126
  subject.coderay(text_with_caption).should match('<h5>This will become an h5</h5>')
95
127
  end
128
+ it 'accepts a caption with weird chars inside the code' do
129
+ subject.coderay(text_with_weird_caption).should match('<h5>This will become an h5, with some/strange.characters\yo</h5>')
130
+ end
96
131
  it 'passes the caption to the div' do
97
132
  parsed = double :parsed
98
133
  CodeRay.should_receive(:scan).and_return parsed
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 2
9
- version: 0.3.2
8
+ - 3
9
+ version: 0.3.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Josep M. Bach
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-02-07 00:00:00 +01:00
19
+ date: 2011-02-15 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -109,9 +109,9 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  segments:
111
111
  - 2
112
- - 4
112
+ - 5
113
113
  - 0
114
- version: 2.4.0
114
+ version: 2.5.0
115
115
  type: :development
116
116
  version_requirements: *id007
117
117
  description: Render any text as markdown, with code highlighting and all!