Skip to content

Commit

Permalink
fix index; patch courtesy by jest++
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Sep 25, 2010
1 parent a6b8fdd commit e76fe15
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/Perl6BookLatex.pm
Expand Up @@ -63,6 +63,26 @@ sub end_U {
$self->{scratch} .= '}';
}

sub start_X {
my ($self, $flags) = @_;
$self->{scratch} .= '\\index{';
++$self->{flags}{in_index};
}

sub end_X {
my ($self) = @_;
$self->{scratch} .= '}';
--$self->{flags}{in_index};
}

sub encode_index_text {
my ($self, $text) = @_;
# this is only a subset of required escaping, but should fix UsingPerl6 book
$text =~ s/"/\\"/g;
$text =~ s/!/"!/g;
$text;
}

# --------------------------------------------------------------------
sub encode_verbatim_text {
my ($self, $text) = @_;
Expand Down Expand Up @@ -149,6 +169,8 @@ sub encode_text {
$text =~ s/Perl 6/Perl~6/g;
$text =~ s/Perl 5/Perl~5/g;

$text = $self->encode_index_text($text) if $self->{flags}{in_index};

return $text;
}

Expand Down

0 comments on commit e76fe15

Please sign in to comment.