1 # Copyright (C) 2004 Alex Schroeder <alex@emacswiki.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
19 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/setext.pl">setext.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/SeText_Extension">SeText Extension</a></p>';
21 push(@MyRules, \
&SeTextRule
);
23 # The trickiest part is the first rule. It finds titles like the following:
28 # It ignores the amount of whitespace after the title and the
29 # underlining, and it allows underlining using ==== or ----. The
30 # underlining has to be exactly as wide as the title itself. If it is
31 # too long or too short, the entire thing is not a title.
33 # If the length does not match, pos is reset and zero is returned so
34 # that the remaining rules will be tested instead.
36 my $word = '([-A-Za-z\x{0080}-\x{fffd}]+)';
39 if ($bol && ((m/\G((.+?)[ \t]*\n(-+|=+)[ \t]*\n)/gc
40 and (length($2) == length($3)))
41 or ((pos = $oldpos) and 0))) {
42 my $html = CloseHtmlEnvironments
() . ($PortraitSupportColorDiv ?
'</div>' : '');
43 if (substr($3,0,1) eq '=') {
48 $PortraitSupportColorDiv = 0;
49 return $html . AddHtmlEnvironment
('p');
50 } elsif ($bol && m/\G((> .*\n)+)/gc) {
52 return CloseHtmlEnvironments
() . $q->pre($text) . AddHtmlEnvironment
('p');
53 } elsif (m/\G\*\*($word( $word)*)\*\*/goc) {
55 } elsif (m/\G~$word~/goc) {
57 } elsif (m/\G\b_($word(_$word)*)_\b/goc) {
58 return '<em style="text-decoration: underline; font-style: normal;">'
59 . join(' ', split(/_/, $1)) . "</em>"; # don't clobber pos
60 } elsif (m/\G`_(.+)_`/gc) {