model_formatting 0.2.1.1 → 0.2.3
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/Rakefile +5 -5
- data/lib/model_formatting.rb +5 -2
- data/test/model_formatting_test.rb +6 -2
- metadata +19 -19
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake/testtask'
|
|
3
3
|
|
4
4
|
spec = Gem::Specification.new do |s|
|
5
5
|
s.name = "model_formatting"
|
6
|
-
s.version = "0.2.
|
6
|
+
s.version = "0.2.3"
|
7
7
|
s.author = "ENTP"
|
8
8
|
s.email = "company@entp.com"
|
9
9
|
s.homepage = "http://github.com/entp"
|
@@ -12,10 +12,10 @@ spec = Gem::Specification.new do |s|
|
|
12
12
|
s.files = FileList['[a-zA-Z]*', 'bin/*', 'lib/**/*', 'rails/**/*', 'test/**/*']
|
13
13
|
s.has_rdoc = false
|
14
14
|
s.extra_rdoc_files = ["README"]
|
15
|
-
s.add_dependency("rdiscount", "~>1.
|
16
|
-
s.add_dependency("actionpack", "~>2.
|
17
|
-
s.add_dependency("activerecord", "~>2.
|
18
|
-
s.add_dependency("activesupport", "~>2.
|
15
|
+
s.add_dependency("rdiscount", "~>1.5.8.1")
|
16
|
+
s.add_dependency("actionpack", "~>2.3.9")
|
17
|
+
s.add_dependency("activerecord", "~>2.3.9")
|
18
|
+
s.add_dependency("activesupport", "~>2.3.9")
|
19
19
|
s.add_dependency("tidy", "~>1.1.2")
|
20
20
|
s.add_development_dependency("jeremymcanally-context", "~>0.5.5")
|
21
21
|
s.add_development_dependency("jeremymcanally-matchy", "~>0.1.0")
|
data/lib/model_formatting.rb
CHANGED
@@ -145,7 +145,8 @@ module ModelFormatting
|
|
145
145
|
tag_names.each do |tag_name|
|
146
146
|
text.gsub!(%r{<#{tag_name}[^>]*>.*?</#{tag_name}>}m) do |match|
|
147
147
|
md5 = Digest::MD5.hexdigest(match)
|
148
|
-
extractions[md5]
|
148
|
+
extractions[md5] ||= []
|
149
|
+
extractions[md5] << match
|
149
150
|
"{mkd-extraction-#{md5}}"
|
150
151
|
end
|
151
152
|
end
|
@@ -157,7 +158,9 @@ module ModelFormatting
|
|
157
158
|
while !extractions.keys.empty?
|
158
159
|
# Insert block extractions
|
159
160
|
text.gsub!(/\{mkd-extraction-([0-9a-f]{32})\}/) do
|
160
|
-
extractions
|
161
|
+
value = extractions[$1].pop
|
162
|
+
extractions.delete($1) if extractions[$1].empty?
|
163
|
+
value
|
161
164
|
end
|
162
165
|
end
|
163
166
|
text
|
@@ -58,6 +58,10 @@ class ModelFormattingTest < Test::Unit::TestCase
|
|
58
58
|
ModelFormatting.process(:html, "Yo.\n\nhere is a | pipe\n\nfoobaz").should == %(<div><p>Yo.</p>\n\n<p>here is a | pipe</p>\n\n<p>foobaz</p></div>)
|
59
59
|
end
|
60
60
|
|
61
|
+
it "doesn't remove duplicate pre blocks" do
|
62
|
+
ModelFormatting.process(:html, "Yes! <pre>tacos</pre> are great.\n\nI love to eat <pre>tacos</pre> topped with <pre>tacos</pre>.\n\nYes.").should == %(<div><p>Yes! <pre>tacos</pre> are great.</p>\n\n<p>I love to eat <pre>tacos</pre> topped with <pre>tacos</pre>.</p>\n\n<p>Yes.</p></div>)
|
63
|
+
end
|
64
|
+
|
61
65
|
it "links and encodes urls correctly" do
|
62
66
|
ModelFormatting.process(:html, "a *b* \n[Whoo](http://entp.com?a=1&b=2)").should == %(<div><p>a <em>b</em><br/>\n<a href="http://entp.com?a=1&b=2">Whoo</a></p></div>)
|
63
67
|
end
|
@@ -67,11 +71,11 @@ class ModelFormattingTest < Test::Unit::TestCase
|
|
67
71
|
end
|
68
72
|
|
69
73
|
it "converts @@@ with params to code blocks" do
|
70
|
-
ModelFormatting.process(:html, "foo\n@@@ ninja\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n").should == %(<div><p>foo</p>\n\n<pre><code class=\"ninja\">bar</code>\n</pre>\n\n\n<pre><code>baz</code>\n</pre>\n\n\n<p>@@@ wah wah</p></div>)
|
74
|
+
ModelFormatting.process(:html, "foo\n@@@ ninja\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n").should == %(<div><p>foo<br/>\n</p>\n\n<pre><code class=\"ninja\">bar</code>\n</pre>\n\n\n<pre><code>baz</code>\n</pre>\n\n\n<p>@@@ wah wah</p></div>)
|
71
75
|
end
|
72
76
|
|
73
77
|
it "fixes irregular number of @@@'s" do
|
74
|
-
ModelFormatting.process(:html, "foo\n@@@\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n@@@").should == %(<div><p>foo</p>\n\n<pre><code>bar</code>\n</pre>\n\n\n<pre><code>baz</code>\n</pre>\n\n\n<p>@@@ wah wah</p>\n\n<pre><code></code>\n</pre></div>)
|
78
|
+
ModelFormatting.process(:html, "foo\n@@@\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n@@@").should == %(<div><p>foo<br/>\n</p>\n\n<pre><code>bar</code>\n</pre>\n\n\n<pre><code>baz</code>\n</pre>\n\n\n<p>@@@ wah wah</p>\n\n<pre><code></code>\n</pre></div>)
|
75
79
|
end
|
76
80
|
|
77
81
|
it "converts @@@ with params to code blocks with text format" do
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_formatting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 0.2.1.1
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- ENTP
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date:
|
18
|
+
date: 2011-04-14 00:00:00 -07:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
@@ -27,12 +26,13 @@ dependencies:
|
|
27
26
|
requirements:
|
28
27
|
- - ~>
|
29
28
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
29
|
+
hash: 85
|
31
30
|
segments:
|
32
31
|
- 1
|
33
|
-
- 6
|
34
32
|
- 5
|
35
|
-
|
33
|
+
- 8
|
34
|
+
- 1
|
35
|
+
version: 1.5.8.1
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id001
|
38
38
|
- !ruby/object:Gem::Dependency
|
@@ -43,12 +43,12 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
hash:
|
46
|
+
hash: 17
|
47
47
|
segments:
|
48
48
|
- 2
|
49
|
-
- 2
|
50
49
|
- 3
|
51
|
-
|
50
|
+
- 9
|
51
|
+
version: 2.3.9
|
52
52
|
type: :runtime
|
53
53
|
version_requirements: *id002
|
54
54
|
- !ruby/object:Gem::Dependency
|
@@ -59,12 +59,12 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
hash:
|
62
|
+
hash: 17
|
63
63
|
segments:
|
64
64
|
- 2
|
65
|
-
- 2
|
66
65
|
- 3
|
67
|
-
|
66
|
+
- 9
|
67
|
+
version: 2.3.9
|
68
68
|
type: :runtime
|
69
69
|
version_requirements: *id003
|
70
70
|
- !ruby/object:Gem::Dependency
|
@@ -75,12 +75,12 @@ dependencies:
|
|
75
75
|
requirements:
|
76
76
|
- - ~>
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
hash:
|
78
|
+
hash: 17
|
79
79
|
segments:
|
80
80
|
- 2
|
81
|
-
- 2
|
82
81
|
- 3
|
83
|
-
|
82
|
+
- 9
|
83
|
+
version: 2.3.9
|
84
84
|
type: :runtime
|
85
85
|
version_requirements: *id004
|
86
86
|
- !ruby/object:Gem::Dependency
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
requirements: []
|
183
183
|
|
184
184
|
rubyforge_project:
|
185
|
-
rubygems_version: 1.
|
185
|
+
rubygems_version: 1.4.1
|
186
186
|
signing_key:
|
187
187
|
specification_version: 3
|
188
188
|
summary: Automatically format model attributes using rdiscount and Tender/Lighthouse extensions.
|