'; $_[0]->emit() }
sub start_headrow { $_[0]{'scratch'} .= "\n"; $_[0]{'headrow'} = 1 }
sub start_bodyrows {
my ($self, $flags) = @_;
$self->{'scratch'} .= "\n" if ($self->{'headrow'});
$self->{'headrow'} = 0;
$self->{'scratch'} .= "\n";
}
sub start_row {$_[0]{'scratch'} .= "\n" }
sub end_row { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub start_cell {
$_[0]{'scratch'} .= '';
}
sub end_cell {
my $self = shift;
$self->{'scratch'} .= '';
$self->emit();
}
sub start_Document {
my ($self) = @_;
}
sub end_Document {
my ($self) = @_;
$self->{'scratch'} .= $self->close_sections(-1);
$self->emit();
}
# Handling entity tags
sub start_L { $_[0]{'scratch'} .= '' }
sub start_A { my $self = shift @_; $self->start_L(@_) }
sub end_A { my $self = shift @_; $self->end_L(@_) }
sub start_B { $_[0]{'scratch'} .= '' }
sub end_B { $_[0]{'scratch'} .= '' }
sub start_C { $_[0]{'scratch'} .= '' }
sub end_C { $_[0]{'scratch'} .= '' }
sub start_E { $_[0]{'scratch'} .= '&' }
sub end_E { $_[0]{'scratch'} .= ';' }
sub start_F {
my ($self) = @_;
if ($self->{'in_figure'}) {
$self->{'in_filename'} = 1;
} else {
$self->{'scratch'} .= '';
}
}
sub end_F {
my ($self) = @_;
if ($self->{'in_figure'}) {
$self->{'in_filename'} = 0;
} else {
$self->{'scratch'} .= '';
}
}
sub start_G { $_[0]{'scratch'} .= '' }
sub end_G { $_[0]{'scratch'} .= '' }
sub start_H { $_[0]{'scratch'} .= '' }
sub end_H { $_[0]{'scratch'} .= '' }
sub start_I { $_[0]{'scratch'} .= '' }
sub end_I { $_[0]{'scratch'} .= '' }
sub start_N {
my ($self) = @_;
my $id = $self->chapter_id() . '-FNOTE-'. $self->footnote_next();
$self->{'scratch'} .= '';
}
sub end_N {
my ($self) = @_;
$self->{'scratch'} .= '';
}
sub footnote_next { ++$_[0]{'footnote_count'} }
sub start_M { $_[0]{'scratch'} .= '' }
sub end_M { $_[0]{'scratch'} .= '' }
sub start_R { $_[0]{'scratch'} .= '' }
sub end_R { $_[0]{'scratch'} .= '' }
sub start_U { $_[0]{'scratch'} .= '' }
sub start_X {
my ($self) = @_;
my $id = $self->chapter_id() . '-IDX-' . $self->index_next();
$self->{'scratch'} .= '';
}
sub end_X { $_[0]{'scratch'} .= '' }
sub index_next {
my ($self) = @_;
my $idx = ++$self->{'index_count'};
return sprintf("%04d", $idx);
}
sub start_Z { $_[0]{'scratch'} .= '' }
sub emit {
my($self) = @_;
if ($self->{'scratch'}) {
my $out = $self->{'scratch'} . "\n";
print {$self->{'output_fh'}} $out;
$self->{'scratch'} = '';
}
return;
}
sub book_id { $_[0]{'book_id'} = $_[1] }
sub index_count {
$_[0]{'index_count'} = $_[1] if ($_[1]);
return $_[0]{'index_count'};
}
sub chapter_num {
my ($self, $number) = @_;
$self->{'chapter_num'} = $number;
$self->{'sectionnum'}[0] = $number;
}
sub chapter_type {
my ($self, $type) = @_;
$self->{'chapter_type'} = $type;
$self->{'sectionname'}[0] = $type;
}
sub chapter_id {
my ($self) = @_;
unless ($self->{'chapter_id'}) {
my $id;
$id = $self->{'book_id'} . '-' if ($self->{'book_id'});
if ($self->{'chapter_type'} eq 'preface') {
$id .= 'PREFACE';
$id .= '-' . $self->{'chapter_num'} if ($self->{'chapter_num'});
} elsif ($self->{'chapter_type'} eq 'colophon') {
$id .= 'COLOPHON';
} elsif ($self->{'chapter_type'} eq 'appendix') {
$id .= 'APP-' . $self->{'chapter_num'};
} elsif ($self->{'chapter_type'} eq 'chapter') {
$id .= 'CHP-' . $self->{'chapter_num'};
}
$self->{'chapter_id'} = $id;
}
return $self->{'chapter_id'};
}
# bypass built-in E<> handling to preserve entity encoding
sub _treat_Es {}
1;
__END__
=head1 NAME
Pod::PseudoPod::DocBook -- format PseudoPod as DocBook
=head1 SYNOPSIS
use Pod::PseudoPod::DocBook;
my $parser = Pod::PseudoPod::DocBook->new();
...
$parser->parse_file('path/to/file.pod');
Before sending in your manuscript, check that the formatter produced a
well-formed DocBook file with I:
$ xmllint --noout --valid book.xml
=head1 DESCRIPTION
This class is a formatter that takes PseudoPod and renders it as
DocBook 4.4.
This is a subclass of L and inherits all its methods.
=head1 SEE ALSO
L, L
=head1 COPYRIGHT
Copyright (c) 2003-2006 Allison Randal. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. The full text of the license
can be found in the LICENSE file included with this module.
This library is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
=head1 AUTHOR
Allison Randal
=cut