Skip to content

Instantly share code, notes, and snippets.

@rretsiem
Last active December 11, 2015 04:39
Show Gist options
  • Save rretsiem/4546646 to your computer and use it in GitHub Desktop.
Save rretsiem/4546646 to your computer and use it in GitHub Desktop.
Convert Scriptogr.am markdown to Octopress markdown compatible files
#! /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