typedown 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/typedown/section.rb +7 -9
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -11,7 +11,7 @@ module Typedown
11
11
  end
12
12
 
13
13
  def dummy?
14
- (title.empty?) && @body.empty? && subsections.length == 1
14
+ (title.empty?) && (!@body || @body.empty?) && subsections.length == 1
15
15
  end
16
16
 
17
17
  def title
@@ -39,26 +39,24 @@ module Typedown
39
39
 
40
40
  def self.sectionize body, title = nil
41
41
  s = nil
42
- if title
43
- s = Section.new title, body
44
- else
45
- s = Section.new "", body
46
- s.dummy? ? s.subsections[0] : s
47
- end
42
+ s = Section.new title || "", body || ""
43
+ s.dummy? ? s.subsections[0] : s
48
44
  end
49
45
 
50
46
  private
51
47
 
52
48
  def sectionize v
49
+ return if v == nil || v.strip.empty?
50
+
53
51
  body, rest = v.split(/^! /, 2)
54
52
  sections = []
55
53
 
56
54
  if rest
57
55
  rest.strip.split(/^! /).each do |s|
58
56
  title, rest = s.split(/$/, 2)
59
- rest.gsub!(/^!(!+ )/, "\\1")
57
+ rest.gsub!(/^!(!+ )/, "\\1") if rest
60
58
 
61
- sections << Section.new(title.strip, rest)
59
+ sections << Section.new(title || "", rest || "")
62
60
  end
63
61
  end
64
62
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typedown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - wrimle
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-20 00:00:00 +02:00
18
+ date: 2010-08-21 00:00:00 +02:00
19
19
  default_executable: typedown
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency