1 | # |
1 | # |
2 | # This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | # This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | # |
3 | # |
4 | # Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | # Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | # |
5 | # |
6 | # Deliantra is free software: you can redistribute it and/or modify it under |
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 |
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 |
8 | # Free Software Foundation, either version 3 of the License, or (at your |
9 | # option) any later version. |
9 | # option) any later version. |
10 | # |
10 | # |
11 | # This program is distributed in the hope that it will be useful, |
11 | # This program is distributed in the hope that it will be useful, |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | # GNU General Public License for more details. |
14 | # GNU General Public License for more details. |
15 | # |
15 | # |
16 | # You should have received a copy of the Affero GNU General Public License |
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 |
17 | # and the GNU General Public License along with this program. If not, see |
18 | # <http://www.gnu.org/licenses/>. |
18 | # <http://www.gnu.org/licenses/>. |
19 | # |
19 | # |
20 | # The authors can be reached via e-mail to <support@deliantra.net> |
20 | # The authors can be reached via e-mail to <support@deliantra.net> |
21 | # |
21 | # |
22 | |
22 | |
23 | package cf::pod; |
23 | package cf::pod; |
24 | |
24 | |
… | |
… | |
66 | *view_seq_T = sub { "T<$_[1]>" }; |
66 | *view_seq_T = sub { "T<$_[1]>" }; |
67 | *view_seq_G = sub { "G<$_[1]>" }; |
67 | *view_seq_G = sub { "G<$_[1]>" }; |
68 | *view_seq_zero = sub { "Z<>" }; |
68 | *view_seq_zero = sub { "Z<>" }; |
69 | *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 }; |
70 | *view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" }; |
70 | *view_seq_index = sub { push @{ $result[-1]{index} }, $_[1]; "" }; |
|
|
71 | #view_seq_entity |
71 | |
72 | |
72 | sub view_seq_text { |
73 | sub view_seq_text { |
73 | my $text = $_[1]; |
74 | my $text = $_[1]; |
74 | $text =~ s/\s+/ /g; |
75 | $text =~ s/\s+/ /g; |
75 | aspod $text |
76 | aspod $text |
… | |
… | |
81 | my $text = $link =~ s/^(.*)\|// ? $1 : $link; |
82 | my $text = $link =~ s/^(.*)\|// ? $1 : $link; |
82 | |
83 | |
83 | if ($link =~ /http:/) { |
84 | if ($link =~ /http:/) { |
84 | "U<" . (aspod $link) . ">" |
85 | "U<" . (aspod $link) . ">" |
85 | } else { |
86 | } else { |
86 | () |
87 | aspod $text |
87 | } |
88 | } |
88 | } |
89 | } |
89 | |
90 | |
90 | sub view_item { |
91 | sub view_item { |
91 | push @result, { |
92 | push @result, { |
… | |
… | |
192 | |
193 | |
193 | ############################################################################# |
194 | ############################################################################# |
194 | |
195 | |
195 | package cf::pod; |
196 | package cf::pod; |
196 | |
197 | |
197 | sub pom_as_paragraphs($) { |
198 | sub pom_as_paragraphs_ng($) { |
198 | my ($pom) = @_; |
199 | my ($pom) = @_; |
199 | |
200 | |
200 | # we suckers use global variables, unfortunately. |
201 | # we suckers use global variables, unfortunately. |
201 | my $guard = cf::lock_acquire "cf::pod::as_paragraphs"; |
|
|
202 | |
|
|
203 | local $indent = 0; |
202 | local $indent = 0; |
204 | local $level = 1; |
203 | local $level = 1; |
205 | local @result = ( { } ); |
204 | local @result = ( { } ); |
206 | |
205 | |
207 | $pom->present ("cf::pod::AsParagraphs"); |
206 | $pom->present ("cf::pod::AsParagraphs"); |
208 | |
207 | |
209 | [grep $_->{index} || exists $_->{markup}, @result] |
208 | [grep $_->{index} || exists $_->{markup}, @result] |
210 | } |
209 | } |
211 | |
210 | |
|
|
211 | sub pom_as_paragraphs($) { |
|
|
212 | my ($pom) = @_; |
|
|
213 | |
|
|
214 | my $guard = cf::lock_acquire "cf::pod::as_paragraphs"; |
|
|
215 | |
|
|
216 | $pom->pom_as_paragraphs_ng |
|
|
217 | } |
|
|
218 | |
212 | sub load_pod($) { |
219 | sub load_pod($) { |
213 | my ($path) = @_; |
220 | my ($path) = @_; |
214 | |
221 | |
215 | Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path], |
222 | Coro::Storable::thaw cf::cache "cf::pod::as_paragraphs/$path" => [$path], |
216 | 7 => sub { |
223 | 9 => sub { |
217 | my ($src) = @_; |
224 | my ($src) = @_; |
218 | |
225 | |
219 | cf::fork_call { |
226 | cf::fork_call { |
220 | my $pod = $src->[0]; |
227 | Coro::Storable::blocking_nfreeze |
221 | utf8::decode $pod; |
228 | pom_as_paragraphs_ng |
222 | Coro::Storable::blocking_nfreeze pom_as_paragraphs +(Pod::POM->new->parse_text ($pod)) |
229 | +(Pod::POM->new->parse_text ($src->[0])) |
223 | } |
230 | } |
224 | }; |
231 | }; |
225 | } |
232 | } |
226 | |
233 | |
227 | # format as cfpod-style text |
234 | # format as cfpod-style text |