Class: TDiary::Style::BloggfmDiary

Inherits:
GfmDiary
  • Object
show all
Defined in:
lib/tdiary/style/bloggfm.rb

Instance Method Summary collapse

Instance Method Details

#append(body, author = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tdiary/style/bloggfm.rb', line 14

def append( body, author = nil )
	in_code_block = false
	section = nil
	body.each_line do |l|
		case l
		when /^\#[^\#]/
			if in_code_block
				section << l
			else
				@sections << BloggfmSection.new(section, author) if section
				section = l
			end
		when /^```/
			in_code_block = !in_code_block
			section << l
		else
			section = '' unless section
			section << l
		end
	end
	if section
		section << "\n" unless section =~ /\n\n\z/
		@sections << BloggfmSection.new(section, author)
	end
	@last_modified = Time.now
	self
end

#styleObject



10
11
12
# File 'lib/tdiary/style/bloggfm.rb', line 10

def style
	'BlogGfm'
end

#to_html4(opt) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/tdiary/style/bloggfm.rb', line 42

def to_html4( opt )
	r = ''
	idx = 1
	each_section do |section|
		if idx > 1 and not opt['anchor'] then
			r << %Q|<p class="readmore"><a href="#{opt['index']}<%=anchor "#{date.strftime( '%Y%m%d' )}"%>">Read more..</a></p>\n|
			break
		end
		r << section.html4( date, idx, opt )
		idx += 1
	end
	r
end