17 lines
655 B
Bash
Executable file
17 lines
655 B
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
cd "$(dirname "$0")"
|
|
if ! [ -e one-section-per-line.txt ] || ! [ -e bookmark.txt ]; then
|
|
echo "Please run $(dirname "$0")/init first to initialise the book"
|
|
exit 1; fi
|
|
head -"$(cat bookmark.txt)" one-section-per-line.txt | tail -1 |
|
|
sed 's,<p>,\n\n,g;s,</p>,,g;s,</*em>,*,g;s,<h1>,\n# ,g;s,<h2>,\n## ,g;s,<h3>,\n### ,g;s,<h4>,\n#### ,g;s,</h[1-4]>,,g'
|
|
|
|
echo
|
|
if [ "$(cat bookmark.txt)" -lt "$(wc -l < one-section-per-line.txt)" ]; then
|
|
echo "Run $(dirname "$0")/next to read on."
|
|
fi
|
|
if [ $(cat bookmark.txt) -gt 1 ]; then
|
|
echo "Run $(dirname "$0")/prev to go back."
|
|
echo "Run $(dirname "$0")/init to restart."
|
|
fi
|