model_formatting 0.2.3.19 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -7
- data/Gemfile.lock +41 -27
- data/README +1 -7
- data/Rakefile +8 -9
- data/lib/model_formatting.rb +15 -31
- data/test/formatting_test.rb +6 -13
- data/test/model_formatting_test.rb +7 -22
- metadata +51 -66
- data/lib/redcarpet_custom.rb +0 -27
data/Gemfile
CHANGED
@@ -2,15 +2,13 @@ source :gemcutter
|
|
2
2
|
source "http://gem.entp.com"
|
3
3
|
|
4
4
|
gem 'rake'
|
5
|
-
gem '
|
6
|
-
gem 'actionpack', '~>
|
7
|
-
gem 'activerecord', '~>
|
8
|
-
gem 'activesupport', '~>
|
9
|
-
gem '
|
10
|
-
gem 'tidy_ffi', '~> 0.1'
|
5
|
+
gem 'rdiscount', '~> 1.6.5'
|
6
|
+
gem 'actionpack', '~> 3.0.0'
|
7
|
+
gem 'activerecord', '~> 3.0.0'
|
8
|
+
gem 'activesupport', '~> 3.0.0'
|
9
|
+
gem 'tidy_ffi', '~> 0.1.2'
|
11
10
|
|
12
11
|
group :development, :test do
|
13
12
|
gem 'context', '0.5.5'
|
14
13
|
gem 'matchy', '~>0.4.0'
|
15
|
-
gem 'ruby-debug'
|
16
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -2,41 +2,55 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
remote: http://gem.entp.com/
|
4
4
|
specs:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
abstract (1.0.0)
|
6
|
+
actionpack (3.0.12)
|
7
|
+
activemodel (= 3.0.12)
|
8
|
+
activesupport (= 3.0.12)
|
9
|
+
builder (~> 2.1.2)
|
10
|
+
erubis (~> 2.6.6)
|
11
|
+
i18n (~> 0.5.0)
|
12
|
+
rack (~> 1.2.5)
|
13
|
+
rack-mount (~> 0.6.14)
|
14
|
+
rack-test (~> 0.5.7)
|
15
|
+
tzinfo (~> 0.3.23)
|
16
|
+
activemodel (3.0.12)
|
17
|
+
activesupport (= 3.0.12)
|
18
|
+
builder (~> 2.1.2)
|
19
|
+
i18n (~> 0.5.0)
|
20
|
+
activerecord (3.0.12)
|
21
|
+
activemodel (= 3.0.12)
|
22
|
+
activesupport (= 3.0.12)
|
23
|
+
arel (~> 2.0.10)
|
24
|
+
tzinfo (~> 0.3.23)
|
25
|
+
activesupport (3.0.12)
|
26
|
+
arel (2.0.10)
|
27
|
+
builder (2.1.2)
|
12
28
|
context (0.5.5)
|
13
|
-
|
14
|
-
|
15
|
-
|
29
|
+
erubis (2.6.6)
|
30
|
+
abstract (>= 1.0.0)
|
31
|
+
ffi (1.0.10)
|
32
|
+
i18n (0.5.0)
|
16
33
|
matchy (0.4.0)
|
17
|
-
rack (1.
|
34
|
+
rack (1.2.5)
|
35
|
+
rack-mount (0.6.14)
|
36
|
+
rack (>= 1.0.0)
|
37
|
+
rack-test (0.5.7)
|
38
|
+
rack (>= 1.0)
|
18
39
|
rake (0.9.2)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
ruby-debug-base (~> 0.10.4.0)
|
24
|
-
ruby-debug-base (0.10.4)
|
25
|
-
linecache (>= 0.3)
|
26
|
-
tidy_ffi (0.1.5)
|
27
|
-
ffi (~> 1.2.0)
|
40
|
+
rdiscount (1.6.8)
|
41
|
+
tidy_ffi (0.1.3)
|
42
|
+
ffi (>= 0.3.5)
|
43
|
+
tzinfo (0.3.32)
|
28
44
|
|
29
45
|
PLATFORMS
|
30
46
|
ruby
|
31
47
|
|
32
48
|
DEPENDENCIES
|
33
|
-
actionpack (~>
|
34
|
-
activerecord (~>
|
35
|
-
activesupport (~>
|
49
|
+
actionpack (~> 3.0.0)
|
50
|
+
activerecord (~> 3.0.0)
|
51
|
+
activesupport (~> 3.0.0)
|
36
52
|
context (= 0.5.5)
|
37
53
|
matchy (~> 0.4.0)
|
38
|
-
rack (~> 1.1.3)
|
39
54
|
rake
|
40
|
-
|
41
|
-
|
42
|
-
tidy_ffi (~> 0.1)
|
55
|
+
rdiscount (~> 1.6.5)
|
56
|
+
tidy_ffi (~> 0.1.2)
|
data/README
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
This is a plugin for Rails that performs automatic text-to-html formatting.
|
2
|
-
|
3
|
-
For rails 2.3, please use the 'rails23' branch (you can specify ~> 0.2 in your gemfile)
|
4
|
-
|
5
|
-
It uses the 'redcarpet' markdown library with a few other pre-processing steps.
|
6
|
-
Note: tests do not run on 1.9.x series due to a bug in the test frameworks we use,
|
7
|
-
but the code works fine.
|
1
|
+
This is a plugin for Rails 2.2.x that performs automatic text-to-html formatting.
|
8
2
|
|
9
3
|
It is extracted from and used by [Tender](http://tenderapp.com/) and [Lighthouse](http://lighthouseapp.com/).
|
data/Rakefile
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
require '
|
1
|
+
require 'rake/gempackagetask'
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
4
|
spec = Gem::Specification.new do |s|
|
5
5
|
s.name = "model_formatting"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.3.2"
|
7
7
|
s.author = "ENTP"
|
8
8
|
s.email = "company@entp.com"
|
9
9
|
s.homepage = "http://github.com/entp"
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
|
-
s.summary = "Automatically format model attributes using
|
11
|
+
s.summary = "Automatically format model attributes using rdiscount and Tender/Lighthouse extensions."
|
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("
|
16
|
-
s.add_dependency("
|
17
|
-
s.add_dependency("
|
18
|
-
s.add_dependency("
|
19
|
-
s.add_dependency("activesupport", "~>2.3.15")
|
15
|
+
s.add_dependency("rdiscount", "~>1.6.5")
|
16
|
+
s.add_dependency("actionpack", "~>3.0.0")
|
17
|
+
s.add_dependency("activerecord", "~>3.0.0")
|
18
|
+
s.add_dependency("activesupport", "~>3.0.0")
|
20
19
|
s.add_dependency("tidy_ffi", "~>0.1.2")
|
21
20
|
s.add_development_dependency("jeremymcanally-context", "~>0.5.5")
|
22
21
|
s.add_development_dependency("jeremymcanally-matchy", "~>0.1.0")
|
@@ -24,7 +23,7 @@ end
|
|
24
23
|
|
25
24
|
|
26
25
|
desc 'Build the gem.'
|
27
|
-
|
26
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
28
27
|
pkg.gem_spec = spec
|
29
28
|
end
|
30
29
|
|
data/lib/model_formatting.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'cgi'
|
2
2
|
require 'active_support' # NilClass#blank?
|
3
|
-
require 'redcarpet_custom'
|
4
3
|
module ModelFormatting
|
5
4
|
class Part < Array
|
6
5
|
attr_reader :format
|
@@ -89,16 +88,16 @@ module ModelFormatting
|
|
89
88
|
end
|
90
89
|
end
|
91
90
|
if format == :html
|
92
|
-
string = process_tidy(string)
|
93
91
|
if options[:white_list]
|
94
92
|
string = options[:white_list].sanitize(string)
|
95
93
|
end
|
94
|
+
string = process_tidy(string)
|
96
95
|
end
|
97
96
|
string.strip!
|
98
97
|
format == :html ? "<div>#{string}</div>" : string
|
99
98
|
end
|
100
99
|
|
101
|
-
CODEBLOCK_RE =
|
100
|
+
CODEBLOCK_RE = /^@@@( ([a-z]+)\s*)?$/
|
102
101
|
|
103
102
|
# Parse a string into a given array of [CodeBlcok, FormattedBlock, CodeBlock, FormattedBlock]
|
104
103
|
#
|
@@ -123,7 +122,7 @@ module ModelFormatting
|
|
123
122
|
current_part = nil
|
124
123
|
else
|
125
124
|
if current_part then parts << current_part end
|
126
|
-
current_part = CodePart.new(format, $
|
125
|
+
current_part = CodePart.new(format, $2)
|
127
126
|
end
|
128
127
|
in_code_block = !in_code_block
|
129
128
|
else
|
@@ -179,27 +178,20 @@ module ModelFormatting
|
|
179
178
|
|
180
179
|
def self.gfm(text)
|
181
180
|
extract_tag(text, :pre) do |txt|
|
182
|
-
#
|
183
|
-
|
184
|
-
|
185
|
-
text.gsub!(/^[\w\<][^\n]*\n+/) do |x|
|
186
|
-
x =~ /\n{2}/ ? x : (x.strip!; x << " \n")
|
181
|
+
# prevent foo_bar_baz from ending up with an italic word in the middle
|
182
|
+
text.gsub!(/(^(?! {4}|\t)\w+_\w+_\w[\w_]*)/) do |x|
|
183
|
+
x.gsub('_', '\_') if x.split('').sort.to_s[0..1] == '__'
|
187
184
|
end
|
188
185
|
end
|
189
186
|
end
|
190
187
|
|
191
188
|
begin
|
192
|
-
require '
|
189
|
+
require 'rdiscount'
|
193
190
|
def self.process_markdown(text)
|
194
|
-
|
195
|
-
:no_intra_emphasis => true,
|
196
|
-
:tables => true,
|
197
|
-
:fenced_code_blocks => true,
|
198
|
-
:space_after_headers => true
|
199
|
-
).render(text)
|
191
|
+
RDiscount.new(text).to_html
|
200
192
|
end
|
201
193
|
rescue LoadError
|
202
|
-
puts "No
|
194
|
+
puts "No RDiscount gem found. `gem install rdiscount`."
|
203
195
|
def self.process_markdown(text)
|
204
196
|
text
|
205
197
|
end
|
@@ -208,20 +200,12 @@ module ModelFormatting
|
|
208
200
|
begin
|
209
201
|
require 'tidy_ffi'
|
210
202
|
def self.process_tidy(text)
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
tidy.clean.strip
|
218
|
-
rescue ArgumentError => e
|
219
|
-
if e.to_s == "string contains null byte"
|
220
|
-
text
|
221
|
-
else
|
222
|
-
raise e
|
223
|
-
end
|
224
|
-
end
|
203
|
+
tidy = TidyFFI::Tidy.new(text)
|
204
|
+
tidy.options.input_encoding = 'utf8'
|
205
|
+
tidy.options.show_body_only = true
|
206
|
+
tidy.options.new_inline_tags = "video"
|
207
|
+
tidy.options.force_output = true
|
208
|
+
tidy.clean.strip
|
225
209
|
end
|
226
210
|
rescue LoadError
|
227
211
|
puts "No TidyFFI gem found. `gem install tidy_ffi`."
|
data/test/formatting_test.rb
CHANGED
@@ -24,7 +24,7 @@ module ModelFormatting
|
|
24
24
|
formats :body
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
describe "Simple with formatting" do
|
28
28
|
it "has attribute from #formats arguments" do
|
29
29
|
Simple.model_formatting_attributes[:body].should == "formatted_body"
|
30
30
|
end
|
@@ -60,13 +60,6 @@ module ModelFormatting
|
|
60
60
|
record.save
|
61
61
|
record.formatted_body.should ==%(<div><p>Encöded ɐ \\Upload \\upload</p></div>)
|
62
62
|
end
|
63
|
-
|
64
|
-
it "formats incorrect html" do
|
65
|
-
record = Simple.new
|
66
|
-
record.body = "<a href=http://google.com>google</a>"
|
67
|
-
record.save
|
68
|
-
record.formatted_body.should ==%(<div><p><a href="http://google.com">google</a></p></div>)
|
69
|
-
end
|
70
63
|
end
|
71
64
|
|
72
65
|
class BaseWithAfter < Base
|
@@ -75,7 +68,7 @@ module ModelFormatting
|
|
75
68
|
end
|
76
69
|
end
|
77
70
|
|
78
|
-
|
71
|
+
describe "base with after callback" do
|
79
72
|
it "does not leave mkd-extraction artifacts" do
|
80
73
|
record = BaseWithAfter.new
|
81
74
|
record.body = File.read(File.dirname(__FILE__) + '/fixtures/mkd-extraction.txt')
|
@@ -101,7 +94,7 @@ module ModelFormatting
|
|
101
94
|
end
|
102
95
|
end
|
103
96
|
|
104
|
-
|
97
|
+
describe "Post with formatting" do
|
105
98
|
it "has attribute from #formats arguments" do
|
106
99
|
Post.model_formatting_attributes[:body].should == "formatted_body"
|
107
100
|
end
|
@@ -122,7 +115,7 @@ module ModelFormatting
|
|
122
115
|
Post.before_save.should == :format_content_with_model_formatting
|
123
116
|
end
|
124
117
|
|
125
|
-
|
118
|
+
describe "being saved" do
|
126
119
|
before do
|
127
120
|
@record = Post.new
|
128
121
|
@record.body = 'booya'
|
@@ -159,7 +152,7 @@ module ModelFormatting
|
|
159
152
|
end
|
160
153
|
end
|
161
154
|
|
162
|
-
|
155
|
+
describe "ChildPost with formatting" do
|
163
156
|
it "has attribute from #formats arguments" do
|
164
157
|
ChildPost.model_formatting_attributes[:body].should == "formatted_body"
|
165
158
|
end
|
@@ -176,7 +169,7 @@ module ModelFormatting
|
|
176
169
|
ChildPost.before_save.should == :format_content_with_model_formatting
|
177
170
|
end
|
178
171
|
|
179
|
-
|
172
|
+
describe "being saved" do
|
180
173
|
before do
|
181
174
|
@record = ChildPost.new
|
182
175
|
@record.body = 'booya'
|
@@ -7,11 +7,6 @@ class ModelFormattingTest < Test::Unit::TestCase
|
|
7
7
|
parts.first.class.should == ModelFormatting::FormattedPart
|
8
8
|
parts.first.should == 'foo'
|
9
9
|
end
|
10
|
-
|
11
|
-
it "generates TOC titles" do
|
12
|
-
ModelFormatting.process(:html, "# title one\n\n# title two\n\n## title one").should == \
|
13
|
-
"<div><h1 id=\"title-one\"><a name=\"title-one\" class=\"anchor\" href=\n\"#title-one\" id=\"title-one\"></a>title one</h1>\n<h1 id=\"title-two\"><a name=\"title-two\" class=\"anchor\" href=\n\"#title-two\" id=\"title-two\"></a>title two</h1>\n<h2 id=\"title-one_1\"><a name=\"title-one_1\" class=\"anchor\" href=\n\"#title-one_1\" id=\"title-one_1\"></a>title one</h2></div>"
|
14
|
-
end
|
15
10
|
|
16
11
|
it "parses empty code block into array of single CodeBlock" do
|
17
12
|
parts = ModelFormatting.parse_text_parts(nil, nil, "@@@ foo\n@@@")
|
@@ -76,11 +71,11 @@ class ModelFormattingTest < Test::Unit::TestCase
|
|
76
71
|
end
|
77
72
|
|
78
73
|
it "converts @@@ with params to code blocks" do
|
79
|
-
ModelFormatting.process(:html, "foo\n@@@ ninja\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n").should == "<div><p>foo
|
74
|
+
ModelFormatting.process(:html, "foo\n@@@ ninja\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n").should == "<div><p>foo</p>\n<pre>\n<code class=\"ninja\">bar</code>\n</pre>\n<pre>\n<code>baz</code>\n</pre>\n<p>@@@ wah wah</p></div>"
|
80
75
|
end
|
81
76
|
|
82
77
|
it "fixes irregular number of @@@'s" do
|
83
|
-
ModelFormatting.process(:html, "foo\n@@@\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n@@@").should == "<div><p>foo
|
78
|
+
ModelFormatting.process(:html, "foo\n@@@\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n@@@").should == "<div><p>foo</p>\n<pre>\n<code>bar</code>\n</pre>\n<pre>\n<code>baz</code>\n</pre>\n<p>@@@ wah wah</p>\n<pre>\n\n</pre></div>"
|
84
79
|
end
|
85
80
|
|
86
81
|
it "converts @@@ with params to code blocks with text format" do
|
@@ -93,11 +88,10 @@ class ModelFormattingTest < Test::Unit::TestCase
|
|
93
88
|
|
94
89
|
it "treats linebreaks correctly" do
|
95
90
|
ModelFormatting.process(:html, "Line breaks should not be treated as\nnew paragraphs. They are not paragraphs.\n\nHowever, when a line is skipped, that is a paragraph.\nGMail, and basically every comment or submission form on the \nweb work this way.").should == \
|
96
|
-
"<div><p>Line breaks should not be treated as
|
97
|
-
|
91
|
+
"<div><p>Line breaks should not be treated as new paragraphs. They are\nnot paragraphs.</p>\n<p>However, when a line is skipped, that is a paragraph. GMail, and\nbasically every comment or submission form on the web work this\nway.</p></div>"
|
98
92
|
end
|
99
93
|
|
100
|
-
|
94
|
+
describe "GFM" do
|
101
95
|
it "does not touch single underscores inside words" do
|
102
96
|
assert_equal "foo_bar", ModelFormatting.gfm("foo_bar")
|
103
97
|
end
|
@@ -110,19 +104,10 @@ class ModelFormattingTest < Test::Unit::TestCase
|
|
110
104
|
assert_equal "<pre>\nfoo_bar_baz\n</pre>", ModelFormatting.gfm("<pre>\nfoo_bar_baz\n</pre>")
|
111
105
|
end
|
112
106
|
|
113
|
-
it "
|
114
|
-
assert_equal "
|
115
|
-
end
|
116
|
-
|
117
|
-
it "turns newlines into br tags in simple cases" do
|
118
|
-
assert_equal "foo \nbar", ModelFormatting.gfm("foo\nbar")
|
107
|
+
it "escapes two or more underscores inside words" do
|
108
|
+
assert_equal "foo\\_bar\\_baz", ModelFormatting.gfm("foo_bar_baz")
|
119
109
|
end
|
120
|
-
|
121
|
-
it "converts newlines in all groups" do
|
122
|
-
assert_equal "apple \npear \norange \nbanana\n\nruby \npython \nerlang \njavascript",
|
123
|
-
ModelFormatting.gfm("apple\npear\norange\nbanana\n\nruby\npython\nerlang\njavascript")
|
124
|
-
end
|
125
|
-
|
110
|
+
|
126
111
|
it "does not not convert newlines in lists" do
|
127
112
|
assert_equal "# foo\n# bar", ModelFormatting.gfm("# foo\n# bar")
|
128
113
|
assert_equal "* foo\n* bar", ModelFormatting.gfm("* foo\n* bar")
|
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 2
|
9
8
|
- 3
|
10
|
-
-
|
11
|
-
version: 0.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- ENTP
|
@@ -16,89 +15,77 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date:
|
18
|
+
date: 2012-03-21 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
22
|
+
name: rdiscount
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
25
|
none: false
|
24
26
|
requirements:
|
25
27
|
- - ~>
|
26
28
|
- !ruby/object:Gem::Version
|
27
|
-
hash:
|
29
|
+
hash: 5
|
28
30
|
segments:
|
29
31
|
- 1
|
30
|
-
-
|
31
|
-
-
|
32
|
-
version: 1.
|
32
|
+
- 6
|
33
|
+
- 5
|
34
|
+
version: 1.6.5
|
33
35
|
type: :runtime
|
34
|
-
|
35
|
-
prerelease: false
|
36
|
-
name: rack
|
36
|
+
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
hash: 7
|
44
|
-
segments:
|
45
|
-
- 2
|
46
|
-
- 2
|
47
|
-
version: "2.2"
|
48
|
-
type: :runtime
|
49
|
-
requirement: *id002
|
38
|
+
name: actionpack
|
50
39
|
prerelease: false
|
51
|
-
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
54
41
|
none: false
|
55
42
|
requirements:
|
56
43
|
- - ~>
|
57
44
|
- !ruby/object:Gem::Version
|
58
|
-
hash:
|
45
|
+
hash: 7
|
59
46
|
segments:
|
60
|
-
- 2
|
61
47
|
- 3
|
62
|
-
-
|
63
|
-
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
version: 3.0.0
|
64
51
|
type: :runtime
|
65
|
-
|
66
|
-
prerelease: false
|
67
|
-
name: actionpack
|
52
|
+
version_requirements: *id002
|
68
53
|
- !ruby/object:Gem::Dependency
|
69
|
-
|
54
|
+
name: activerecord
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
70
57
|
none: false
|
71
58
|
requirements:
|
72
59
|
- - ~>
|
73
60
|
- !ruby/object:Gem::Version
|
74
|
-
hash:
|
61
|
+
hash: 7
|
75
62
|
segments:
|
76
|
-
- 2
|
77
63
|
- 3
|
78
|
-
-
|
79
|
-
|
64
|
+
- 0
|
65
|
+
- 0
|
66
|
+
version: 3.0.0
|
80
67
|
type: :runtime
|
81
|
-
|
82
|
-
prerelease: false
|
83
|
-
name: activerecord
|
68
|
+
version_requirements: *id003
|
84
69
|
- !ruby/object:Gem::Dependency
|
85
|
-
|
70
|
+
name: activesupport
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
86
73
|
none: false
|
87
74
|
requirements:
|
88
75
|
- - ~>
|
89
76
|
- !ruby/object:Gem::Version
|
90
|
-
hash:
|
77
|
+
hash: 7
|
91
78
|
segments:
|
92
|
-
- 2
|
93
79
|
- 3
|
94
|
-
-
|
95
|
-
|
80
|
+
- 0
|
81
|
+
- 0
|
82
|
+
version: 3.0.0
|
96
83
|
type: :runtime
|
97
|
-
|
98
|
-
prerelease: false
|
99
|
-
name: activesupport
|
84
|
+
version_requirements: *id004
|
100
85
|
- !ruby/object:Gem::Dependency
|
101
|
-
|
86
|
+
name: tidy_ffi
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
102
89
|
none: false
|
103
90
|
requirements:
|
104
91
|
- - ~>
|
@@ -110,11 +97,11 @@ dependencies:
|
|
110
97
|
- 2
|
111
98
|
version: 0.1.2
|
112
99
|
type: :runtime
|
113
|
-
|
114
|
-
prerelease: false
|
115
|
-
name: tidy_ffi
|
100
|
+
version_requirements: *id005
|
116
101
|
- !ruby/object:Gem::Dependency
|
117
|
-
|
102
|
+
name: jeremymcanally-context
|
103
|
+
prerelease: false
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
118
105
|
none: false
|
119
106
|
requirements:
|
120
107
|
- - ~>
|
@@ -126,11 +113,11 @@ dependencies:
|
|
126
113
|
- 5
|
127
114
|
version: 0.5.5
|
128
115
|
type: :development
|
129
|
-
|
130
|
-
prerelease: false
|
131
|
-
name: jeremymcanally-context
|
116
|
+
version_requirements: *id006
|
132
117
|
- !ruby/object:Gem::Dependency
|
133
|
-
|
118
|
+
name: jeremymcanally-matchy
|
119
|
+
prerelease: false
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
134
121
|
none: false
|
135
122
|
requirements:
|
136
123
|
- - ~>
|
@@ -142,9 +129,7 @@ dependencies:
|
|
142
129
|
- 0
|
143
130
|
version: 0.1.0
|
144
131
|
type: :development
|
145
|
-
|
146
|
-
prerelease: false
|
147
|
-
name: jeremymcanally-matchy
|
132
|
+
version_requirements: *id007
|
148
133
|
description:
|
149
134
|
email: company@entp.com
|
150
135
|
executables: []
|
@@ -163,12 +148,12 @@ files:
|
|
163
148
|
- lib/model_formatting/init.rb
|
164
149
|
- lib/model_formatting/instance_methods.rb
|
165
150
|
- lib/model_formatting.rb
|
166
|
-
- lib/redcarpet_custom.rb
|
167
151
|
- rails/init.rb
|
168
152
|
- test/fixtures/mkd-extraction.txt
|
169
153
|
- test/formatting_test.rb
|
170
154
|
- test/model_formatting_test.rb
|
171
155
|
- test/test_helper.rb
|
156
|
+
has_rdoc: true
|
172
157
|
homepage: http://github.com/entp
|
173
158
|
licenses: []
|
174
159
|
|
@@ -198,9 +183,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
183
|
requirements: []
|
199
184
|
|
200
185
|
rubyforge_project:
|
201
|
-
rubygems_version: 1.
|
186
|
+
rubygems_version: 1.6.2
|
202
187
|
signing_key:
|
203
188
|
specification_version: 3
|
204
|
-
summary: Automatically format model attributes using
|
189
|
+
summary: Automatically format model attributes using rdiscount and Tender/Lighthouse extensions.
|
205
190
|
test_files: []
|
206
191
|
|
data/lib/redcarpet_custom.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'redcarpet'
|
2
|
-
module Redcarpet::Render
|
3
|
-
class Custom < HTML
|
4
|
-
# include Redcarpet::Render::HTML
|
5
|
-
def header(title, level)
|
6
|
-
@headers ||= []
|
7
|
-
# you can use this permalink style: 1-foo-bar with the level in it
|
8
|
-
# permalink = "#{level}-#{title.gsub(/\W+/, "-")}"
|
9
|
-
|
10
|
-
# .. or just use title. you might like a better regex here, too
|
11
|
-
permalink = title.gsub(/\W+/, "-").downcase
|
12
|
-
|
13
|
-
# for extra credit: implement this as its own method
|
14
|
-
if @headers.include?(permalink)
|
15
|
-
permalink += "_1"
|
16
|
-
# my brain hurts
|
17
|
-
loop do
|
18
|
-
break if !@headers.include?(permalink)
|
19
|
-
# generate titles like foo-bar_1, foo-bar_2
|
20
|
-
permalink.gsub!(/\_(\d+)$/, "_#{$1.to_i + 1}")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
@headers << permalink
|
24
|
-
%(\n<h#{level} id=\"#{permalink}\"><a name="#{permalink}" class="anchor" href="##{permalink}"></a>#{title}</h#{level}>\n)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|