Skip to content

Instantly share code, notes, and snippets.

@SimianLogic
Created May 29, 2019 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimianLogic/4d56eb57c01adc35aa92cbbc987213ac to your computer and use it in GitHub Desktop.
Save SimianLogic/4d56eb57c01adc35aa92cbbc987213ac to your computer and use it in GitHub Desktop.
markdown processor for introcave.com blog
# Markdown Processor for the IntroCave Blog
# The IntroCave intro maker allows you to create dustomized intro videos for your YouTube channel with no experience
# USAGE
# ---------------------------------------------------------
# install the redcarpet gem first
# i usually drop this file into my drafts folder
# and use like "ruby process.rb filename.txt"
# it will then generate a filename_processed.txt with the HTML
require 'redcarpet'
class ICBlogRender < Redcarpet::Render::HTML
def paragraph(text)
if text.index("CAPTION") == 0
text = text.gsub("CAPTION:","")
"<p class=\"blog-caption\">#{text}</p>\n"
elsif text.index("CALLOUT") == 0
text = text.gsub("CALLOUT:","")
"<p class=\"callout\">#{text}</p>\n"
else
"<p>#{text}</p>\n"
end
end
end
filename = ARGV[0]
root = File.basename(filename, ".txt")
file = File.open("#{root}.txt",'r')
raw = file.read
file.close
renderer = ICBlogRender.new()
md = Redcarpet::Markdown.new(renderer)
file = File.open("#{root}_processed.txt","w")
file << "<div class=\"row\">\n<div class=\"col-md-12\">\n"
file << md.render(raw).gsub("&#39;","'")
file << "</div>\n</div>"
file.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment