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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e92689b8f46d26711cfcab4041edd5b64f02a21a
4
- data.tar.gz: 3c7892df9c5f386f3fe64130670e2bf0c226f7b8
3
+ metadata.gz: 347807d619401620f7eb88ad15405a00867bf570
4
+ data.tar.gz: 0f167fefb0c8fc6ab4a0ab0b2c2bc440b4a17bd0
5
5
  SHA512:
6
- metadata.gz: 20ec7751adda1c00022ad58f9e5f789d93490348d1d6376afb6b4e87e8ddac7a520071994bf431e152767c294c7a1ad3f2a615f0813459a5e9d467d097624ecd
7
- data.tar.gz: b1d80c0d6396fc43af8a0ea401d6eb7a50e6b01aa4a0e527407469d9bc7cab32dd9d1d5a30f50511526bef732bdeb3483af206f3105042cb428cd36b88122387
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
@@ -1,3 +1,3 @@
1
1
  module BBCode
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbcode-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcel Müller