37 lines
1.2 KiB
Bash
Executable File
37 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# set root path here? (currently this script is in script/, so org/ is ../)
|
|
# another 'trick' to fix the path is
|
|
dir=$(dirname $0/..)
|
|
# or
|
|
cd $(dirname $0/..) # $0 contains the full path to the script
|
|
|
|
# -s makes the doc a standalone document instead of a snippet
|
|
for doc in org/*.org
|
|
do
|
|
# This will return a list of files like 'org/somefile.org'.
|
|
# To only get the filename we use sed and use basename.
|
|
|
|
filename=$(basename $doc) # we want to get rid of .org
|
|
nosuffix=$(echo "$filename"|sed -E "s/\.org$//")
|
|
# -E makes it POSIX compatible
|
|
# $ locks it to the end, ^ to the beginning
|
|
# * . ( ) { } [ ] need to be escaped with \
|
|
htmlfile="html/$nosuffix.html"
|
|
|
|
|
|
echo "$doc > $htmlfile"
|
|
pandoc -s --toc $doc -o - | \
|
|
sed -E "s/(<\/title>)/\1\n <link rel=\"stylesheet\" type=\"text\/css\" href=\"css\/style.css\">/" | \
|
|
sed -E "s/(<body>)/\1\n<div class=\"container\">\n/" | \
|
|
sed -E "s/(<\/body>)/\n<\/div>\n\1>/" > $htmlfile
|
|
# The Skeleton template requires that everything is wrapped in a
|
|
# div class="container".
|
|
|
|
pandoc -s $doc -o md/$nosuffix.md
|
|
|
|
done
|
|
|
|
# one time only
|
|
pandoc org/README.org -o ./README.md
|
|
pandoc org/index.org -o ./index.html
|