@@ -268,7 +268,7 @@ sub include {
268
268
sub got_para {
269
269
local ($_ ) = @_ ;
270
270
my $pflags = " " , $i , $w , $l , $t ;
271
- my @ para = () ;
271
+ my $ para = [] ;
272
272
273
273
return if !/\S/;
274
274
@@ -294,7 +294,7 @@ sub got_para {
294
294
$l =~ s /\\\{ / \{ / g ;
295
295
$l =~ s /\\\} / }/ g ;
296
296
$l =~ s /\\\\ / \\ / g ;
297
- push @para , $l ;
297
+ push @$ para , $l ;
298
298
}
299
299
$_ = ' ' ; # suppress word-by-word code
300
300
} elsif (/ ^\\ C/ ) {
@@ -308,7 +308,7 @@ sub got_para {
308
308
die " badly formatted chapter heading: $_ \n " if !/^\\C\{([^\}]*)\}\s * (.* )$/ ;
309
309
$refs {$1 } = "chapter $cnum ";
310
310
$node = "Chapter $cnum ";
311
- &add_item($node , 1);
311
+ &add_item($node , 1, $para );
312
312
$xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
313
313
$xrefs {$1 } = $xref ;
314
314
$_ = $2 ;
@@ -325,7 +325,7 @@ sub got_para {
325
325
die "badly formatted appendix heading: $_ \n " if !/^\\ A\{ ([^\} ]* )}\s * (.* )$/ ;
326
326
$refs {$1 } = "appendix $cnum ";
327
327
$node = "Appendix $cnum ";
328
- &add_item($node , 1);
328
+ &add_item($node , 1, $para );
329
329
$xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
330
330
$xrefs {$1 } = $xref ;
331
331
$_ = $2 ;
@@ -339,7 +339,7 @@ sub got_para {
339
339
die "badly formatted heading: $_ \n " if !/^\\ [HP]\{ ([^\} ]* )\}\s * (.* )$/ ;
340
340
$refs {$1 } = "section $cnum .$hnum ";
341
341
$node = "Section $cnum .$hnum ";
342
- &add_item($node , 2);
342
+ &add_item($node , 2, $para );
343
343
$xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
344
344
$xrefs {$1 } = $xref ;
345
345
$_ = $2 ;
@@ -352,7 +352,7 @@ sub got_para {
352
352
die "badly formatted subheading: $_ \n " if !/^\\ S\{ ([^\} ]* )\}\s * (.* )$/ ;
353
353
$refs {$1 } = "section $cnum .$hnum .$snum ";
354
354
$node = "Section $cnum .$hnum .$snum ";
355
- &add_item($node , 3);
355
+ &add_item($node , 3, $para );
356
356
$xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
357
357
$xrefs {$1 } = $xref ;
358
358
$_ = $2 ;
@@ -389,11 +389,11 @@ sub got_para {
389
389
$pflags = " norm" ;
390
390
}
391
391
392
- # The word-by-word code: unless @para is already defined (which it
392
+ # The word-by-word code: unless @$ para is already defined (which it
393
393
# will be in the case of a code paragraph), split the paragraph up
394
- # into words and push each on @para.
394
+ # into words and push each on @$ para.
395
395
#
396
- # Each thing pushed on @para should have a two-character type
396
+ # Each thing pushed on @$ para should have a two-character type
397
397
# code followed by the text.
398
398
#
399
399
# Type codes are:
@@ -416,7 +416,7 @@ sub got_para {
416
416
# index-items arrays
417
417
# "sp" for space
418
418
while (/ \S / ) {
419
- s / ^\s *// , push @para , " sp" if / ^\s / ;
419
+ s / ^\s *// , push @$ para , " sp" if / ^\s / ;
420
420
$indexing = $qindex = 0;
421
421
if (/ ^(\\ [iI])?\\ c/ ) {
422
422
$qindex = 1 if $1 eq " \\ I" ;
@@ -429,8 +429,8 @@ sub got_para {
429
429
$w =~ s /\\\} / \} / g ;
430
430
$w =~ s /\\ -/ -/ g ;
431
431
$w =~ s /\\\\ / \\ / g ;
432
- push (@para , addidx($node , $w , " c $w " )) if ($indexing );
433
- push (@para , " c $w " ) if (!$qindex );
432
+ push (@$ para , addidx($node , $w , " c $w " )) if ($indexing );
433
+ push (@$ para , " c $w " ) if (!$qindex );
434
434
} elsif (/ ^\\ [iIe]/ ) {
435
435
/ ^(\\ [iI])?(\\ e)?/ ;
436
436
$emph = 0;
@@ -456,7 +456,7 @@ sub got_para {
456
456
if ($indexing ) {
457
457
$w =~ tr / A-Z/ a-z/ ;
458
458
pop @ientry ; # remove final space
459
- push (@para , addidx($node , $w , @ientry ));
459
+ push (@$ para , addidx($node , $w , @ientry ));
460
460
}
461
461
if (!$qindex ) {
462
462
pop @pentry ; # remove final space
@@ -465,15 +465,15 @@ sub got_para {
465
465
} elsif ($emph ) {
466
466
substr ($pentry [-1],0,2) = ' ee' ;
467
467
}
468
- push (@para , @pentry );
468
+ push (@$ para , @pentry );
469
469
}
470
470
} elsif (/ ^\\ [kK]/ ) {
471
471
$t = " k " ;
472
472
$t = " kK" if / ^\\ K/ ;
473
473
s / ^\\ [kK]// ;
474
474
die " badly formatted \\ k: \\ k$_ \n " if !/\{([^\}]*)\}(.*)$/ ;
475
475
$_ = $2 ;
476
- push @para ," $t$1 " ;
476
+ push @$ para ," $t$1 " ;
477
477
} elsif (/ ^\\ W/ ) {
478
478
s / ^\\ W// ;
479
479
die " badly formatted \\ W: \\ W$_ \n "
@@ -488,8 +488,8 @@ sub got_para {
488
488
$w =~ s /\\\} / \} / g ;
489
489
$w =~ s /\\ -/ -/ g ;
490
490
$w =~ s /\\\\ / \\ / g ;
491
- push (@para , addidx($node , $w , " c $w " )) if $indexing ;
492
- push (@para , " $t <$l >$w " );
491
+ push (@$ para , addidx($node , $w , " c $w " )) if $indexing ;
492
+ push (@$ para , " $t <$l >$w " );
493
493
} else {
494
494
die " what the hell? $_ \n " if !/^(([^\s \\\-]|\\[\\{}\-])*-?)(.*)$/ ;
495
495
die " painful death! $_ \n " if !length $1 ;
@@ -500,18 +500,18 @@ sub got_para {
500
500
$w =~ s /\\ -/ -/ g ;
501
501
$w =~ s /\\\\ / \\ / g ;
502
502
if ($w eq ' --' ) {
503
- push @para , ' dm' ;
503
+ push @$ para , ' dm' ;
504
504
} elsif ($w eq ' -' ) {
505
- push @para , ' da' ;
505
+ push @$ para , ' da' ;
506
506
} else {
507
- push @para ," n $w " ;
507
+ push @$ para ," n $w " ;
508
508
}
509
509
}
510
510
}
511
511
if ($irewrite ne undef ) {
512
- addidx(undef , $irewrite , @para );
512
+ addidx(undef , $irewrite , @$ para );
513
513
} else {
514
- push @pnames , [ @ para] ;
514
+ push @pnames , $ para ;
515
515
push @pflags , $pflags ;
516
516
}
517
517
}
@@ -807,12 +807,8 @@ sub write_html {
807
807
# Use the preceding filename plus a marker point.
808
808
$link = $fname . " #$xrefnodes {$node }" ;
809
809
}
810
- $title = ' ' ;
811
810
$pname = $tstruct_pname {$node };
812
- foreach $i (@$pname ) {
813
- $ww = &word_html($i );
814
- $title .= $ww unless $ww eq " \001 " ;
815
- }
811
+ $title = plist_to_html(@$pname );
816
812
print " <li class=\" toc${level} \" >\n " ;
817
813
print " <span class=\" node\" >$node : </span><a href=\" $link \" >$title </a>\n " ;
818
814
}
@@ -1066,7 +1062,19 @@ sub html_index {
1066
1062
print " </ul>\n " ;
1067
1063
}
1068
1064
1069
- sub word_html {
1065
+ sub plist_to_html (@) {
1066
+ my $ws = ' ' ;
1067
+
1068
+ foreach my $w (@_ ) {
1069
+ my $ww = word_html($w );
1070
+ next if ($ww eq " \001 " );
1071
+ $ws .= $ww ;
1072
+ }
1073
+
1074
+ return $ws ;
1075
+ }
1076
+
1077
+ sub word_html ($) {
1070
1078
my ($w ) = @_ ;
1071
1079
my $wtype , $wmajt , $pfx , $sfx ;
1072
1080
@@ -1119,11 +1127,11 @@ sub word_html {
1119
1127
}
1120
1128
1121
1129
# Make tree structures. $tstruct_* is top-level and global.
1122
- sub add_item {
1123
- my ($item , $level ) = @_ ;
1130
+ sub add_item ($$$) {
1131
+ my ($item , $level , $para ) = @_ ;
1124
1132
my $i ;
1125
1133
1126
- $tstruct_pname {$item } = $pname ;
1134
+ $tstruct_pname {$item } = $para ;
1127
1135
$tstruct_next {$tstruct_previtem } = $item ;
1128
1136
$tstruct_prev {$item } = $tstruct_previtem ;
1129
1137
$tstruct_level {$item } = $level ;
0 commit comments