diff --git a/modules/bbcode.pl b/modules/bbcode.pl index 96f0fc08..a8832608 100644 --- a/modules/bbcode.pl +++ b/modules/bbcode.pl @@ -1,17 +1,16 @@ -# Copyright (C) 2007, 2008 Alex Schroeder +# Copyright (C) 2007, 2008, 2013 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 3 of the License, or -# (at your option) any later version. +# 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 3 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. +# 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, see . +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . $ModulesDescription .= '

bbcode.pl, see bbCode Extension

'; @@ -37,6 +36,10 @@ sub bbCodeRule { . qq{font-style: normal;"}); } elsif ($tag eq 's' or $tag eq 'strike') { return AddHtmlEnvironment('del'); } + elsif ($tag eq 'sub') { + return AddHtmlEnvironment('sub'); } + elsif ($tag eq 'sup') { + return AddHtmlEnvironment('sup'); } elsif ($tag eq 'color') { return AddHtmlEnvironment('em', qq{style="color: $option; } . qq{font-style: normal;"}); } @@ -96,7 +99,7 @@ sub bbCodeRule { %translate = qw{b b i i u em color em size em font span url a quote blockquote h1 h1 h2 h2 h3 h3 h4 h4 h5 h5 h6 h6 center div left div right div list ul - s del strike del highlight strong}; + s del strike del sub sub sup sup highlight strong}; # closing a block level element closes all elements if ($bbBlock eq $translate{$tag}) { /\G([ \t]*\n)*/cg; # eat whitespace after closing block level element diff --git a/modules/fractions.pl b/modules/fractions.pl new file mode 100644 index 00000000..31cb4b7a --- /dev/null +++ b/modules/fractions.pl @@ -0,0 +1,60 @@ +# Copyright (C) 2013 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 3 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, see . + +$ModulesDescription .= '

fractions.pl, see Fractions

'; + +push(@MyRules, \&FractionsRule); + +# usage: ^1/32 +sub FractionsRule { + if (/\G\^([0-9]+)\/([0-9]+)/cg) { + if ($1 == 1 and $2 == 4) { return "\¼"; } + elsif ($1 == 1 and $2 == 2) { return "\½"; } + elsif ($1 == 3 and $2 == 4) { return "\¾"; } + elsif ($1 == 1 and $2 == 7) { return "\⅐"; } + elsif ($1 == 1 and $2 == 9) { return "\⅑"; } + elsif ($1 == 1 and $2 == 10) { return "\⅒"; } + elsif ($1 == 1 and $2 == 3) { return "\⅓"; } + elsif ($1 == 2 and $2 == 3) { return "\⅔"; } + elsif ($1 == 1 and $2 == 5) { return "\⅕"; } + elsif ($1 == 2 and $2 == 5) { return "\⅖"; } + elsif ($1 == 3 and $2 == 5) { return "\⅗"; } + elsif ($1 == 4 and $2 == 5) { return "\⅘"; } + elsif ($1 == 1 and $2 == 6) { return "\⅙"; } + elsif ($1 == 5 and $2 == 6) { return "\⅚"; } + elsif ($1 == 1 and $2 == 8) { return "\⅛"; } + elsif ($1 == 3 and $2 == 8) { return "\⅜"; } + elsif ($1 == 5 and $2 == 8) { return "\⅝"; } + elsif ($1 == 7 and $2 == 8) { return "\⅞"; } + else { + my $html; + # superscripts + for my $char (split(//, $1)) { + if ($char eq '1') { $html .= "\¹"; } + elsif ($char eq '2') { $html .= "\²"; } + elsif ($char eq '3') { $html .= "\³"; } + else { $html .= "\ȇ$char;"; } + } + # fraction slash + $html .= '⁄'; + # subscripts + for my $char (split(//, $2)) { + $html .= "\Ȉ$char;"; + } + return $html; + } + } + return undef; +} diff --git a/rc2mail.pl b/rc2mail.pl index 57613560..055f8eee 100644 --- a/rc2mail.pl +++ b/rc2mail.pl @@ -148,9 +148,12 @@ sub send_file { warn "No content for $title\n" unless $item->{description}; my $link = $item->{link}; my $sub = "$root?action=subscriptions"; - print $fh qq(

Visit $title) + my $text = qq(

Visit $title) . qq( or manage your subscriptions.


) . $item->{description}; + # prevent 501 Syntax error - line too long + $text =~ s/<(p|h[1-6]|[duo]l|pre|li|form|div|blockquote|hr|table|tr)>/\r\n<$1>/gi; + print $fh $text; $fh->close; foreach my $subscriber (@subscribers) { send_mail($subscriber, $title, $fh); diff --git a/wiki.pl b/wiki.pl index f0647372..d6ef7506 100755 --- a/wiki.pl +++ b/wiki.pl @@ -1586,7 +1586,8 @@ sub GetRcLinesFor { rcclusteronly rcfilteronly match lang followup); # parsing and filtering my @result = (); - open(F, '<:encoding(UTF-8)', $file) or return (); + # using :utf8 instead of :encoding(utf-8) to avoid validation and warnings on corrupt files :( + open(F, '<:utf8', $file) or return (); while (my $line = ) { chomp($line); my ($ts, $id, $minor, $summary, $host, $username, $revision,