Created
February 17, 2017 10:02
-
-
Save JamesKim2998/4fec41376f41c226ae59abb33dfcbcaf to your computer and use it in GitHub Desktop.
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 | |
if [ ! -d "$1" ]; then | |
echo Usage: $(basename "$0") BOOKDIR \> trpl.md | |
echo Then: pandoc -S -o trpl.epub trpl.md | |
exit 1 | |
fi | |
cat "$1/README.md" | |
echo | |
grep '^ *\*' "$1/SUMMARY.md" | | |
sed 's/^\*/main/g' | | |
sed 's/^ \+\*/sub/g' | | |
sed 's/\[.*\](\(.*\))/\1/g' | | |
while read level filename; do | |
cat "$1/$filename" | | |
if [ "$level" = "main" ]; then | |
sed 's/^\(#\+ \)/#\1/g' | | |
sed 's/^% /# /g' | |
else | |
sed 's/^\(#\+ \)/##\1/g' | | |
sed 's/^% /## /g' | |
fi | | |
sed 's/^\(```rust\),.*$/\1/g' | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment