hamdown 0.0.13 → 0.0.14

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.
Files changed (2) hide show
  1. data/lib/hamdown.rb +15 -4
  2. metadata +3 -3
@@ -11,7 +11,9 @@ class Hamdown
11
11
 
12
12
  def to_html(options={})
13
13
  columns = options.delete(:columns) { false }
14
- timestamp
14
+ timestamp = options.delete(:timestamp) { false }
15
+ padlines = options.delete(:padlines) { 0 }
16
+ @innerfile = insert_timestamps(@innerfile) if timestamp
15
17
  if columns
16
18
  first_half = ""
17
19
  second_half = ""
@@ -27,20 +29,23 @@ class Hamdown
27
29
  second_half << line
28
30
  end
29
31
  end
32
+ first_half = insert_padding(padlines, first_half)
33
+ second_half = insert_padding(padlines, second_half)
30
34
  html = "<table><tr><td>\n"
31
35
  html << RDiscount.new(first_half).to_html
32
36
  html << "</td>\n<td>\n"
33
37
  html << RDiscount.new(second_half).to_html
34
38
  html << "</td></tr></table>"
35
39
  else
40
+ @innerfile = insert_padding(padlines, @innerfile)
36
41
  html = RDiscount.new(@innerfile).to_html
37
42
  end
38
43
  @outerfile ? Haml::Engine.new(@outerfile).render { html } : html
39
44
  end
40
45
 
41
- def timestamp
46
+ def insert_timestamps(source_lines)
42
47
  lines = ''
43
- @innerfile.each do |line|
48
+ source_lines.each do |line|
44
49
  if line.match(/(\[:(.*):\])/)
45
50
  if $2 == 'today'
46
51
  line.gsub!($1, Time.now.strftime('%B %d, %Y'))
@@ -50,7 +55,13 @@ class Hamdown
50
55
  end
51
56
  lines << line
52
57
  end
53
- @innerfile = lines
58
+ lines
54
59
  end
55
60
 
61
+ def insert_padding(padlines, source_lines)
62
+ count = padlines - source_lines.lines.count
63
+ source_lines += "_" * 10
64
+ count.times { source_lines += "\n \n " + '\_' * 30 }
65
+ source_lines
66
+ end
56
67
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamdown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 13
10
- version: 0.0.13
9
+ - 14
10
+ version: 0.0.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Robert Fletcher