Fancy tables
This commit is contained in:
parent
d73213dba7
commit
beda980dec
1 changed files with 15 additions and 4 deletions
|
@ -5,11 +5,22 @@ RubyPython.start python_exe: 'python2.6' if ENV['RACK_ENV'] == 'production'
|
||||||
class MarkdownHTML < Redcarpet::Render::HTML
|
class MarkdownHTML < Redcarpet::Render::HTML
|
||||||
include Redcarpet::Render::SmartyPants
|
include Redcarpet::Render::SmartyPants
|
||||||
|
|
||||||
def initialize(options={})
|
|
||||||
super options.merge(with_toc_data: true)
|
|
||||||
end
|
|
||||||
|
|
||||||
def block_code(code, language)
|
def block_code(code, language)
|
||||||
Pygments.highlight(code, lexer: language)
|
Pygments.highlight(code, lexer: language)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def table(header, body)
|
||||||
|
el('table', el('thead', header) + el('tbody', body), class: 'table table-striped table-bordered')
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def el(el, content, attributes = {})
|
||||||
|
if content
|
||||||
|
attrs = attributes ? ' ' + attributes.map { |k,v| "#{k}=\"#{v}\"" }.join(' ') : ''
|
||||||
|
"<#{el}#{attrs}>\n#{content}</#{el}>\n"
|
||||||
|
else
|
||||||
|
''
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue