Skip to content

Instantly share code, notes, and snippets.

@karthikselva
Last active February 27, 2016 07:56
Show Gist options
  • Select an option

  • Save karthikselva/96d4755ed56800fa3e1a to your computer and use it in GitHub Desktop.

Select an option

Save karthikselva/96d4755ed56800fa3e1a to your computer and use it in GitHub Desktop.
Octopress to Jekyll Code tag converter
src = /{% include_code\s+([A-Za-z0-9\._]+)\s+%}/
files = Dir['_posts/*']
files.each do |e|
content =nil
File.open(e) do |f|
content = f.read
end
dest = content.gsub(src) {|m|
"{% highlight ruby %}
{% include {{page.permalink}}/downloads/code/#{$1} %}
{% endhighlight %}"
}
next if dest.eql?(content)
File.open(e,'w') do |f|
f.write dest
end
p dest
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment