|
|
1 | # |
|
|
2 | # This file is part of Deliantra, the Roguelike Realtime MMORPG. |
|
|
3 | # |
|
|
4 | # Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
|
|
5 | # |
|
|
6 | # Deliantra is free software: you can redistribute it and/or modify it under |
|
|
7 | # the terms of the Affero GNU General Public License as published by the |
|
|
8 | # Free Software Foundation, either version 3 of the License, or (at your |
|
|
9 | # option) any later version. |
|
|
10 | # |
|
|
11 | # This program is distributed in the hope that it will be useful, |
|
|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
14 | # GNU General Public License for more details. |
|
|
15 | # |
|
|
16 | # You should have received a copy of the Affero GNU General Public License |
|
|
17 | # and the GNU General Public License along with this program. If not, see |
|
|
18 | # <http://www.gnu.org/licenses/>. |
|
|
19 | # |
|
|
20 | # The authors can be reached via e-mail to <support@deliantra.net> |
|
|
21 | # |
|
|
22 | |
1 | package cf::pod; |
23 | package cf::pod; |
|
|
24 | |
|
|
25 | use common::sense; |
2 | |
26 | |
3 | use Pod::POM; |
27 | use Pod::POM; |
4 | |
28 | |
5 | our $indent; |
29 | our $indent; |
6 | our $level; |
30 | our $level; |
7 | our @result; |
31 | our @result; |
8 | |
32 | |
9 | package cf::pod::AsParagraphs; |
33 | package cf::pod::AsParagraphs; |
10 | |
34 | |
11 | use strict; |
35 | use common::sense; |
12 | |
36 | |
13 | use base "Pod::POM::View"; |
37 | use base "Pod::POM::View"; |
14 | |
38 | |
15 | my %E = ( |
39 | my %E = ( |
16 | "<" => "E<lt>", |
40 | "<" => "E<lt>", |
… | |
… | |
33 | s/\s+/ /g; |
57 | s/\s+/ /g; |
34 | |
58 | |
35 | $_ |
59 | $_ |
36 | } |
60 | } |
37 | |
61 | |
38 | *view_seq_file = sub { "B<$_[1]>" }; |
62 | *view_seq_file = sub { "C<$_[1]>" }; |
39 | *view_seq_code = sub { "B<$_[1]>" }; |
63 | *view_seq_code = sub { "C<$_[1]>" }; |
40 | *view_seq_bold = sub { "B<$_[1]>" }; |
64 | *view_seq_bold = sub { "B<$_[1]>" }; |
41 | *view_seq_italic = sub { "I<$_[1]>" }; |
65 | *view_seq_italic = sub { "I<$_[1]>" }; |
|
|
66 | *view_seq_T = sub { "T<$_[1]>" }; |
|
|
67 | *view_seq_G = sub { "G<$_[1]>" }; |
42 | *view_seq_zero = sub { "Z<>" }; |
68 | *view_seq_zero = sub { "Z<>" }; |
43 | *view_seq_space = sub { my $text = $_[1]; $text =~ s/ /\xa0/g; $text }; |
69 | *view_seq_space = sub { my $text = $_[1]; $text =~ s/ /\xa0/g; $text }; |
44 | *view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" }; |
70 | *view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" }; |
45 | |
71 | |
46 | sub view_seq_text { |
72 | sub view_seq_text { |
… | |
… | |
185 | |
211 | |
186 | sub load_pod($) { |
212 | sub load_pod($) { |
187 | my ($path) = @_; |
213 | my ($path) = @_; |
188 | |
214 | |
189 | Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path], |
215 | Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path], |
190 | 5 => sub { |
216 | 8 => sub { |
191 | my ($src) = @_; |
217 | my ($src) = @_; |
192 | |
218 | |
193 | cf::fork_call { |
219 | cf::fork_call { |
194 | my $pod = $src->[0]; |
220 | Coro::Storable::blocking_nfreeze |
195 | utf8::decode $pod; |
221 | pom_as_paragraphs |
196 | Coro::Storable::blocking_nfreeze pom_as_paragraphs +(Pod::POM->new->parse_text ($pod)) |
222 | +(Pod::POM->new->parse_text ($src->[0])) |
197 | } |
223 | } |
198 | }; |
224 | }; |
199 | } |
225 | } |
200 | |
226 | |
201 | # format as cfpod-style text |
227 | # format as cfpod-style text |
… | |
… | |
206 | |
232 | |
207 | for my $par (@$pars) { |
233 | for my $par (@$pars) { |
208 | if ($par->{type} =~ /^head\d+$/) { |
234 | if ($par->{type} =~ /^head\d+$/) { |
209 | $res .= "B<$par->{markup}>\n\n"; |
235 | $res .= "B<$par->{markup}>\n\n"; |
210 | } elsif ($par->{type} eq "verbatim") { |
236 | } elsif ($par->{type} eq "verbatim") { |
211 | $res .= "\n$par->{markup}\n\n"; |
237 | $res .= "$par->{markup}\n\n"; |
212 | } elsif ($par->{type} eq "item") { |
238 | } elsif ($par->{type} eq "item") { |
213 | $res .= "\n* I<$par->{markup}>\n\n"; |
239 | $res .= "* I<$par->{markup}>\n\n"; |
214 | } else { |
240 | } else { |
215 | $res .= "$par->{markup}\n\n"; |
241 | $res .= "$par->{markup}\n\n"; |
216 | } |
242 | } |
217 | } |
243 | } |
218 | |
244 | |