#!/bin/bash

# This script generates the HTML version of the User Guide
# for the txt2tags website.

outdir=/a/txt2tags/web/userguide/

# Regenerate HTML version (if needed)
test userguide.t2t -nt userguide.html && txt2tags userguide.t2t

# HTMLDOC splits the one-big-HTML-file to lots of tiny HTML files
htmldoc --book --no-title \
	--toclevels 2 --toctitle "Txt2tags User Guide" \
	-t htmlsep \
	-d "$outdir" \
	userguide.html

cd "$outdir" || { echo "Can't find $outdir, aborting." ; exit 1; }

# Requires Funcoes ZZ (http://funcoeszz.net)
funcoeszz trocapalavra '</HEAD>' \
	'<LINK REL="stylesheet" TYPE="text/css" HREF="userguide.css"></HEAD>' *.html

# Old links
ln -sf index.html userguide.html

open "$outdir/index.html"
exit 0
