Created
May 29, 2019 21:26
-
-
Save SimianLogic/4d56eb57c01adc35aa92cbbc987213ac to your computer and use it in GitHub Desktop.
markdown processor for introcave.com blog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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("'","'") | |
file << "</div>\n</div>" | |
file.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment