--- deliantra/Deliantra-Client/DC/Pod.pm 2008/03/30 00:25:11 1.20 +++ deliantra/Deliantra-Client/DC/Pod.pm 2010/04/03 02:58:25 1.24 @@ -1,7 +1,6 @@ package DC::Pod; -use strict; -use utf8; +use common::sense; use Storable; @@ -42,7 +41,7 @@ return 1 unless @path; - my $kw = lc pop @path; + my $kw = pop @path; $node = $node->[N_PARENT] or return 0; @@ -55,14 +54,15 @@ return unless @path; - my $kw = lc pop @path; + my $kw = pop @path; - # TODO: make sure results are unique + my %res = map +($_, $_), + grep { is_prefix_of $_, @path } + map @$_, + $kw eq "*" ? values %wiki + : $wiki{$kw} || (); - grep { is_prefix_of $_, @path } - map @$_, - $kw eq "*" ? @wiki{sort keys %wiki} - : $wiki{$kw} || () + values %res } sub full_path_of($) { @@ -70,8 +70,7 @@ my @path; - # skip toplevel hierarchy pod/, because its not a document - while ($node->[N_PARENT]) { + while ($node) { unshift @path, $node; $node = $node->[N_PARENT]; } @@ -124,7 +123,20 @@ } } +my %as_common = ( + h1 => sub { + "\n\n$_[1]\n" + }, + h2 => sub { + "\n\n$_[1]\n" + }, + h3 => sub { + "\n\n$_[1]\n" + }, +); + my %as_label = ( + %as_common, image => sub { my ($par, $path) = @_; @@ -152,6 +164,7 @@ } my %as_paragraphs = ( + %as_common, image => sub { my ($par, $path, $flags) = @_;