--- deliantra/Deliantra-Client/DC/Pod.pm 2006/08/13 03:20:56 1.5
+++ deliantra/Deliantra-Client/DC/Pod.pm 2006/08/13 18:48:56 1.7
@@ -8,6 +8,10 @@
our %wiki;
+my $MA_BEG = "\x{fcd0}";
+my $MA_SEP = "\x{fcd1}";
+my $MA_END = "\x{fcd2}";
+
*wiki = Storable::retrieve CFPlus::find_rcfile "docwiki.pst";
sub is_prefix_of($@) {
@@ -58,18 +62,11 @@
do {
my $p = $doc->[$par];
- if (exists $p->{markup}) {
- my %para = (
+ if (length $p->{markup}) {
+ push @res, {
markup => $p->{markup},
indent => $p->{indent},
- );
-
- for (@{ $p->{widget} || [] }) {
- my ($class, @args) = @$_;
- push @{ $para{widget} }, $class->new (@args);
- }
-
- push @res, \%para;
+ };
}
} while $doc->[++$par]{level} > $lvl;
@@ -80,10 +77,74 @@
map section_of $_, &find
}
+sub thaw_section(\@\%) {
+ for (@{$_[0]}) {
+ $_->{markup} =~ s{
+ $MA_BEG
+ ([^$MA_END]+)
+ $MA_END
+ }{
+ my ($type, @arg) = split /$MA_SEP/o, $1;
+
+ $_[1]{$type}($_, @arg)
+ }ogex;
+ }
+}
+
+my %as_label = (
+ image => sub {
+ my ($par, $path) = @_;
+
+ "img"
+ },
+ link => sub {
+ my ($par, $link) = @_;
+
+ "" . (CFPlus::asxml $link) . ""
+ },
+);
+
sub as_label(@) {
- join "\n",
- map +("\xa0" x ($_->{indent} / 4)) . $_->{markup},
- @_
+ thaw_section @_, %as_label;
+
+ my $text =
+ join "\n",
+ map +("\xa0" x ($_->{indent} / 4)) . $_->{markup},
+ @_;
+
+ $text =~ s/^\s+//;
+ $text =~ s/\s+$//;
+
+ $text
+}
+
+my %as_paragraphs = (
+ image => sub {
+ my ($par, $path) = @_;
+
+ push @{ $par->{widget} }, new CFPlus::UI::Image path => $path;
+
+ "\x{FFFC}"
+ },
+ link => sub {
+ my ($par, $link) = @_;
+
+ "" . (CFPlus::asxml $link) . ""
+ },
+);
+
+sub as_paragraphs(@) {
+ thaw_section @_, %as_paragraphs;
+
+ @_
+}
+
+sub section_paragraphs(@) {
+ as_paragraphs §ion
+}
+
+sub section_label(@) {
+ as_label §ion
}
1