Skip to content

Instantly share code, notes, and snippets.

@kripy
Created November 18, 2014 10:58
Show Gist options
  • Save kripy/7adec39d2c11cbce96f4 to your computer and use it in GitHub Desktop.
Save kripy/7adec39d2c11cbce96f4 to your computer and use it in GitHub Desktop.
All In Markdown
#!/usr/bin/env ruby
# coding: utf-8
require 'rubygems'
require 'redcarpet'
p_replace = '<p style="padding-top:10px;padding-left:30px;padding-right:30px;font-family:\'Helvetica Neue\',Helvetica,arial,sans-serif;font-size:15px;font-weight:normal;color:#000;line-height:20px;">'
i_replace = '<p><img class="image_fix"'
a_replace = '<a style="color:#ffff00;text-decoration:none;background-color:black" target="_blank" href'
renderer = Redcarpet::Render::HTML.new()
markdown = Redcarpet::Markdown.new(renderer, extensions = {})
file = File.new("allin-2.md", "rb")
contents = file.read
output = markdown.render(contents)
output = output.gsub(/<p>/, p_replace)
output = output.gsub(/<p style="padding-top:10px;padding-left:30px;padding-right:30px;font-family:\'Helvetica Neue\',Helvetica,arial,sans-serif;font-size:15px;font-weight:normal;color:#000;line-height:20px;"><img/, i_replace)
output = output.gsub(/<a href/, a_replace)
puts output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment