line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl6::Pod::To::DocBook; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Perl6::Pod::To::DocBook - DocBook formater |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $p = new Perl6::Pod::To::DocBook:: |
10
|
|
|
|
|
|
|
header => 0, doctype => 'chapter'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Process pod to docbook |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Sample: |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=begin pod |
20
|
|
|
|
|
|
|
=NAME Test chapter |
21
|
|
|
|
|
|
|
=para This is a test para |
22
|
|
|
|
|
|
|
=end pod |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Run converter: |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
pod6docbook test.pod > test.xml |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Result xml: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Test chapter |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This is a test para |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
53
|
|
42
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
59
|
|
43
|
2
|
|
|
2
|
|
10
|
use Perl6::Pod::To; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
42
|
|
44
|
2
|
|
|
2
|
|
10
|
use base 'Perl6::Pod::To'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
135
|
|
45
|
2
|
|
|
2
|
|
12
|
use Perl6::Pod::Utl; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
850
|
|
46
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
49
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
50
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
51
|
|
|
|
|
|
|
# $self->{doctype} ||= 'chapter'; |
52
|
0
|
|
|
|
|
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
sub block_NAME { |
55
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
56
|
0
|
|
|
|
|
|
my $el = shift; |
57
|
0
|
|
|
|
|
|
my $w = $self->w; |
58
|
0
|
|
|
|
|
|
$w->raw(''); |
59
|
0
|
|
|
|
|
|
$el->{content} = Perl6::Pod::Utl::parse_para($el->childs->[0]->{content}->[0]); |
60
|
0
|
|
|
|
|
|
$self->visit_childs($el); |
61
|
0
|
|
|
|
|
|
$w->raw(''); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub start_write { |
65
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
66
|
0
|
|
|
|
|
|
my $w = $self->writer; |
67
|
0
|
0
|
|
|
|
|
if ( $self->{header} ) { |
68
|
0
|
|
|
|
|
|
$w->say( |
69
|
|
|
|
|
|
|
q@@); |
70
|
|
|
|
|
|
|
} |
71
|
0
|
0
|
|
|
|
|
$self->w->raw_print( '<' . $self->{doctype} . '>' ) if $self->{doctype}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub switch_head_level { |
75
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
76
|
0
|
|
|
|
|
|
my $level = shift; |
77
|
0
|
|
|
|
|
|
my $no_start_next_flag = shift; |
78
|
0
|
|
|
|
|
|
my $w = $self->w; |
79
|
0
|
|
|
|
|
|
my $prev = $self->SUPER::switch_head_level($level); |
80
|
0
|
0
|
0
|
|
|
|
if ($level && $level == $prev ) { |
|
|
0
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$w->raw(' |
82
|
|
|
|
|
|
|
} elsif ( $prev < $level ) { |
83
|
0
|
|
|
|
|
|
$w->raw('') for ( 1..$level-$prev); |
84
|
|
|
|
|
|
|
} else #$prev > $level |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
|
|
|
my $count_to_close = $level * 1 + $prev-$level; |
87
|
0
|
|
|
|
|
|
$w->raw('') for ( 1..$count_to_close); |
88
|
0
|
0
|
0
|
|
|
|
$w->raw('') unless $no_start_next_flag or !$level; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub end_write { |
94
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
95
|
0
|
|
|
|
|
|
$self->switch_head_level(0,'no_start_next'); |
96
|
0
|
0
|
|
|
|
|
$self->w->raw_print( '' . $self->{doctype} . '>' ) if $self->{doctype}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
__END__ |