summaryrefslogtreecommitdiff
path: root/plain.sh
diff options
context:
space:
mode:
authoreudoxia <uplink@distress.network>2020-12-05 21:35:46 -0500
committereudoxia <uplink@distress.network>2020-12-05 21:35:46 -0500
commitc149b2944f0759ea4daa1bf12539ee489bd420b4 (patch)
treea5a22f3052db2ed559c1778690e5c4fdc05bc0d4 /plain.sh
parent8b826ae4f741c022351e7e11a158ebd216703931 (diff)
several reliability improvements, other slight refactors
Diffstat (limited to 'plain.sh')
-rwxr-xr-xplain.sh13
1 files changed, 4 insertions, 9 deletions
diff --git a/plain.sh b/plain.sh
index 530c592..6208da7 100755
--- a/plain.sh
+++ b/plain.sh
@@ -18,15 +18,15 @@ set -e
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# i/o variables
IN="$1"
OUT="$2"
-[ -f $IN ] || { echo "---- [FATAL] $IN not found ----" ; exit 1 ; }
+[ "$1" ] || { echo "usage: ./plain.sh <input txt> <output html>" ; exit 1 ; }
+[ -f $IN ] || { echo "---- [FATAL] $IN not found ----" ; exit 1 ; }
+[ -f plain-header ] || { echo "---- [FATAL] plain-header not found ----" ; exit 1 ; }
-# initial write
cat plain-header > $2
cat $1 >> $2
@@ -34,15 +34,10 @@ printf "</pre>\n</body>\n</html>" >> $2
echo '[ok] initial assembly'
# hack to fix double <pre> when generating from nav.sh
-
sed -e "/^<pre>$/ {n;/^<pre>$/d}" -e "/^<\/pre>$/ {n;/^<\/pre>$/d}" -i'' $2
-# metadata
-
-sedesc() {
- sed -e 's;\&;\\\&;' -e 's/;/\\\;/' -e 's;-->;;'
-}
+sedesc() {sed -e 's;\&;\\\&;' -e 's/;/\\\;/' -e 's;-->;;'}
TITLE=$(grep -e '^<!--title: ' -m 1 $1 | cut -f 2- -d ' ' | sedesc)
sed -e "/^<!--title:/d" -e "s;<title>#;<title>${TITLE};1" -i'' $2