bbcode-rails 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bbcode-rails.rb +9 -6
- data/lib/bbcode-rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 347807d619401620f7eb88ad15405a00867bf570
|
4
|
+
data.tar.gz: 0f167fefb0c8fc6ab4a0ab0b2c2bc440b4a17bd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3632535904a3db28cd65540545b026b0fcae76544ac6756bc8ac7362396e7e02d3d9b3746cff310cb0e103f3aaa642092cf66dcbe91d529465cbe17e3028c3ce
|
7
|
+
data.tar.gz: 198b3be08e56674d2385bbafeb84236fc479917c4ca93ae504d9535d44b18270f988ed86c62cf31f06311db0317f1747981be4a6ccb2d3b4b4ba54a5cba795bd
|
data/lib/bbcode-rails.rb
CHANGED
@@ -28,11 +28,6 @@ module BBCode
|
|
28
28
|
str.gsub!('"', '"')
|
29
29
|
str.gsub!("'", ''')
|
30
30
|
|
31
|
-
# Taken from bb-ruby, who took it from Rails Actionpack
|
32
|
-
str.gsub!(/\r\n?/, "\n") # \r\n and \r => \n
|
33
|
-
str.gsub!(/\n+/, '<br>') # 1+ newline => br
|
34
|
-
|
35
|
-
|
36
31
|
# Let's iterate over the pieces to build a tree
|
37
32
|
# It works like this:
|
38
33
|
# For each object you have two things:
|
@@ -159,7 +154,15 @@ module BBCode
|
|
159
154
|
end
|
160
155
|
end
|
161
156
|
|
162
|
-
result.map(&:to_s).join('').strip
|
157
|
+
result_str = result.map(&:to_s).join('').strip
|
158
|
+
|
159
|
+
# extracted from bb-ruby, which extracted it from Rails ActionPack
|
160
|
+
start_tag = '<p>'
|
161
|
+
result_str.gsub!(/\r\n?/, "\n") # \r\n and \r => \n
|
162
|
+
result_str.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline => paragraph
|
163
|
+
result_str.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br>') # 1 newline => br
|
164
|
+
result_str.insert 0, start_tag
|
165
|
+
result_str << '</p>'
|
163
166
|
rescue BBCode::ParseError => e
|
164
167
|
if raise_error
|
165
168
|
raise e
|
data/lib/bbcode-rails/version.rb
CHANGED