--- deliantra/server/lib/cf/pod.pm 2008/08/31 09:03:31 1.13
+++ deliantra/server/lib/cf/pod.pm 2012/11/06 21:52:55 1.27
@@ -1,5 +1,29 @@
+#
+# This file is part of Deliantra, the Roguelike Realtime MMORPG.
+#
+# Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+#
+# Deliantra is free software: you can redistribute it and/or modify it under
+# the terms of the Affero 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 Affero GNU General Public License
+# and the GNU General Public License along with this program. If not, see
+# .
+#
+# The authors can be reached via e-mail to
+#
+
package cf::pod;
+use common::sense;
+
use Pod::POM;
our $indent;
@@ -8,15 +32,19 @@
package cf::pod::AsParagraphs;
-use strict;
+use common::sense;
use base "Pod::POM::View";
-sub asxml($) {
+my %E = (
+ "<" => "E",
+ ">" => "E",
+);
+
+sub aspod($) {
local $_ = $_[0];
- s//g;
- s/>/E/g;
+ s/[<>]/$E{$1}/g;
$_
}
@@ -24,7 +52,6 @@
sub flatten($) {
local $_ = $_[0];
- s/<[^>]+>//g;
s/^\s+//;
s/\s+$//;
s/\s+/ /g;
@@ -32,18 +59,20 @@
$_
}
-*view_seq_file =
-*view_seq_code =
+*view_seq_file = sub { "C<$_[1]>" };
+*view_seq_code = sub { "C<$_[1]>" };
*view_seq_bold = sub { "B<$_[1]>" };
*view_seq_italic = sub { "I<$_[1]>" };
-*view_seq_zero = sub { };
+*view_seq_T = sub { "T<$_[1]>" };
+*view_seq_G = sub { "G<$_[1]>" };
+*view_seq_zero = sub { "Z<>" };
*view_seq_space = sub { my $text = $_[1]; $text =~ s/ /\xa0/g; $text };
*view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" };
sub view_seq_text {
my $text = $_[1];
$text =~ s/\s+/ /g;
- asxml $text
+ aspod $text
}
sub view_seq_link {
@@ -52,7 +81,7 @@
my $text = $link =~ s/^(.*)\|// ? $1 : $link;
if ($link =~ /http:/) {
- "U<" . (asxml $link) . ">"
+ "U<" . (aspod $link) . ">"
} else {
()
}
@@ -184,13 +213,13 @@
my ($path) = @_;
Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path],
- 3 => sub {
+ 8 => sub {
my ($src) = @_;
cf::fork_call {
- my $pod = $src->[0];
- utf8::decode $pod;
- Coro::Storable::blocking_nfreeze pom_as_paragraphs +(Pod::POM->new->parse_text ($pod))
+ Coro::Storable::blocking_nfreeze
+ pom_as_paragraphs
+ +(Pod::POM->new->parse_text ($src->[0]))
}
};
}
@@ -205,9 +234,9 @@
if ($par->{type} =~ /^head\d+$/) {
$res .= "B<$par->{markup}>\n\n";
} elsif ($par->{type} eq "verbatim") {
- $res .= "\n$par->{markup}\n\n";
+ $res .= "$par->{markup}\n\n";
} elsif ($par->{type} eq "item") {
- $res .= "\n* I<$par->{markup}>\n\n";
+ $res .= "* I<$par->{markup}>\n\n";
} else {
$res .= "$par->{markup}\n\n";
}