diff options
author | Connor Shea <connor.james.shea@gmail.com> | 2016-11-23 01:46:54 +0300 |
---|---|---|
committer | Connor Shea <connor.james.shea@gmail.com> | 2016-11-23 01:59:23 +0300 |
commit | b43087fb68934db1c9f992b9d580562742ef7dc0 (patch) | |
tree | 0ec542b39d62c665b58b80371d160f3fbcc2d2fc /lib | |
parent | be91e30adaabd1312395d1a03d4ac02e960a83bb (diff) |
Add anchor links to all headers.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helpers_.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/helpers_.rb b/lib/helpers_.rb index 589df4b7..7fa9d11f 100644 --- a/lib/helpers_.rb +++ b/lib/helpers_.rb @@ -9,4 +9,10 @@ require 'rouge/plugins/redcarpet' class HTML < Redcarpet::Render::HTML include Rouge::Plugins::Redcarpet + + def header(text, header_level) + anchor = text.downcase.strip.split(" ").join("-") + + "<h#{header_level} id='#{anchor}'>#{text} <a class='anchor' href='##{anchor}' title='Permalink'>¶</a></h#{header_level}>" + end end |