From 0733fedfca9672480285ee4ce06baa01eebb8cdc Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Sun, 27 Jun 2004 22:04:52 +0000 Subject: [PATCH] new --- modules/setext.pl | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 modules/setext.pl diff --git a/modules/setext.pl b/modules/setext.pl new file mode 100644 index 00000000..71b48500 --- /dev/null +++ b/modules/setext.pl @@ -0,0 +1,47 @@ +# Copyright (C) 2004 Alex Schroeder +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc. +# 59 Temple Place, Suite 330 +# Boston, MA 02111-1307 USA + +$ModulesDescription .= '

$Id: setext.pl,v 1.1 2004/06/27 22:04:52 as Exp $

'; + +push(@MyRules, \&SeTextRule); + +my $word = '([-A-Za-z\x80-\xff]+)'; +sub SeTextRule { + if (($oldpos = pos) + and ((m/\G\n(([ \t]*(.+?))[ \t]*\n(-+|=+)[ \t]*\n)/gc + and (length($2) == length($4))) + or ((pos = $oldpos) + and 0))) { + if (substr($4,0,1) eq '=') { + return CloseHtmlEnvironments() . "

$3

"; + } else { + return CloseHtmlEnvironments() . "

$3

"; + } + } elsif (m/\G\*\*($word( $word)*)\*\*/goc) { + return "$1"; + } elsif (m/\G~$word~/goc) { + return "$1"; + } elsif (m/\G\b_($word(_$word)*)_\b/goc) { + return "" . join(' ', split(/_/, $1)) . ""; # don't clobber pos + } elsif (m/\G((\n> .*)+\n)/gc) { + return "
$1
"; + } elsif (m/\G`_(.+)_`/gc) { + return $1; + } + return undef; +}