diff --git a/lib/markdown_html.rb b/lib/markdown_html.rb
index b0de173..c6f7440 100644
--- a/lib/markdown_html.rb
+++ b/lib/markdown_html.rb
@@ -11,8 +11,16 @@ class MarkdownHTML < Redcarpet::Render::HTML
el('table', el('thead', header) + el('tbody', body), class: 'table table-striped table-bordered')
end
+ def header(text, level)
+ el("h#{level}", text, id: anchor(text))
+ end
+
private
+ def anchor(text)
+ text.downcase.strip.gsub(/[^a-z0-9 ]/, '').gsub(/\s+/, '-')
+ end
+
def el(el, content, attributes = {})
if content
attrs = attributes ? ' ' + attributes.map { |k,v| "#{k}=\"#{v}\"" }.join(' ') : ''