Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created April 5, 2012 21:43
Show Gist options
  • Save cowboy/2314423 to your computer and use it in GitHub Desktop.
Save cowboy/2314423 to your computer and use it in GitHub Desktop.
Linkify every H2+ in *.md MarkDown files with a ⚑ for GitHub-friendly deep-linking.
ruby -pi -e '$_.gsub!(/(##+)\s+(.*?)\s*\n/){a,b=$1,$2;name=b.downcase.gsub(/\W+/,"-").gsub(/^-|-$/,"");%{#{a} #{b} <a name="#{name}" href="##{name}" title="Link to this section">⚑</a>\n}}' *.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment