markdownizer 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/markdownizer.rb +6 -0
- data/lib/markdownizer/version.rb +1 -1
- data/spec/markdownizer_spec.rb +23 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
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
|
|
data/lib/markdownizer/version.rb
CHANGED
data/spec/markdownizer_spec.rb
CHANGED
@@ -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
|
-
|
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
|