markdownizer 0.3.3 → 0.3.4

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.2)
4
+ markdownizer (0.3.3)
5
5
  activerecord (>= 3.0.3)
6
6
  coderay
7
7
  rdiscount
data/lib/markdownizer.rb CHANGED
@@ -89,6 +89,7 @@ module Markdownizer
89
89
  text.gsub! %r[^(\s*)(#+)([\w\s]+)$] do
90
90
  $1 << ('#' * hierarchy) << $2 << $3
91
91
  end
92
+ text.gsub!('\#','#')
92
93
  RDiscount.new(text).to_html
93
94
  end
94
95
 
@@ -116,6 +117,11 @@ module Markdownizer
116
117
 
117
118
  code, language = $2.strip, $1.strip
118
119
 
120
+ # Mark comments to avoid conflicts with Header parsing
121
+ code.gsub!(/(#+)/) do
122
+ '\\' + $1
123
+ end
124
+
119
125
  code, options, caption = extract_caption_from(code, options)
120
126
  code, options = extract_highlights_from(code, options)
121
127
 
@@ -1,3 +1,3 @@
1
1
  module Markdownizer
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -110,8 +110,21 @@ describe Markdownizer do
110
110
 
111
111
  """
112
112
  }
113
+ let(:text_with_comments) { """
114
+ #My markdown text
113
115
 
114
- it 'calls CodeRay to parse the code inside {% highlight ruby %} blocks' do
116
+ {% code ruby %}
117
+ #My comment
118
+ # My other comment
119
+ def function(*args)
120
+ puts 'result'
121
+ end
122
+ {% endcode %}
123
+
124
+ """
125
+ }
126
+
127
+ it 'calls CodeRay to parse the code inside {% code ruby %} blocks' do
115
128
  scanned_code, html_code = double(:scanned_code), double(:html_code)
116
129
 
117
130
  CodeRay.should_receive(:scan).with("""def function(*args)
@@ -128,6 +141,15 @@ describe Markdownizer do
128
141
  it 'accepts a caption with weird chars inside the code' do
129
142
  subject.coderay(text_with_weird_caption).should match('<h5>This will become an h5, with some/strange.characters\yo</h5>')
130
143
  end
144
+ it 'marks ruby comments to avoid conflicts with Markdown headers' do
145
+ code = ''
146
+ code.stub(:div).and_return ''
147
+ CodeRay.should_receive(:scan).with do |string|
148
+ string.should match(/\\#My comment/)
149
+ string.should match(/\\# My other comment/)
150
+ end.and_return code
151
+ subject.coderay(text_with_comments)
152
+ end
131
153
  it 'passes the caption to the div' do
132
154
  parsed = double :parsed
133
155
  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
- - 3
9
- version: 0.3.3
8
+ - 4
9
+ version: 0.3.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Josep M. Bach