#!/bin/sh
# Markdown v1.2 2007/05/28
# Build an HTML page (with headers) from Markdown.pl output.
# v1.2: Source is .markdown, available without modification.
# Access as .text to get HTML version.
INCLUDES=/home/web/www.reppep.com/include
REALFILE=`dirname $PATH_TRANSLATED`/`basename $PATH_TRANSLATED .text`.markdown
TITLE=`head -1 $REALFILE | cut -f2`
echo "Content-type: text/html"
echo
cat $INCLUDES/head1.incl
echo $TITLE
cat $INCLUDES/head2.incl
# If we already have an H1, don't insert one.
if ! grep --silent '^# ' $REALFILE
then
echo -n '
'
echo -n $TITLE
echo '
'
echo
fi
/usr/local/bin/Markdown.pl < $REALFILE
cat $INCLUDES/foot.incl
exit 0
# http://www.extrapepperoni.com/category/computers/markdown/
# http://daringfireball.net/projects/markdown/
# To use, copy Markdown.cgi (this wrapper, which you may have to rename
# from Markdown.txt) and Markdown.pl (from Daring Fireball) into your
# cgi-bin/ and make them executable
# ("chmod +x Markdown.cgi Markdown.pl"), set the correct path for
# INCLUDES below, and install head1.incl (HTML header up to ),
# head2.incl (HTML header starting with ), and foot.incl in
# that directory.
# Markdown.cgi reads the page's title from the first line, starting
# after the first tab and ending before the second.
# Your document's title should be inside an HTML comment, set off by tabs.
# Follow the title line with a blank line (Markdown.pl requires blank
# lines between block elements).
# The title line contains 5 parts:
# 1) the HTML comment open delimiter (less-bang-dash-dash)
# 2) a tab
# 3) the title text
# 4) a tab
# 5) the HTML comment close delimiter (dash-dash-greater)
# For example (not counting the # on the next line):
#
# Add the following to your Apache httpd configuration
# (likely httpd.conf or a virtual host .conf file):
# AddHandler markdown .text
# Action markdown /cgi-bin/Markdown.cgi
# AddType text/html .text
# ScriptAlias /cgi-bin/ /home/web/www.reppep.com/cgi-bin/
# AddType text/html .pl