| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Perl6::Pod::FormattingCode::X; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | =pod | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =head1 NAME | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | Perl6::Pod::FormattingCode::X - index entry | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | An X is an ordered list of scalars indexed by number, | 
| 13 |  |  |  |  |  |  | starting with 0. A X is an unordered collection of | 
| 14 |  |  |  |  |  |  | scalar values indexed by their associated string key. | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | A X | 
| 17 |  |  |  |  |  |  | is an unordered collection of scalar values indexed by their | 
| 18 |  |  |  |  |  |  | associated string key. | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | Anything enclosed in an C<< XEE >> code is an B. The contents of the code are both formatted into the document and used as the (case-insensitive) index entry: | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | An X is an ordered list of scalars indexed by number, | 
| 26 |  |  |  |  |  |  | starting with 0. A X is an unordered collection of scalar | 
| 27 |  |  |  |  |  |  | values indexed by their associated string key. | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | You can specify an index entry in which the indexed text and the index entry are different, by separating the two with a vertical bar: | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | An X is an ordered list of scalars indexed by number, | 
| 32 |  |  |  |  |  |  | starting with 0. A X is an unordered collection of | 
| 33 |  |  |  |  |  |  | scalar values indexed by their associated string key. | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | In the two-part form, the index entry comes after the bar and is case-sensitive. | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | You can specify hierarchical index entries by separating indexing levels with commas: | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | An X is an ordered list of scalars | 
| 40 |  |  |  |  |  |  | indexed by number, starting with 0. A X | 
| 41 |  |  |  |  |  |  | is an unordered collection of scalar values indexed by their | 
| 42 |  |  |  |  |  |  | associated string key. | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | You can specify two or more entries for a single indexed text, by separating the entries with semicolons: | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | A X | 
| 47 |  |  |  |  |  |  | is an unordered collection of scalar values indexed by their | 
| 48 |  |  |  |  |  |  | associated string key. | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | The indexed text can be empty, creating a "zero-width" index entry: | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | X<|puns, deliberate>This is called the "Orcish Manoeuvre" | 
| 53 |  |  |  |  |  |  | because you "OR" the "cache". | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | Exported : | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =over | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =item *  docbook | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | information | 
| 64 |  |  |  |  |  |  | dissemination | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | L | 
| 68 |  |  |  |  |  |  | L | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | =cut | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 3 |  |  | 3 |  | 15 | use warnings; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 80 |  | 
| 73 | 3 |  |  | 3 |  | 15 | use strict; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 57 |  | 
| 74 | 3 |  |  | 3 |  | 14 | use Data::Dumper; | 
|  | 3 |  |  |  |  | 4 |  | 
|  | 3 |  |  |  |  | 122 |  | 
| 75 | 3 |  |  | 3 |  | 16 | use Perl6::Pod::FormattingCode; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 63 |  | 
| 76 | 3 |  |  | 3 |  | 18 | use base 'Perl6::Pod::FormattingCode'; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 2008 |  | 
| 77 |  |  |  |  |  |  | our $VERSION = '0.01'; | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =head2 process_index $text | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =cut | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | sub process_index { | 
| 85 | 0 |  |  | 0 | 1 |  | my ( $self, $src_string ) = @_; | 
| 86 | 0 |  |  |  |  |  | my ( $text, $index ) = split( /\s*\|\s*/, $src_string ); | 
| 87 | 0 | 0 |  |  |  |  | unless ( defined $index ) { | 
| 88 | 0 |  |  |  |  |  | $index = $text; | 
| 89 |  |  |  |  |  |  | } | 
| 90 | 0 |  |  |  |  |  | $index = [ split( /\s*;\s*/, $index ) ]; | 
| 91 | 0 | 0 |  |  |  |  | wantarray() ? ( $text, $index ) : $text; | 
| 92 |  |  |  |  |  |  | } | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | sub split_text_entry { | 
| 95 | 0 |  |  | 0 | 0 |  | my ( $self, $str ) = @_; | 
| 96 | 0 |  |  |  |  |  | my ( $text, $index ) = split( /\s*\|\s*/, $str ); | 
| 97 | 0 | 0 |  |  |  |  | unless ( defined $index ) { | 
| 98 | 0 |  |  |  |  |  | $index = $text; | 
| 99 |  |  |  |  |  |  | } | 
| 100 | 0 |  |  |  |  |  | for ( $text, $index ) { | 
| 101 | 0 |  |  |  |  |  | s/^\s+//; | 
| 102 | 0 |  |  |  |  |  | s/\s+$//; | 
| 103 |  |  |  |  |  |  | } | 
| 104 | 0 | 0 |  |  |  |  | wantarray() ? ( $text, $index ) : $text; | 
| 105 |  |  |  |  |  |  | } | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | sub on_para { | 
| 108 | 0 |  |  | 0 | 0 |  | my ( $self, $parser, $txt ) = @_; | 
| 109 | 0 |  |  |  |  |  | my $attr = $self->attrs_by_name; | 
| 110 | 0 |  |  |  |  |  | ( $attr->{index_text}, $attr->{index_entry} ) = | 
| 111 |  |  |  |  |  |  | $self->split_text_entry($txt); | 
| 112 | 0 |  |  |  |  |  | $attr->{index_text}; | 
| 113 |  |  |  |  |  |  | } | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | sub to_xhtml { | 
| 116 | 0 |  |  | 0 | 0 |  | my $self   = shift; | 
| 117 | 0 |  |  |  |  |  | my $parser = shift; | 
| 118 | 0 |  |  |  |  |  | return $self->attrs_by_name->{index_text}; | 
| 119 |  |  |  |  |  |  | } | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | sub to_docbook { | 
| 122 | 0 |  |  | 0 | 0 |  | my ($self, $to )= @_; | 
| 123 | 0 |  |  |  |  |  | $to->write($self->{text}); | 
| 124 |  |  |  |  |  |  | } | 
| 125 |  |  |  |  |  |  | sub to_docbook_ { | 
| 126 | 0 |  |  | 0 | 0 |  | my $self   = shift; | 
| 127 | 0 |  |  |  |  |  | my $parser = shift; | 
| 128 | 0 |  |  |  |  |  | my $attr   = $self->attrs_by_name; | 
| 129 | 0 |  |  |  |  |  | my ( $itext, $ientry ) = ( $attr->{index_text}, $attr->{index_entry} ); | 
| 130 | 0 |  |  |  |  |  | my @elements; | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | #determine terms and levels | 
| 133 | 0 |  |  |  |  |  | foreach my $term_line ( split( /\s*;\s*/, $ientry ) ) { | 
| 134 | 0 |  |  |  |  |  | my $el_indexterm = $parser->mk_element('indexterm'); | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | #get levels (only two ) | 
| 137 | 0 |  |  |  |  |  | my ( $l1, $l2 ) = split( /\s*,\s*/, $term_line ); | 
| 138 | 0 | 0 |  |  |  |  | $el_indexterm->add_content( $parser->mk_element('primary') | 
| 139 |  |  |  |  |  |  | ->add_content( $parser->mk_characters($l1) ) ) | 
| 140 |  |  |  |  |  |  | if $l1; | 
| 141 | 0 | 0 |  |  |  |  | $el_indexterm->add_content( $parser->mk_element('secondary') | 
| 142 |  |  |  |  |  |  | ->add_content( $parser->mk_characters($l2) ) ) | 
| 143 |  |  |  |  |  |  | if defined $l2; | 
| 144 | 0 |  |  |  |  |  | push @elements, $el_indexterm; | 
| 145 |  |  |  |  |  |  | } | 
| 146 | 0 |  |  |  |  |  | return [ $self->attrs_by_name->{index_text}, @elements ]; | 
| 147 |  |  |  |  |  |  | } | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | 1; | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | __END__ |