Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 557460c

Browse files
committed
swallow_newline(): Removed function; not really needed. Modified all call
sites. do_cmd_ignorePlatformAnnotation(), do_cmd_platform(), do_cmd_platformof(): New functions to support platform dependency information. process_all_platformofs(): New function to post-process \platformof macros using information collected during the initial pass. process_python_state(): New function. Call all post-processing functions defined in this file to avoid having to have too much knowledge of the internals for this stuff in l2hinit.perl.
1 parent 2383f6d commit 557460c

1 file changed

Lines changed: 47 additions & 16 deletions

File tree

Doc/perl/python.perl

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ sub next_optional_argument{
2323
return $param;
2424
}
2525

26-
sub swallow_newline{
27-
s/[\n]?//o;
28-
}
29-
3026

3127
# This is a fairly simple hack; it supports \let when it is used to create
3228
# (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
@@ -251,6 +247,44 @@ sub do_cmd_versionchanged{
251247
return "\nChanged in version $release.\n" . $_;
252248
}
253249

250+
#
251+
# These function handle platform dependency tracking. The first two implement
252+
# the \platform and \platformof macros, and the third is called at the end of
253+
# processing to fill in references to the platform of a module.
254+
#
255+
sub do_cmd_platform{
256+
local($_) = @_;
257+
my $platform = next_argument();
258+
$ModulePlatforms{$THIS_MODULE} = $platform;
259+
$platform = "Macintosh"
260+
if $platform eq "Mac";
261+
return "\n<p class=availability>Availability: <span"
262+
. "\n class=platform>$platform</span>.</p>\n" . $_;
263+
}
264+
265+
sub do_cmd_platformof{
266+
local($_) = @_;
267+
next_optional_argument();
268+
my $module = next_argument();
269+
return "<tex2html-platformof><$module>" . $_;
270+
}
271+
272+
$IGNORE_PLATFORM_ANNOTATION = '';
273+
sub do_cmd_ignorePlatformAnnotation{
274+
local($_) = @_;
275+
$IGNORE_PLATFORM_ANNOTATION = next_argument();
276+
return $_;
277+
}
278+
279+
sub process_all_platformofs{
280+
while (/<tex2html-platformof><([^>]+)>/) {
281+
my $match = $&;
282+
my $module = $1;
283+
s/$match/<span\n class=platform>$ModulePlatforms{$module}<\/span>/;
284+
}
285+
}
286+
287+
254288
# file and samp are at the end of this file since they screw up fontlock.
255289

256290
# index commands
@@ -338,7 +372,6 @@ sub new_link_info{
338372
sub do_cmd_index{
339373
local($_) = @_;
340374
my $str = next_argument();
341-
# swallow_newline();
342375
#
343376
my($name,$aname,$ahref) = new_link_info();
344377
add_index_entry("$str", $ahref);
@@ -398,14 +431,12 @@ sub do_cmd_ttindex{
398431
local($_) = @_;
399432
my $str = next_argument();
400433
my $entry = $str . get_indexsubitem();
401-
# swallow_newline();
402434
return make_index_entry($entry) . $_;
403435
}
404436

405437
sub my_typed_index_helper{
406438
local($word,$_) = @_;
407439
my $str = next_argument();
408-
# swallow_newline();
409440
#
410441
my($name,$aname,$ahref) = new_link_info();
411442
add_index_entry("$str $word", $ahref);
@@ -421,7 +452,6 @@ sub my_typed_index_helper{
421452
sub my_parword_index_helper{
422453
local($word,$_) = @_;
423454
my $str = next_argument();
424-
# swallow_newline();
425455
return make_index_entry("$str ($word)") . $_;
426456
}
427457

@@ -444,6 +474,7 @@ sub make_mod_index_entry{
444474
return "$aname$anchor_invisible_mark</a>";
445475
}
446476

477+
447478
$THIS_MODULE = '';
448479
$THIS_CLASS = '';
449480

@@ -460,14 +491,12 @@ sub define_module{
460491
sub my_module_index_helper{
461492
local($word, $_) = @_;
462493
my $name = next_argument();
463-
# swallow_newline();
464494
return define_module($word, $name) . $_;
465495
}
466496

467497
sub ref_module_index_helper{
468498
local($word, $_) = @_;
469499
my $str = next_argument();
470-
# swallow_newline();
471500
$word = "$word " if $word;
472501
return make_mod_index_entry("<tt>$str</tt> (${word}module)", 'REF') . $_;
473502
}
@@ -476,7 +505,6 @@ sub do_cmd_bifuncindex{
476505
local($_) = @_;
477506
my $str = next_argument();
478507
my $fname = "<tt>$str()</tt>";
479-
# swallow_newline();
480508
return make_index_entry("$fname (built-in function)") . $_;
481509
}
482510

@@ -989,25 +1017,28 @@ sub do_cmd_modulesynopsis{
9891017
local($_) = @_;
9901018
my $st = get_synopsis_table(get_chapter_id());
9911019
$st->set_synopsis($THIS_MODULE, next_argument());
992-
# swallow_newline();
9931020
return $_;
9941021
}
9951022

9961023
sub do_cmd_localmoduletable{
9971024
local($_) = @_;
9981025
my $chap = get_chapter_id();
999-
return "<tex2htmllocalmoduletable><$chap>\\tableofchildlinks[off]" . $_;
1026+
return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
10001027
}
10011028

10021029
sub process_all_localmoduletables{
1003-
while (/<tex2htmllocalmoduletable><(\d+)>/) {
1030+
while (/<tex2html-localmoduletable><(\d+)>/) {
10041031
my $match = $&;
10051032
my $chap = $1;
10061033
my $st = get_synopsis_table($chap);
10071034
my $data = $st->tohtml();
10081035
s/$match/$data/;
10091036
}
10101037
}
1038+
sub process_python_state{
1039+
process_all_localmoduletables();
1040+
process_all_platformofs();
1041+
}
10111042

10121043

10131044
#
@@ -1048,15 +1079,13 @@ sub do_cmd_seetext{
10481079

10491080
sub do_env_definitions{
10501081
local($_) = @_;
1051-
# swallow_newline();
10521082
return "<dl class=definitions>$_</dl>\n";
10531083
}
10541084

10551085
sub do_cmd_term{
10561086
local($_) = @_;
10571087
my $term = next_argument();
10581088
my($name,$aname,$ahref) = new_link_info();
1059-
# swallow_newline();
10601089
# could easily add an index entry here...
10611090
return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
10621091
}
@@ -1068,6 +1097,8 @@ sub do_cmd_term{
10681097
memberline # [] # {}
10691098
methodline # [] # {} # {}
10701099
modulesynopsis # {}
1100+
platform # {}
1101+
platformof # [] # {}
10711102
samp # {}
10721103
setindexsubitem # {}
10731104
withsubitem # {} # {}

0 commit comments

Comments
 (0)