… | |
… | |
25 | sub P_INDENT (){ 0 } |
25 | sub P_INDENT (){ 0 } |
26 | sub P_LEVEL (){ 1 } |
26 | sub P_LEVEL (){ 1 } |
27 | sub P_MARKUP (){ 2 } |
27 | sub P_MARKUP (){ 2 } |
28 | sub P_INDEX (){ 3 } |
28 | sub P_INDEX (){ 3 } |
29 | |
29 | |
30 | *wiki = Storable::retrieve DC::find_rcfile "docwiki.pst"; |
30 | our %wiki; |
|
|
31 | |
|
|
32 | sub load_docwiki { |
|
|
33 | *wiki = Storable::retrieve $_[0]; |
|
|
34 | } |
31 | |
35 | |
32 | sub goto_document($) { |
36 | sub goto_document($) { |
33 | $goto_document->(split /\//, $_[0]); |
37 | $goto_document->(split /\//, $_[0]); |
34 | } |
38 | } |
35 | |
39 | |
… | |
… | |
38 | |
42 | |
39 | return 1 unless @path; |
43 | return 1 unless @path; |
40 | |
44 | |
41 | my $kw = lc pop @path; |
45 | my $kw = lc pop @path; |
42 | |
46 | |
43 | $node = $node->{parent} |
47 | $node = $node->[N_PARENT] |
44 | or return 0; |
48 | or return 0; |
45 | |
49 | |
|
|
50 | #TODO: maybe get rid of lowercasing? |
46 | return scalar grep $_ eq $kw, @{ $node->{kw} }; |
51 | return scalar grep lc eq $kw, @{ $node->[N_KW] }; |
47 | } |
52 | } |
48 | |
53 | |
49 | sub find(@) { |
54 | sub find(@) { |
50 | my (@path) = @_; |
55 | my (@path) = @_; |
51 | |
56 | |
… | |
… | |
65 | my ($node) = @_; |
70 | my ($node) = @_; |
66 | |
71 | |
67 | my @path; |
72 | my @path; |
68 | |
73 | |
69 | # skip toplevel hierarchy pod/, because its not a document |
74 | # skip toplevel hierarchy pod/, because its not a document |
70 | while ($node->{parent}) { |
75 | while ($node->[N_PARENT]) { |
71 | unshift @path, $node; |
76 | unshift @path, $node; |
72 | $node = $node->{parent}; |
77 | $node = $node->[N_PARENT]; |
73 | } |
78 | } |
74 | |
79 | |
75 | @path |
80 | @path |
76 | } |
81 | } |
77 | |
82 | |
78 | sub full_path($) { |
83 | sub full_path($) { |
79 | join "/", map $_->{kw}[0], &full_path_of |
84 | join "/", map $_->[N_KW][0], &full_path_of |
80 | } |
85 | } |
81 | |
86 | |
82 | sub section_of($) { |
87 | sub section_of($) { |
83 | my ($node) = @_; |
88 | my ($node) = @_; |
84 | |
89 | |
85 | my $doc = $node->{doc}; |
90 | my $doc = $node->[N_DOC]; |
86 | my $par = $node->{par}; |
91 | my $par = $node->[N_PAR]; |
87 | my $lvl = $node->{level}; |
92 | my $lvl = $node->[N_LEVEL]; |
88 | |
93 | |
89 | my @res; |
94 | my @res; |
90 | |
95 | |
91 | do { |
96 | do { |
92 | my $p = $doc->[$par]; |
97 | my $p = $doc->[$par]; |