tdiary-style-gfm 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eee77f409b9a7a5110c11973981037a999e5a713
4
+ data.tar.gz: 7e1f43152704f7205942ce9b2f4b2e4d1b66d3d8
5
+ SHA512:
6
+ metadata.gz: d1be4d76d86e342fce61f5a465994c989e4b7df75a1a0d9904ff4a33a0d57ee347e6b95377c7dbf1349116fa80bf4ac3a07613aa8365b975242db598ad50f2ad
7
+ data.tar.gz: 2ab79befd95a142441982d50ffbf7a38a0aaaa81a1d151a3510c85dac060ecfe59cec1d4084ab29701b7efabc1aa2bf564923a47a12c8eb6a9207272c4ba383e
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tdiary-style-gfm.gemspec
4
+ gemspec
5
+
6
+ gem 'tdiary', github: 'tdiary/tdiary-core'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 SHIBATA Hiroshi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Tdiary::Style::Gfm
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'tdiary-style-gfm'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tdiary-style-gfm
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,195 @@
1
+ # -*- coding: utf-8; -*-
2
+ #
3
+ # gfm_style.rb: "GitHub Flavored Markdown" (GFM) style for tDiary 2.x format.
4
+ #
5
+ # if you want to use this style, add @style into tdiary.conf below:
6
+ #
7
+ # @style = 'GFM'
8
+ #
9
+ # Copyright (C) 2003, TADA Tadashi <sho@spc.gr.jp>
10
+ # Copyright (C) 2004, MoonWolf <moonwolf@moonwolf.com>
11
+ # Copyright (C) 2012, kdmsnr <kdmsnr@gmail.com>
12
+ # Copyright (C) 2013, hsbt <shibata.hiroshi@gmail.com>
13
+ # You can distribute this under GPL.
14
+ #
15
+
16
+ require 'redcarpet'
17
+ require 'pygments'
18
+ require 'twitter-text'
19
+
20
+ class HTMLwithPygments < Redcarpet::Render::HTML
21
+ def block_code(code, language)
22
+ Pygments.highlight(code, :lexer => language)
23
+ rescue Exception
24
+ <<-HTML
25
+ <div class="highlight"><pre>#{CGI.escapeHTML(code)}</pre></div>
26
+ HTML
27
+ end
28
+ end
29
+
30
+ module TDiary
31
+ module Style
32
+ class GfmSection
33
+ include BaseSection
34
+ include Twitter::Autolink
35
+
36
+ def initialize(fragment, author = nil)
37
+ @author = author
38
+ @subtitle, @body = fragment.split(/\n/, 2)
39
+ @subtitle.sub!(/^\#\s*/,'')
40
+ @body ||= ''
41
+
42
+ @categories = get_categories
43
+ @stripped_subtitle = strip_subtitle
44
+
45
+ @subtitle_to_html = @subtitle ? to_html('# ' + @subtitle).gsub(/\A<h\d>|<\/h\d>\z/io, '') : nil
46
+ @stripped_subtitle_to_html = @stripped_subtitle ? to_html('# ' + @stripped_subtitle).gsub(/\A<h\d>|<\/h\d>\z/io, '') : nil
47
+ @body_to_html = to_html(@body)
48
+ end
49
+
50
+ def subtitle=(subtitle)
51
+ @subtitle = (subtitle || '').sub(/^# /,"\##{categories_to_string} ")
52
+ @strip_subtitle = strip_subtitle
53
+ end
54
+
55
+ def categories=(categories)
56
+ @subtitle = "#{categories_to_string} " + (strip_subtitle || '')
57
+ @strip_subtitle = strip_subtitle
58
+ end
59
+
60
+ def to_src
61
+ r = ''
62
+ r << "\# #{@subtitle}\n" if @subtitle
63
+ r << @body
64
+ end
65
+
66
+ def do_html4(date, idx, opt)
67
+ subtitle = to_html('# ' + @subtitle)
68
+ subtitle.sub!( %r!<h3>(.+?)</h3>!m ) do
69
+ "<h3><%= subtitle_proc( Time.at( #{date.to_i} ), #{$1.dump.gsub( /%/, '\\\\045' )} ) %></h3>"
70
+ end
71
+ if opt['multi_user'] and @author then
72
+ subtitle.sub!(/<\/h3>/,%Q|[#{@author}]</h3>|)
73
+ end
74
+ r = subtitle
75
+ r << @body_to_html
76
+ end
77
+
78
+ private
79
+
80
+ def to_html(string)
81
+ renderer = HTMLwithPygments.new(:hard_wrap => true)
82
+ extensions = {:fenced_code_blocks => true, :tables => true, :no_intra_emphasis => true}
83
+ r = Redcarpet::Markdown.new(renderer, extensions).render(string)
84
+
85
+ # Twitter Autolink
86
+ r = auto_link(r)
87
+
88
+ if r =~ /(<pre>|<code>)/
89
+ r.gsub!(/<a class=\"tweet-url username\" href=\".*?\">(.*?)<\/a>/){ $1 }
90
+ end
91
+
92
+ # except url autolink in plugin block
93
+ if r =~ /\{\{.+?\}\}/
94
+ r.gsub!(/<a href=\"(.*?)\" rel=\"nofollow\">.*?<\/a>/){ $1 }
95
+ r.gsub!(/\{\{(.+?)\}\}/) { "<%=#{CGI.unescapeHTML($1).gsub(/&#39;/, "'").gsub(/&quot;/, '"')}%>" }
96
+ end
97
+
98
+ # ignore duplicate autolink
99
+ if r =~ /<a href="<a href="/
100
+ r.gsub!(/<a href="<a href=".*?" rel="nofollow">(.*?)<\/a>"(.*?)>(.*?)<\/a>/) do
101
+ "<a href=\"#{$1}\" rel=\"nofollow\"#{$2}>#{$3}</a>"
102
+ end
103
+ end
104
+ # ignore auto imagelink
105
+ if r =~ /<img src="<a href="/
106
+ r.gsub!(/<img src="<a href=".*?" rel="nofollow">(.*?)<\/a>"(?: alt="(.*?)")?>/){ "<img src=\"#{$1}\" alt=\"#{$2}\">" }
107
+ end
108
+
109
+ # emoji
110
+ r = r.emojify
111
+
112
+ # diary anchor
113
+ r.gsub!(/<h(\d)/) { "<h#{$1.to_i + 2}" }
114
+ r.gsub!(/<\/h(\d)/) { "</h#{$1.to_i + 2}" }
115
+
116
+ # my syntax
117
+ r.gsub!(/<a href="(\d{4}|\d{6}|\d{8}|\d{8}-\d+)[^\d]*?#?([pct]\d+)?">(.*?)<\/a>/) {
118
+ unless $3.empty?
119
+ %Q|<%=my "#{$1}#{$2}", "#{$3}" %>|
120
+ else
121
+ %Q|<%=my "#{$1}#{$2}", "#{$1}#{$2}" %>|
122
+ end
123
+ }
124
+
125
+ r
126
+ end
127
+
128
+ def get_categories
129
+ return [] unless @subtitle
130
+ cat = /(\\?\[([^\[]+?)\\?\])+/.match(@subtitle).to_a[0]
131
+ return [] unless cat
132
+ cat.scan(/\\?\[(.*?)\\?\]/).collect do |c|
133
+ c[0].split(/,/)
134
+ end.flatten
135
+ end
136
+
137
+ def strip_subtitle
138
+ return nil unless @subtitle
139
+ r = @subtitle.sub(/^((\\?\[[^\[]+?\]\\?)+\s+)?/, '')
140
+ if r.empty?
141
+ nil
142
+ else
143
+ r
144
+ end
145
+ end
146
+ end
147
+
148
+ class GfmDiary
149
+ include BaseDiary
150
+ include CategorizableDiary
151
+
152
+ def initialize(date, title, body, modified = Time.now)
153
+ init_diary
154
+ replace( date, title, body )
155
+ @last_modified = modified
156
+ end
157
+
158
+ def style
159
+ 'GFM'
160
+ end
161
+
162
+ def append(body, author = nil)
163
+ section = nil
164
+ body.each_line do |l|
165
+ case l
166
+ when /^\#[^\#]/
167
+ @sections << GfmSection.new(section, author) if section
168
+ section = l
169
+ else
170
+ section = '' unless section
171
+ section << l
172
+ end
173
+ end
174
+ if section
175
+ section << "\n" unless section =~ /\n\n\z/
176
+ @sections << GfmSection.new(section, author)
177
+ end
178
+ @last_modified = Time.now
179
+ self
180
+ end
181
+
182
+ def add_section(subtitle, body)
183
+ @sections = GfmSection.new("\# #{subtitle}\n\n#{body}")
184
+ @sections.size
185
+ end
186
+ end
187
+ end
188
+ end
189
+
190
+ # Local Variables:
191
+ # mode: ruby
192
+ # indent-tabs-mode: t
193
+ # tab-width: 3
194
+ # ruby-indent-level: 3
195
+ # End:
@@ -0,0 +1,7 @@
1
+ module Tdiary
2
+ module Style
3
+ module Gfm
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'tdiary/comment_manager'
3
+ require 'tdiary/referer_manager'
4
+ require 'tdiary/style'
5
+ require 'tdiary/style/gfm'
@@ -0,0 +1,379 @@
1
+ # -*- coding: utf-8; -*-
2
+ require 'spec_helper'
3
+
4
+ describe TDiary::Style::GfmDiary do
5
+ before do
6
+ @diary = TDiary::Style::GfmDiary.new(Time.at( 1041346800 ), "TITLE", "")
7
+ end
8
+
9
+ describe '#append' do
10
+ before do
11
+ @source = <<-'EOF'
12
+ # subTitle
13
+ honbun
14
+
15
+ ## subTitleH4
16
+ honbun
17
+
18
+ EOF
19
+ @diary.append(@source)
20
+ end
21
+
22
+ context 'HTML' do
23
+ before do
24
+ @html = <<-'EOF'
25
+ <div class="section">
26
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
27
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
28
+ <p>honbun</p>
29
+
30
+ <h4>subTitleH4</h4>
31
+
32
+ <p>honbun</p>
33
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
34
+ </div>
35
+ EOF
36
+ end
37
+ it { @diary.to_html.should eq @html }
38
+ end
39
+
40
+ context 'CHTML' do
41
+ before do
42
+ @html = <<-'EOF'
43
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
44
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
45
+ <p>honbun</p>
46
+
47
+ <h4>subTitleH4</h4>
48
+
49
+ <p>honbun</p>
50
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
51
+ EOF
52
+ end
53
+ it { @diary.to_html({}, :CHTML).should eq @html }
54
+ end
55
+
56
+ context 'to_src' do
57
+ it { @diary.to_src.should eq @source }
58
+ end
59
+ end
60
+
61
+ describe '#replace' do
62
+ before do
63
+ source = <<-'EOF'
64
+ # subTitle
65
+ honbun
66
+
67
+ ## subTitleH4
68
+ honbun
69
+
70
+ EOF
71
+ @diary.append(source)
72
+
73
+ replaced = <<-'EOF'
74
+ # replaceTitle
75
+ replace
76
+
77
+ ## replaceTitleH4
78
+ replace
79
+
80
+ EOF
81
+ @diary.replace(Time.at( 1041346800 ), "TITLE", replaced)
82
+
83
+ @html = <<-'EOF'
84
+ <div class="section">
85
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
86
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "replaceTitle" ) %></h3>
87
+ <p>replace</p>
88
+
89
+ <h4>replaceTitleH4</h4>
90
+
91
+ <p>replace</p>
92
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
93
+ </div>
94
+ EOF
95
+ end
96
+ it { @diary.to_html.should eq @html }
97
+ end
98
+
99
+ describe 'autolink' do
100
+ before do
101
+ source = <<-EOF
102
+ # subTitle
103
+
104
+ * http://www.google.com
105
+
106
+ [google](https://www.google.com)
107
+
108
+ http://www.google.com
109
+ EOF
110
+ @diary.append(source)
111
+ @html = <<-EOF
112
+ <div class="section">
113
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
114
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
115
+ <ul>
116
+ <li><a href="http://www.google.com" rel="nofollow">http://www.google.com</a></li>
117
+ </ul>
118
+
119
+ <p><a href="https://www.google.com" rel="nofollow">google</a></p>
120
+
121
+ <p><a href="http://www.google.com" rel="nofollow">http://www.google.com</a></p>
122
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
123
+ </div>
124
+ EOF
125
+ end
126
+
127
+ it { @diary.to_html.should eq @html }
128
+ end
129
+
130
+ describe 'auto imagelink' do
131
+ before do
132
+ source = <<-EOF
133
+ # subTitle
134
+
135
+ ![](http://www.google.com/logo.jpg)
136
+
137
+ ![google](http://www.google.com/logo.jpg)
138
+ EOF
139
+ @diary.append(source)
140
+ @html = <<-EOF
141
+ <div class="section">
142
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
143
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
144
+ <p><img src="http://www.google.com/logo.jpg" alt=""></p>
145
+
146
+ <p><img src="http://www.google.com/logo.jpg" alt="google"></p>
147
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
148
+ </div>
149
+ EOF
150
+ end
151
+
152
+ it { @diary.to_html.should eq @html }
153
+
154
+ end
155
+
156
+ describe 'auto imagelink' do
157
+ before do
158
+ source = <<-EOF
159
+ # subTitle
160
+
161
+ <a href="http://www.exaple.com" target="_blank">Anchor</a>
162
+ EOF
163
+ @diary.append(source)
164
+ @html = <<-EOF
165
+ <div class="section">
166
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
167
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
168
+ <p><a href="http://www.exaple.com" rel="nofollow" target="_blank">Anchor</a></p>
169
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
170
+ </div>
171
+ EOF
172
+ end
173
+
174
+ it { @diary.to_html.should eq @html }
175
+
176
+ end
177
+
178
+ describe 'url syntax with code blocks' do
179
+ before do
180
+ source = <<-'EOF'
181
+ # subTitle
182
+
183
+ ```ruby
184
+ @foo
185
+ ```
186
+
187
+ http://example.com is example.com
188
+
189
+ EOF
190
+ @diary.append(source)
191
+
192
+ @html = <<-'EOF'
193
+ <div class="section">
194
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
195
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
196
+ <div class="highlight"><pre><span class="vi">@foo</span>
197
+ </pre></div>
198
+ <p><a href="http://example.com" rel="nofollow">http://example.com</a> is example.com</p>
199
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
200
+ </div>
201
+ EOF
202
+ end
203
+ it { @diary.to_html.should eq @html }
204
+ end
205
+
206
+ describe 'ignored url syntax with markdown anchor' do
207
+ before do
208
+ source = <<-'EOF'
209
+ # subTitle
210
+
211
+ [example](http://example.com) is example.com
212
+
213
+ EOF
214
+ @diary.append(source)
215
+
216
+ @html = <<-'EOF'
217
+ <div class="section">
218
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
219
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
220
+ <p><a href="http://example.com" rel="nofollow">example</a> is example.com</p>
221
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
222
+ </div>
223
+ EOF
224
+ end
225
+ it { @diary.to_html.should eq @html }
226
+ end
227
+
228
+ describe 'plugin syntax' do
229
+ before do
230
+ source = <<-'EOF'
231
+ # subTitle
232
+ {{plugin 'val'}}
233
+
234
+ {{plugin "val", 'val'}}
235
+
236
+ EOF
237
+ @diary.append(source)
238
+
239
+ @html = <<-'EOF'
240
+ <div class="section">
241
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
242
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
243
+ <p><%=plugin 'val'%></p>
244
+
245
+ <p><%=plugin "val", 'val'%></p>
246
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
247
+ </div>
248
+ EOF
249
+ end
250
+ it { @diary.to_html.should eq @html }
251
+ end
252
+
253
+ describe 'plugin syntax with url args' do
254
+ before do
255
+ source = <<-'EOF'
256
+ # subTitle
257
+ {{plugin 'http://www.example.com/foo.html', "https://www.example.com/bar.html"}}
258
+
259
+ EOF
260
+ @diary.append(source)
261
+
262
+ @html = <<-'EOF'
263
+ <div class="section">
264
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
265
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
266
+ <p><%=plugin 'http://www.example.com/foo.html', "https://www.example.com/bar.html"%></p>
267
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
268
+ </div>
269
+ EOF
270
+ end
271
+ it { @diary.to_html.should eq @html }
272
+ end
273
+
274
+ describe 'link to my plugin' do
275
+ before do
276
+ source = <<-'EOF'
277
+ # subTitle
278
+
279
+ ()[20120101p01]
280
+
281
+ (Link)[20120101p01]
282
+
283
+ EOF
284
+ @diary.append(source)
285
+
286
+ @html = <<-'EOF'
287
+ <div class="section">
288
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
289
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
290
+ <p><%=my "20120101p01", "20120101p01" %></p>
291
+
292
+ <p><%=my "20120101p01", "Link" %></p>
293
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
294
+ </div>
295
+ EOF
296
+ end
297
+ it { @diary.to_html.should eq @html }
298
+ end
299
+
300
+ describe 'code highlighting' do
301
+ before do
302
+ source = <<-'EOF'
303
+ # subTitle
304
+
305
+ ```ruby
306
+ def class
307
+ @foo = 'bar'
308
+ end
309
+ ```
310
+ EOF
311
+ @diary.append(source)
312
+
313
+ @html = <<-'EOF'
314
+ <div class="section">
315
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
316
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
317
+ <div class="highlight"><pre> <span class="k">def</span> <span class="nf">class</span>
318
+ <span class="vi">@foo</span> <span class="o">=</span> <span class="s1">&#39;bar&#39;</span>
319
+ <span class="k">end</span>
320
+ </pre></div><%=section_leave_proc( Time.at( 1041346800 ) )%>
321
+ </div>
322
+ EOF
323
+ end
324
+ it { @diary.to_html.should eq @html }
325
+ end
326
+
327
+ describe 'ignore emphasis' do
328
+ before do
329
+ source = <<-'EOF'
330
+ # subTitle
331
+
332
+ @a_matsuda is amatsuda
333
+
334
+ {{isbn_left_image ''}}
335
+ EOF
336
+ @diary.append(source)
337
+
338
+ @html = <<-'EOF'
339
+ <div class="section">
340
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
341
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
342
+ <p>@<a class="tweet-url username" href="https://twitter.com/a_matsuda" rel="nofollow">a_matsuda</a> is amatsuda</p>
343
+
344
+ <p><%=isbn_left_image ''%></p>
345
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
346
+ </div>
347
+ EOF
348
+ end
349
+ it { @diary.to_html.should eq @html }
350
+ end
351
+
352
+ describe 'emoji' do
353
+ before do
354
+ source = <<-'EOF'
355
+ # subTitle
356
+
357
+ :sushi: は美味しい
358
+ EOF
359
+ @diary.append(source)
360
+
361
+ @html = <<-'EOF'
362
+ <div class="section">
363
+ <%=section_enter_proc( Time.at( 1041346800 ) )%>
364
+ <h3><%= subtitle_proc( Time.at( 1041346800 ), "subTitle" ) %></h3>
365
+ <p><img src='http://www.emoji-cheat-sheet.com/graphics/emojis/sushi.png' width='20' height='20' title='sushi' alt='sushi' class='emoji' /> は美味しい</p>
366
+ <%=section_leave_proc( Time.at( 1041346800 ) )%>
367
+ </div>
368
+ EOF
369
+ end
370
+ it { @diary.to_html.should eq @html }
371
+ end
372
+ end
373
+
374
+ # Local Variables:
375
+ # mode: ruby
376
+ # indent-tabs-mode: t
377
+ # tab-width: 3
378
+ # ruby-indent-level: 3
379
+ # End:
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tdiary/style/gfm/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tdiary-style-gfm"
8
+ spec.version = Tdiary::Style::Gfm::VERSION
9
+ spec.authors = ["SHIBATA Hiroshi"]
10
+ spec.email = ["shibata.hiroshi@gmail.com"]
11
+ spec.description = %q{GFM Style for tDiary}
12
+ spec.summary = %q{GFM Style for tDiary}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'redcarpet'
22
+ spec.add_dependency 'pygments.rb'
23
+ spec.add_dependency 'twitter-text'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tdiary-style-gfm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - SHIBATA Hiroshi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: redcarpet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pygments.rb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: twitter-text
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: GFM Style for tDiary
98
+ email:
99
+ - shibata.hiroshi@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - lib/tdiary/style/gfm.rb
112
+ - lib/tdiary/style/gfm/version.rb
113
+ - spec/spec_helper.rb
114
+ - spec/tdiary/style/gfm_spec.rb
115
+ - tdiary-style-gfm.gemspec
116
+ homepage: ''
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.1.3
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: GFM Style for tDiary
140
+ test_files:
141
+ - spec/spec_helper.rb
142
+ - spec/tdiary/style/gfm_spec.rb
143
+ has_rdoc: