Skip to content

Instantly share code, notes, and snippets.

@tetkuz
Last active November 16, 2015 00:11
Show Gist options
  • Save tetkuz/88b1d4744ee0e2074c30 to your computer and use it in GitHub Desktop.
Save tetkuz/88b1d4744ee0e2074c30 to your computer and use it in GitHub Desktop.
Markdown to Textile
#!/bin/sh
### USASE ###
#
# 0. This script depend on `pandoc`
#
# 1. Please set `markdown file`
# ./md2textile.sh hoge.md
#
# 2. Will generate `textile file`
# hoge.textile
#
# pandoc check
which pandoc
if [ $? -ne 0 ]; then
echo "please install: pandoc"
echo "debian: apt-get install pandoc"
exit 1
fi
# file check
if [ ! "$1" ]; then
echo "$0 filename"
exit 1
else
if [ ! -e $1 ]; then
echo "input error"
exit 1
fi
fi
input=$1
is_md=$false
if [ "${input##*.}" = "md" ]; then
is_md="true"
output="${input%.*}.textile"
else
is_md="false"
output="${input}.textile"
cp $input "$input.md"
input="$input.md"
fi
pandoc -s $input -o $output
if [ "$is_md" = "false" ]; then
rm $input
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment