#!/bin/sh # Markdown v1.3 2007/06/05 # Build an HTML page (with headers) from Markdown.pl output. INCLUDES=/home/web/www.reppep.com/include if [ $QUERY_STRING = 'markdown' ] then echo "Content-type: text/plain" echo cat $PATH_TRANSLATED exit 0 # Request is for verbatim source (Markdown format, not HTML) fi echo "Content-type: text/html" echo TITLE=`head -1 $PATH_TRANSLATED | cut -f2` cat $INCLUDES/head1.incl echo $TITLE cat $INCLUDES/head2.incl # If we already have an H1, don't insert one. if ! grep --silent '^# ' $PATH_TRANSLATED then echo -n '

' echo -n $TITLE echo '

' echo fi /usr/local/bin/Markdown.pl < $PATH_TRANSLATED 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 # Version History # v1.3: Unrendered source available with '?markdown' appended to base URL # v1.2: Source is .markdown, available without modification. # Access as .text to get HTML version.