tabs.rb 1.1 KB
Newer Older
1
module Jekyll
Ben Huber's avatar
Ben Huber committed
2 3 4
class TabsConverter < Converter
	safe true
	priority :low
5

Ben Huber's avatar
Ben Huber committed
6 7 8
	def matches(ext)
		ext =~ /^\.md$/i
	end
9

Ben Huber's avatar
Ben Huber committed
10 11 12
	def output_ext(ext)
		".html"
	end
13

Ben Huber's avatar
Ben Huber committed
14 15 16 17 18 19 20 21 22
	def convert(content)
	content.gsub('<p>__tabsInit</p>', "<input id=\"tab1\" type=\"radio\" name=\"tabs\" checked><input id=\"tab2\" type=\"radio\" name=\"tabs\">")
			.gsub('<p>__tabsStart</p>', "<div id=\"tabs\"><label for=\"tab1\">C++</label><label for=\"tab2\">Python</label><div id=\"content\"><section id=\"content1\">")
			.gsub('<p>__tabsMid</p>', "</section><section id=\"content2\">")
			.gsub('<p>__tabsEnd</p>', "</section></div></div>")
			.gsub('<p>__dangerStart</p>', "<div class=\"alert alert-danger\">")
			.gsub('<p>__dangerEnd</p>', "</div>")
			.gsub('<p>__warnStart</p>', "<div class=\"alert alert-warning\">")
			.gsub('<p>__warnEnd</p>', "</div>")
Ben Huber's avatar
Ben Huber committed
23 24
			.gsub('<p>__infoStart</p>', "<div class=\"alert alert-info\">")
			.gsub('<p>__infoEnd</p>', "</div>")
Ben Huber's avatar
Ben Huber committed
25 26
			.gsub('__breakFix1</a></p>', "")
			.gsub('<p>__breakFix2', "</a>")
27
			.gsub('__version', %x( cat ../VERSION ) )
28
			.gsub(/__doxyref\(([^\)]+)\)/){ |m| %x( ./findDoxytag #{$1} ) }
Ben Huber's avatar
Ben Huber committed
29 30
	end
end
31 32
end