
!! Filter : setext2html.flt
!! Version : 1.0
!! Created : Friday, December 29, 2000 - 6:12:40 PM
!! Author : Donavan Hall  donavan@donavanhall.net
!! Author : Craig Upright cupright@alumni.princeton.edu
!! Description : Converts Setext markup to HTML
!! 

!! SYNTAX : 
!!  searchString    replacementString    [option]
!!    where the three arguments are separated by one or more tabulations.
!!    The option is a (possibly empty) string containing 0 or 1 and/or
!!    one of the letters i and m with the following signification :
!!        0 (or nothing) for an ordinary textual search (this is the default)
!!        1 for a search with regular expressions
!!        i for a case insensitive search
!!        m to match words exactly (not only a substring of a word)
!!    The options can be combined in any order : 0m, im1, i, 0m etc.
!!    A line starting with two exclamation signs is considered a comment
!!    and not a filter instruction.

!! Substitute pre-existing <>s
<	\&lt\;	1
>	\&gt\;	1

!! Line endings, empty lines
\r?\n	\r	1
\r[\r\t ]*\r	\r\r	1

!! Horizontal lines
\r\r(\*|=|\-)+\r	\r\r<P>\r<HR>\r</P>\r	1

!! Headings
^(.*)\r=+\r			<H1>\1</H1>	1
^(.*)\r-+\r			<H2>\1</H2>	1

!! Paragraphs
\r\r+([^<\r])	\r\r<P>\r\1	1
!! ^(<P>\r([^\r]+\r)+)	\1</P>\r	1
^<P>\r([^\r]+\r?)+	&</P>\r	1

!! Style typo tags.
!! 
~(.*|.*\r.*)~	<I>\1</I>	1
\*\*(.*|.*\r.*)\*\*	<B>\1</B>	1
_(.*|.*\r.*)_	<U>\1</U>	1

!! An attempt to deal with quoted text:
^<P>\r([\t ]*\&gt\;[^\r]*\r)+</P>	<BLOCKQUOTE>\r&\r</BLOCKQUOTE>	1
!! Now remove the leading " > "
^([\t ]*)\&gt\;([^\r]*)\r	\1\2\r	1

!! Match a url and mark it.  The url must begin on the first column of the
!! line.  An example is:
!! 
!! http://www.nytimes.com/2001/04/08/science/08DESI.html
!! ^.. Evolutionists Battle New Theory on Creation
!! 
!! This is not standard Setext, but a convenient invention of my own. -- dh
!!
^([^:{}"<>\r]+://[^:/]+(:[0-9]+)?/?.[^{}"<>]*)\r\^\.\. (.*)	<A HREF="\1">\3</A>	1

!! Now we'll do the standard url link.
((http|news|mailto|ftp):[^ >]*)	<A HREF=\"\1">\1</A>	1
!! And email addresses.
([-_a-zA-Z0-9.]+@[-_a-zA-Z0-9.]+)	<A HREF=\"mailto:\1"\>\1</A>	1
