Last active
November 16, 2015 00:11
-
-
Save tetkuz/88b1d4744ee0e2074c30 to your computer and use it in GitHub Desktop.
Markdown to Textile
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/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