ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf/pod.pm
(Generate patch)

Comparing deliantra/server/lib/cf/pod.pm (file contents):
Revision 1.14 by root, Sat Sep 6 20:06:10 2008 UTC vs.
Revision 1.20 by root, Wed Oct 21 00:44:39 2009 UTC

1package cf::pod; 1package cf::pod;
2
3use common::sense;
2 4
3use Pod::POM; 5use Pod::POM;
4 6
5our $indent; 7our $indent;
6our $level; 8our $level;
7our @result; 9our @result;
8 10
9package cf::pod::AsParagraphs; 11package cf::pod::AsParagraphs;
10 12
11use strict; 13use common::sense;
12 14
13use base "Pod::POM::View"; 15use base "Pod::POM::View";
16
17my %E = (
18 "<" => "E<lt>",
19 ">" => "E<gt>",
20);
14 21
15sub aspod($) { 22sub aspod($) {
16 local $_ = $_[0]; 23 local $_ = $_[0];
17 24
18 s/</E<lt>/g; 25 s/[<>]/$E{$1}/g;
19 s/>/E<gt>/g;
20 26
21 $_ 27 $_
22} 28}
23 29
24sub flatten($) { 30sub flatten($) {
29 s/\s+/ /g; 35 s/\s+/ /g;
30 36
31 $_ 37 $_
32} 38}
33 39
34*view_seq_file = sub { "B<$_[1]>" }; 40*view_seq_file = sub { "C<$_[1]>" };
35*view_seq_code = sub { "B<$_[1]>" }; 41*view_seq_code = sub { "C<$_[1]>" };
36*view_seq_bold = sub { "B<$_[1]>" }; 42*view_seq_bold = sub { "B<$_[1]>" };
37*view_seq_italic = sub { "I<$_[1]>" }; 43*view_seq_italic = sub { "I<$_[1]>" };
44*view_seq_T = sub { "T<$_[1]>" };
45*view_seq_G = sub { "G<$_[1]>" };
38*view_seq_zero = sub { "Z<>" }; 46*view_seq_zero = sub { "Z<>" };
39*view_seq_space = sub { my $text = $_[1]; $text =~ s/ /\xa0/g; $text }; 47*view_seq_space = sub { my $text = $_[1]; $text =~ s/ /\xa0/g; $text };
40*view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" }; 48*view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" };
41 49
42sub view_seq_text { 50sub view_seq_text {
49 my (undef, $link) = @_; 57 my (undef, $link) = @_;
50 58
51 my $text = $link =~ s/^(.*)\|// ? $1 : $link; 59 my $text = $link =~ s/^(.*)\|// ? $1 : $link;
52 60
53 if ($link =~ /http:/) { 61 if ($link =~ /http:/) {
54 "U<" . (asxml $link) . ">" 62 "U<" . (aspod $link) . ">"
55 } else { 63 } else {
56 () 64 ()
57 } 65 }
58} 66}
59 67
181 189
182sub load_pod($) { 190sub load_pod($) {
183 my ($path) = @_; 191 my ($path) = @_;
184 192
185 Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path], 193 Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path],
186 4 => sub { 194 7 => sub {
187 my ($src) = @_; 195 my ($src) = @_;
188 196
189 cf::fork_call { 197 cf::fork_call {
190 my $pod = $src->[0]; 198 my $pod = $src->[0];
191 utf8::decode $pod; 199 utf8::decode $pod;
202 210
203 for my $par (@$pars) { 211 for my $par (@$pars) {
204 if ($par->{type} =~ /^head\d+$/) { 212 if ($par->{type} =~ /^head\d+$/) {
205 $res .= "B<$par->{markup}>\n\n"; 213 $res .= "B<$par->{markup}>\n\n";
206 } elsif ($par->{type} eq "verbatim") { 214 } elsif ($par->{type} eq "verbatim") {
207 $res .= "\n$par->{markup}\n\n"; 215 $res .= "$par->{markup}\n\n";
208 } elsif ($par->{type} eq "item") { 216 } elsif ($par->{type} eq "item") {
209 $res .= "\n* I<$par->{markup}>\n\n"; 217 $res .= "* I<$par->{markup}>\n\n";
210 } else { 218 } else {
211 $res .= "$par->{markup}\n\n"; 219 $res .= "$par->{markup}\n\n";
212 } 220 }
213 } 221 }
214 222

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines