pettanr_simple_format 0.0.11 → 0.0.12
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.
@@ -1,18 +1,4 @@
|
|
1
1
|
module PettanrSimpleFormat
|
2
2
|
class Renderer
|
3
|
-
def self.render content
|
4
|
-
self.simple_format(content)
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.simple_format text
|
8
|
-
text = Sanitize.clean(text.to_s, Sanitize::Config::RESTRICTED)
|
9
|
-
start_tag = '<p>'
|
10
|
-
text.gsub!(/\r\n?/, "\n")
|
11
|
-
text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph
|
12
|
-
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
|
13
|
-
text.insert 0, start_tag
|
14
|
-
text.concat("</p>")
|
15
|
-
text
|
16
|
-
end
|
17
3
|
end
|
18
4
|
end
|
@@ -1,4 +1,20 @@
|
|
1
1
|
require "pettanr_simple_format/engine"
|
2
2
|
|
3
3
|
module PettanrSimpleFormat
|
4
|
+
module Renderer
|
5
|
+
def render
|
6
|
+
self.render_simple_format(self.content)
|
7
|
+
end
|
8
|
+
|
9
|
+
def render_simple_format text
|
10
|
+
text = Sanitize.clean(text.to_s, Sanitize::Config::RESTRICTED)
|
11
|
+
start_tag = '<p>'
|
12
|
+
text.gsub!(/\r\n?/, "\n")
|
13
|
+
text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph
|
14
|
+
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
|
15
|
+
text.insert 0, start_tag
|
16
|
+
text.concat("</p>")
|
17
|
+
text
|
18
|
+
end
|
19
|
+
end
|
4
20
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pettanr_simple_format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqlite3
|