Last active
December 11, 2015 04:39
-
-
Save rretsiem/4546646 to your computer and use it in GitHub Desktop.
Convert Scriptogr.am markdown to Octopress markdown compatible files
This file contains 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
#! /bin/bash | |
# convert scriptogr.am markdown to Octopress/Jekyll markdown | |
if [ -z "$1" ] | |
then | |
echo "No input files supplied" | |
else | |
if [ ! -f $1 ] | |
then | |
echo "File $1 does not exist." | |
else | |
filename=$1 | |
# echo "converting to lowercase" | |
sed -i '' -e "s/Title: /title: /" $filename | |
sed -i '' -e 's/Tags: /categories: /' $filename | |
sed -i '' -e 's/Date: /date: /' $filename | |
# echo "remove excerpt" | |
sed -i '' -e '/Excerpt: /d' $filename | |
# echo "set header start marker at the beginning (---)" | |
sed -i '' -e 's/date: /---\'$'\ndate: /' $filename | |
# echo "add a layout:post line" | |
sed -i '' -e 's/\(date:\)/layout: post \'$'\ndate:/g' $filename | |
# echo "convert categories and set a header end marker at the end" | |
sed -i '' -e 's/\(categories:\) \(.*\) \(.$\)/\1 [\2] \'$'\n--- /' $filename | |
echo "done!" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment