Skip to content

Instantly share code, notes, and snippets.

@gam0022
Last active December 12, 2015 04:09
Show Gist options
  • Save gam0022/4712560 to your computer and use it in GitHub Desktop.
Save gam0022/4712560 to your computer and use it in GitHub Desktop.
h1の見出しにはアンカーリンクを作成する。
@@ -16,7 +16,7 @@ module OctopressFilters
end
def post_filter(input)
input = unwrap(input)
- RubyPants.new(input).to_html
+ RubyPants.new(input).to_html.gsub(/<h1>([^<].*[^>])<\/h1>/, '<h1><a name="\1" href="#\1">\1</a></h1>')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment