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.6 by root, Wed Apr 18 17:57:24 2007 UTC vs.
Revision 1.18 by root, Thu Sep 11 22:18:46 2008 UTC

10 10
11use strict; 11use strict;
12 12
13use base "Pod::POM::View"; 13use base "Pod::POM::View";
14 14
15my %E = (
16 "<" => "E<lt>",
17 ">" => "E<gt>",
18);
19
15sub asxml($) { 20sub aspod($) {
16 local $_ = $_[0]; 21 local $_ = $_[0];
17 22
18 s/&/&amp;/g; 23 s/[<>]/$E{$1}/g;
19 s/>/&gt;/g;
20 s/</&lt;/g;
21 24
22 $_ 25 $_
23} 26}
24 27
25sub flatten($) { 28sub flatten($) {
26 local $_ = $_[0]; 29 local $_ = $_[0];
27 30
28 s/<[^>]+>//g;
29 s/^\s+//; 31 s/^\s+//;
30 s/\s+$//; 32 s/\s+$//;
31 s/\s+/ /g; 33 s/\s+/ /g;
32 34
33 $_ 35 $_
34} 36}
35 37
36*view_seq_file = 38*view_seq_file = sub { "C<$_[1]>" };
37*view_seq_code = 39*view_seq_code = sub { "C<$_[1]>" };
38*view_seq_bold = sub { "<b>$_[1]</b>" }; 40*view_seq_bold = sub { "B<$_[1]>" };
39*view_seq_italic = sub { "<i>$_[1]</i>" }; 41*view_seq_italic = sub { "I<$_[1]>" };
40*view_seq_zero = sub { }; 42*view_seq_zero = sub { "Z<>" };
41*view_seq_space = sub { my $text = $_[1]; $text =~ s/ /\xa0/g; $text }; 43*view_seq_space = sub { my $text = $_[1]; $text =~ s/ /\xa0/g; $text };
42*view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" }; 44*view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" };
43 45
44sub view_seq_text { 46sub view_seq_text {
45 my $text = $_[1]; 47 my $text = $_[1];
46 $text =~ s/\s+/ /g; 48 $text =~ s/\s+/ /g;
47 asxml $text 49 aspod $text
48} 50}
49 51
50sub view_seq_link { 52sub view_seq_link {
51 my (undef, $link) = @_; 53 my (undef, $link) = @_;
52 54
53 my $text = $link =~ s/^(.*)\|// ? $1 : $link; 55 my $text = $link =~ s/^(.*)\|// ? $1 : $link;
54 56
55 if ($link =~ /http:/) { 57 if ($link =~ /http:/) {
56 "<u>" . (asxml $link) . "</u>" 58 "U<" . (aspod $link) . ">"
57 } else { 59 } else {
58 () 60 ()
59 } 61 }
60} 62}
61 63
76sub view_verbatim { 78sub view_verbatim {
77 push @result, { 79 push @result, {
78 type => "verbatim", 80 type => "verbatim",
79 indent => $indent * 16, 81 indent => $indent * 16,
80 level => $level, 82 level => $level,
81 markup => asxml $_[1], 83 markup => $_[1],
82 }; 84 };
83 () 85 ()
84} 86}
85 87
86sub view_textblock { 88sub view_textblock {
183 185
184sub load_pod($) { 186sub load_pod($) {
185 my ($path) = @_; 187 my ($path) = @_;
186 188
187 Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path], 189 Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path],
188 1 => sub { 190 7 => sub {
189 my ($src) = @_; 191 my ($src) = @_;
192
190 cf::fork_call { 193 cf::fork_call {
191 my $pod = $src->[0]; 194 my $pod = $src->[0];
192 utf8::decode $pod; 195 utf8::decode $pod;
193 Coro::Storable::freeze pom_as_paragraphs +(Pod::POM->new->parse_text ($pod)) 196 Coro::Storable::blocking_nfreeze pom_as_paragraphs +(Pod::POM->new->parse_text ($pod))
194 } 197 }
195 }; 198 };
196} 199}
197 200
198sub as_text($) { 201# format as cfpod-style text
202sub as_cfpod($) {
199 my ($pars) = @_; 203 my ($pars) = @_;
200 204
201 my $res; 205 my $res;
202 206
203 for my $par (@$pars) { 207 for my $par (@$pars) {
204 if ($par->{type} =~ /^head\d+$/) { 208 if ($par->{type} =~ /^head\d+$/) {
209 $res .= "B<$par->{markup}>\n\n";
210 } elsif ($par->{type} eq "verbatim") {
205 $res .= "$par->{markup}\n\n"; 211 $res .= "$par->{markup}\n\n";
206 } elsif ($par->{type} eq "verbatim") {
207 $res .= "\n$par->{markup}\n\n";
208 } elsif ($par->{type} eq "item") { 212 } elsif ($par->{type} eq "item") {
209 $res .= "\n* $par->{markup}\n\n"; 213 $res .= "* I<$par->{markup}>\n\n";
210 } else { 214 } else {
211 $res .= "$par->{markup}\n"; 215 $res .= "$par->{markup}\n\n";
212 } 216 }
213 } 217 }
214 218
215 $res =~ s/\n\n+/\n/g;
216
217 $res 219 $res
218} 220}
219 221
2201; 2221;
221 223

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines