Files
linux-bin/reveal.sh

41 lines
1.1 KiB
Bash
Raw Normal View History

2019-02-05 19:30:40 -08:00
#!/bin/bash
2020-02-13 12:11:29 -08:00
if [ "$1" == "-h" ] ; then
echo "
reveal - helper app for opening reveal.js markdown presentations
Useful for serving markdown text files locally with reveal.js
Usage: reveal.sh neuroanatomy1.md
2021-03-30 00:37:43 -07:00
reveal.sh neuroanatomy1.md 8001
2020-02-13 12:11:29 -08:00
"
echo "$(tput setaf 6)$EDITOR $(tput setaf 7)is currently set as editor"
exit 0
fi
set -e
2021-05-29 08:19:30 -04:00
appPath="$HOME/projects/dev/reveal.js"
2021-03-30 00:37:43 -07:00
portNumber=${2:-8000}
2023-05-15 10:49:24 -04:00
fn=$1 #markdown document to render e.g. neuroanatomy1.md
basefn=$(basename $fn)
fullfn=$(realpath $fn)
2019-02-05 19:30:40 -08:00
if [[ ! -d $appPath ]]; then
echo "reveal.js not found"
exit 1
else
cd $appPath
fi
2021-05-29 08:19:30 -04:00
if [[ ! -e $basefn ]]; then
2023-05-15 10:49:24 -04:00
ln -s $fullfn $basefn
2019-02-05 19:30:40 -08:00
fi
2021-10-19 00:34:23 -07:00
#add markdown filename into html title tag
fn2=$(echo $basefn | sed -E 's/[0-9]{2,4}-//g' | sed 's/\.md//') #prep filename
sed -i -E "s|(<title>).+(<\/title>)|\1$fn2\2|" index.html #swap in document title
2019-02-05 19:30:40 -08:00
#add markdown filename to reveal placeholder start file
2021-05-29 08:19:30 -04:00
sed -i -E "s|(<section data-markdown=\")[A-Za-z0-9\.-]*(\" )|\1$basefn\2|" index.html
2021-03-30 00:37:43 -07:00
npm start -- --port=$portNumber
# npm start