summaryrefslogtreecommitdiff
path: root/plain.sh
diff options
context:
space:
mode:
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