@@ -33,39 +33,46 @@ $VERSION = eval $VERSION;
3333our $labelCnt = 0; # label counter to see to it that when e.g. twice a =head1 NAME in a file it is still an unique label
3434our $sectionLabel = ' x' ;
3535
36+ sub convertText
37+ {
38+ # based on e.g. a file name try to create a doxygen label prefix
39+ my $label = shift ;
40+ $label =~ s / _/ __/ g ;
41+ $label =~ s / :/ _1/ g ;
42+ $label =~ s /\/ / _2/ g ;
43+ $label =~ s / </ _3/ g ;
44+ $label =~ s / >/ _4/ g ;
45+ $label =~ s /\* / _5/ g ;
46+ $label =~ s / &/ _6/ g ;
47+ $label =~ s /\| / _7/ g ;
48+ $label =~ s /\. / _8/ g ;
49+ $label =~ s / !/ _9/ g ;
50+ $label =~ s / ,/ _00/ g ;
51+ $label =~ s / / _01/ g ;
52+ $label =~ s / {/ _02/ g ;
53+ $label =~ s / }/ _03/ g ;
54+ $label =~ s /\? / _04/ g ;
55+ $label =~ s /\^ / _05/ g ;
56+ $label =~ s / %/ _06/ g ;
57+ $label =~ s /\( / _07/ g ;
58+ $label =~ s /\) / _08/ g ;
59+ $label =~ s /\+ / _09/ g ;
60+ $label =~ s / =/ _0A/ g ;
61+ $label =~ s /\$ / _0B/ g ;
62+ $label =~ s /\\ / _0C/ g ;
63+ $label =~ s / @/ _0D/ g ;
64+ $label =~ s / -/ _0E/ g ;
65+ $label =~ s / [^a-z0-9A-Z]/ _/ g ;
66+ print (" New $label \n " );
67+
68+ $label = " x$label " ; # label should not start with a underscore
69+ }
3670sub setAsLabel
3771{
3872 # based on e.g. a file name try to create a doxygen label prefix
3973 my $self = shift ;
40- $sectionLabel = shift ;
41- $sectionLabel =~ s / _/ __/ g ;
42- $sectionLabel =~ s / :/ _1/ g ;
43- $sectionLabel =~ s /\/ / _2/ g ;
44- $sectionLabel =~ s / </ _3/ g ;
45- $sectionLabel =~ s / >/ _4/ g ;
46- $sectionLabel =~ s /\* / _5/ g ;
47- $sectionLabel =~ s / &/ _6/ g ;
48- $sectionLabel =~ s /\| / _7/ g ;
49- $sectionLabel =~ s /\. / _8/ g ;
50- $sectionLabel =~ s / !/ _9/ g ;
51- $sectionLabel =~ s / ,/ _00/ g ;
52- $sectionLabel =~ s / / _01/ g ;
53- $sectionLabel =~ s / {/ _02/ g ;
54- $sectionLabel =~ s / }/ _03/ g ;
55- $sectionLabel =~ s /\? / _04/ g ;
56- $sectionLabel =~ s /\^ / _05/ g ;
57- $sectionLabel =~ s / %/ _06/ g ;
58- $sectionLabel =~ s /\( / _07/ g ;
59- $sectionLabel =~ s /\) / _08/ g ;
60- $sectionLabel =~ s /\+ / _09/ g ;
61- $sectionLabel =~ s / =/ _0A/ g ;
62- $sectionLabel =~ s /\$ / _0B/ g ;
63- $sectionLabel =~ s /\\ / _0C/ g ;
64- $sectionLabel =~ s / @/ _0D/ g ;
65- $sectionLabel =~ s / -/ _0E/ g ;
66- $sectionLabel =~ s / [^a-z0-9A-Z]/ _/ g ;
67-
68- $sectionLabel = " x$sectionLabel " ; # label should not start with a underscore
74+ my $tmpLabel = shift ;
75+ $sectionLabel = convertText($tmpLabel );
6976}
7077
7178sub view_pod
@@ -78,8 +85,7 @@ sub view_head1
7885{
7986 my ($self , $head1 ) = @_ ;
8087 my $title = $head1 -> title-> present($self );
81- my $name = $title ;
82- $name =~ s /\s / _/ g ;
88+ my $name = convertText($title );
8389 $labelCnt += 1;
8490 return " \n\@ section $sectionLabel$name$labelCnt $title \n " . $head1 -> content-> present($self );
8591}
@@ -88,8 +94,7 @@ sub view_head2
8894{
8995 my ($self , $head2 ) = @_ ;
9096 my $title = $head2 -> title-> present($self );
91- my $name = $title ;
92- $name =~ s /\s / _/ g ;
97+ my $name = convertText($title );
9398 $labelCnt += 1;
9499 return " \n\@ subsection $sectionLabel$name$labelCnt $title \n " . $head2 -> content-> present($self );
95100}
@@ -98,8 +103,7 @@ sub view_head3
98103{
99104 my ($self , $head3 ) = @_ ;
100105 my $title = $head3 -> title-> present($self );
101- my $name = $title ;
102- $name =~ s /\s / _/ g ;
106+ my $name = convertText($title );
103107 $labelCnt += 1;
104108 return " \n\@ subsubsection $sectionLabel$name$labelCnt $title \n " . $head3 -> content-> present($self );
105109}
@@ -108,8 +112,7 @@ sub view_head4
108112{
109113 my ($self , $head4 ) = @_ ;
110114 my $title = $head4 -> title-> present($self );
111- my $name = $title ;
112- $name =~ s /\s / _/ g ;
115+ my $name = convertText($title );
113116 $labelCnt += 1;
114117 return " \n\@ paragraph $sectionLabel$name$labelCnt $title \n " . $head4 -> content-> present($self );
115118}
0 commit comments