hateda2md 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,20 +31,21 @@ module HateDa::Converter
31
31
 
32
32
  def self.pre_defined_filters(aliases=false)
33
33
  als = aliases ? [] : [:header, :subheader, :subsubheader, :ul, :ol]
34
- private_instance_methods(false) - [:SYM] - als
34
+ excludes = ->m{ als.include?(m) || m.to_s.start_with?('_') }
35
+ private_instance_methods(false).reject(&excludes)
35
36
  end
36
37
 
37
38
  private
38
- def SYM(key)
39
+ def _SYM(key)
39
40
  {h1:'#',h2:'##',h3:'###',h4:'####',h5:'#####'}[key]
40
41
  end
41
42
 
42
43
  def title(h=:h1)
43
44
  filter(/\*p?\d+\*(.*)$/) do |md, st|
44
45
  st[:titles] << md[1]
45
- "#{SYM(h)}#{md[1]}"
46
+ "#{_SYM(h)}#{md[1]}"
46
47
  end
47
- filter(/^#{SYM(h)}.*$/, global:false) do |md, st|
48
+ filter(/^#{_SYM(h)}.*$/, global:false) do |md, st|
48
49
  st[:titles].size == 1 ? '' : md.to_s
49
50
  end
50
51
  end
@@ -53,7 +54,7 @@ module HateDa::Converter
53
54
  def subtitle(h=:h2)
54
55
  filter(/^\*\*((?!\*).*)$/) do |md, st|
55
56
  st[:subtitles] << md[1]
56
- "#{SYM(h)}#{md[1]}"
57
+ "#{_SYM(h)}#{md[1]}"
57
58
  end
58
59
  end
59
60
  alias :subheader :subtitle
@@ -61,7 +62,7 @@ module HateDa::Converter
61
62
  def subsubtitle(h=:h3)
62
63
  filter(/^\*\*\*((?!\*).*)$/) do |md, st|
63
64
  st[:subsubtitles] << md[1]
64
- "#{SYM(h)}#{md[1]}"
65
+ "#{_SYM(h)}#{md[1]}"
65
66
  end
66
67
  end
67
68
  alias :subsubheader :subsubtitle
@@ -136,7 +137,7 @@ module HateDa::Converter
136
137
  if liquid
137
138
  "{% hatebu #{md[1]} %}"
138
139
  else
139
- hatebu_html(md[1])
140
+ _hatebu_html(md[1])
140
141
  end
141
142
  end
142
143
  end
@@ -161,7 +162,7 @@ module HateDa::Converter
161
162
  if liquid
162
163
  "{% youtube #{md[1]} %}"
163
164
  else
164
- youtube_html(md)
165
+ _youtube_html(md)
165
166
  end
166
167
  end
167
168
  end
@@ -181,12 +182,12 @@ module HateDa::Converter
181
182
  if liquid
182
183
  "{% gist #{md[1]} #{md[2]} %}"
183
184
  else
184
- gist_html(md)
185
+ _gist_html(md)
185
186
  end
186
187
  end
187
188
  end
188
189
 
189
- def hatebu_html(md)
190
+ def _hatebu_html(md)
190
191
  url, title = md.to_s.match(/(https?:\/\/\S+)(.*)/){ [$1, $2] }
191
192
  bm_url = %{<a href="http://b.hatena.ne.jp/entry/#{url}" class="http-bookmark" target="_blank"><img src="http://b.hatena.ne.jp/entry/image/#{url}" alt="" class="http-bookmark"></a>}
192
193
 
@@ -197,11 +198,11 @@ module HateDa::Converter
197
198
  end
198
199
  end
199
200
 
200
- def gist_html(md)
201
+ def _gist_html(md)
201
202
  %{<div><script src="https://gist.github.com/#{md[1]}.js?file=#{md[2]}"></script></div>%}
202
203
  end
203
204
 
204
- def youtube_html(md)
205
+ def _youtube_html(md)
205
206
  %{<iframe width="560" height="420" src="http://www.youtube.com/embed/#{md[1]}?color=white&theme=light"></iframe>}
206
207
  end
207
208
  end
@@ -1,3 +1,3 @@
1
1
  module Hateda2md
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hateda2md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2153731440 !ruby/object:Gem::Requirement
16
+ requirement: &2156110820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2153731440
24
+ version_requirements: *2156110820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &2153730980 !ruby/object:Gem::Requirement
27
+ requirement: &2156110360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153730980
35
+ version_requirements: *2156110360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: gsub_filter
38
- requirement: &2153730560 !ruby/object:Gem::Requirement
38
+ requirement: &2156109940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2153730560
46
+ version_requirements: *2156109940
47
47
  description: Convert Hatena-Diary XML file to Markdown files for Jekyll
48
48
  email:
49
49
  - postagie@gmail.com