📄 python.perl
字号:
sub do_cmd_linev{
local($_) = @_;
my $aligns = next_optional_argument();
my $c1 = next_argument();
my $c2 = next_argument();
my $c3 = next_argument();
my $c4 = next_argument();
my $c5 = next_argument();
s/[\s\n]+//;
my($sfont,$efont) = get_table_col1_fonts();
$c5 = ' ' if ($c5 eq '');
my($c1align,$c2align,$c3align,$c4align,$c5align) = split('\|', $aligns);
my $padding = '';
if ($c1align =~ /align="right"/ || $c1 eq '') {
$padding = ' ';
}
return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
. " $c2align$c2</td>\n"
. " $c3align$c3</td>\n"
. " $c4align$c4</td>\n"
. " $c5align$c5</td>"
. $_;
}
# These can be used to control the title page appearance;
# they need a little bit of documentation.
#
# If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the
# $ICONSERVER directory, or include path information (other than "./"). The
# default image type will be assumed if an extension is not provided.
#
# If specified, the "title page" will contain two colums: one containing the
# title/author/etc., and the other containing the graphic. Use the other
# four variables listed here to control specific details of the layout; all
# are optional.
#
# $TITLE_PAGE_GRAPHIC = "my-company-logo";
# $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%";
# $TITLE_PAGE_GRAPHIC_WIDTH = 150;
# $TITLE_PAGE_GRAPHIC_HEIGHT = 150;
# $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0;
sub make_my_titlepage() {
my $the_title = "";
if ($t_title) {
$the_title .= "\n<h1>$t_title</h1>";
}
else {
write_warnings("\nThis document has no title.");
}
if ($t_author) {
if ($t_authorURL) {
my $href = translate_commands($t_authorURL);
$href = make_named_href('author', $href,
"<b><font size=\"+2\">$t_author"
. '</font></b>');
$the_title .= "\n<p>$href</p>";
}
else {
$the_title .= ("\n<p><b><font size=\"+2\">$t_author"
. '</font></b></p>');
}
}
else {
write_warnings("\nThere is no author for this document.");
}
if ($t_institute) {
$the_title .= "\n<p>$t_institute</p>";
}
if ($DEVELOPER_ADDRESS) {
$the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";
}
if ($t_affil) {
$the_title .= "\n<p><i>$t_affil</i></p>";
}
if ($t_date) {
$the_title .= "\n<p>";
if ($PACKAGE_VERSION) {
$the_title .= ('<strong>Release '
. "$PACKAGE_VERSION$RELEASE_INFO</strong><br>\n");
}
$the_title .= "<strong>$t_date</strong></p>"
}
if ($t_address) {
$the_title .= "\n<p>$t_address</p>";
}
else {
$the_title .= "\n<p>";
}
if ($t_email) {
$the_title .= "\n<p>$t_email</p>";
}
return $the_title;
}
sub make_my_titlegraphic() {
my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC);
my $graphic = "<td class=\"titlegraphic\"";
$graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\""
if ($TITLE_PAGE_GRAPHIC_COLWIDTH);
$graphic .= "><img";
$graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\""
if ($TITLE_PAGE_GRAPHIC_WIDTH);
$graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\""
if ($TITLE_PAGE_GRAPHIC_HEIGHT);
$graphic .= "\n src=\"$filename\"></td>\n";
return $graphic;
}
sub do_cmd_maketitle {
local($_) = @_;
my $the_title = "\n<div class=\"titlepage\">";
if ($TITLE_PAGE_GRAPHIC) {
if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) {
$the_title .= ("\n<table border=\"0\" width=\"100%\">"
. "<tr align=\"right\">\n<td>"
. make_my_titlepage()
. "</td>\n"
. make_my_titlegraphic()
. "</tr>\n</table>");
}
else {
$the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n"
. make_my_titlegraphic()
. "<td>"
. make_my_titlepage()
. "</td></tr>\n</table>");
}
}
else {
$the_title .= ("\n<center>"
. make_my_titlepage()
. "\n</center>");
}
$the_title .= "\n</div>";
return $the_title . $_;
$the_title .= "\n</center></div>";
return $the_title . $_ ;
}
#
# Module synopsis support
#
require SynopsisTable;
sub get_chapter_id(){
my $id = do_cmd_thechapter('');
$id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
$id =~ s/\.//;
return $id;
}
# 'chapter' => 'SynopsisTable instance'
%ModuleSynopses = ();
sub get_synopsis_table($){
my($chap) = @_;
my $key;
foreach $key (keys %ModuleSynopses) {
if ($key eq $chap) {
return $ModuleSynopses{$chap};
}
}
my $st = SynopsisTable->new();
$ModuleSynopses{$chap} = $st;
return $st;
}
sub do_cmd_moduleauthor{
local($_) = @_;
next_argument();
next_argument();
return $_;
}
sub do_cmd_sectionauthor{
local($_) = @_;
next_argument();
next_argument();
return $_;
}
sub do_cmd_declaremodule{
local($_) = @_;
my $key = next_optional_argument();
my $type = next_argument();
my $name = next_argument();
my $st = get_synopsis_table(get_chapter_id());
#
$key = $name unless $key;
$type = 'built-in' if $type eq 'builtin';
$st->declare($name, $key, $type);
define_module($type, $name);
return anchor_label("module-$key",$CURRENT_FILE,$_)
}
sub do_cmd_modulesynopsis{
local($_) = @_;
my $st = get_synopsis_table(get_chapter_id());
$st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
return $_;
}
sub do_cmd_localmoduletable{
local($_) = @_;
my $chap = get_chapter_id();
my $st = get_synopsis_table($chap);
$st->set_file("$CURRENT_FILE");
return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
}
sub process_all_localmoduletables{
my $key;
my $st, $file;
foreach $key (keys %ModuleSynopses) {
$st = $ModuleSynopses{$key};
$file = $st->get_file();
if ($file) {
process_localmoduletables_in_file($file);
}
else {
print "\nsynopsis table $key has no file association\n";
}
}
}
sub process_localmoduletables_in_file{
my $file = @_[0];
open(MYFILE, "<$file");
local($_);
sysread(MYFILE, $_, 1024*1024);
close(MYFILE);
# need to get contents of file in $_
while (/<tex2html-localmoduletable><(\d+)>/) {
my $match = $&;
my $chap = $1;
my $st = get_synopsis_table($chap);
my $data = $st->tohtml();
s/$match/$data/;
}
open(MYFILE,">$file");
print MYFILE $_;
close(MYFILE);
}
sub process_python_state{
process_all_localmoduletables();
process_grammar_files();
}
#
# "See also:" -- references placed at the end of a \section
#
sub do_env_seealso{
return ("<div class=\"seealso\">\n "
. "<p class=\"heading\"><b>See Also:</b></p>\n"
. @_[0]
. '</div>');
}
sub do_env_seealsostar{
return ("<div class=\"seealso-simple\">\n "
. @_[0]
. '</div>');
}
sub do_cmd_seemodule{
# Insert the right magic to jump to the module definition. This should
# work most of the time, at least for repeat builds....
local($_) = @_;
my $key = next_optional_argument();
my $module = next_argument();
my $text = next_argument();
my $period = '.';
$key = $module
unless $key;
if ($text =~ /\.$/) {
$period = '';
}
return ('<dl compact class="seemodule">'
. "\n <dt>Module <b><tt class=\"module\">"
. "<a href=\"module-$key.html\">$module</a></tt>:</b>"
. "\n <dd>$text$period\n </dl>"
. $_);
}
sub strip_html_markup($){
my $str = @_[0];
my $s = "$str";
$s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g;
$s =~ s/<\/[a-zA-Z0-9]+>//g;
return $s;
}
sub handle_rfclike_reference{
local($_, $what, $format) = @_;
my $rfcnum = next_argument();
my $title = next_argument();
my $text = next_argument();
my $url = get_rfc_url($rfcnum, $format);
my $icon = get_link_icon($url);
my $attrtitle = strip_html_markup($title);
return '<dl compact class="seerfc">'
. "\n <dt><a href=\"$url\""
. "\n title=\"$attrtitle\""
. "\n >$what $rfcnum, <em>$title</em>$icon</a>"
. "\n <dd>$text\n </dl>"
. $_;
}
sub do_cmd_seepep{
return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT);
}
sub do_cmd_seerfc{
return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT);
}
sub do_cmd_seetitle{
local($_) = @_;
my $url = next_optional_argument();
my $title = next_argument();
my $text = next_argument();
if ($url) {
my $icon = get_link_icon($url);
return '<dl compact class="seetitle">'
. "\n <dt><em class=\"citetitle\"><a href=\"$url\""
. "\n >$title$icon</a></em>"
. "\n <dd>$text\n </dl>"
. $_;
}
return '<dl compact class="seetitle">'
. "\n <dt><em class=\"citetitle\""
. "\n >$title</em>"
. "\n <dd>$text\n </dl>"
. $_;
}
sub do_cmd_seeurl{
local($_) = @_;
my $url = next_argument();
my $text = next_argument();
my $icon = get_link_icon($url);
return '<dl compact class="seeurl">'
. "\n <dt><a href=\"$url\""
. "\n class=\"url\">$url$icon</a>"
. "\n <dd>$text\n </dl>"
. $_;
}
sub do_cmd_seetext{
local($_) = @_;
my $content = next_argument();
return '<div class="seetext"><p>' . $content . '</div>' . $_;
}
#
# Definition list support.
#
sub do_env_definitions{
return "<dl class=\"definitions\">" . @_[0] . "</dl>\n";
}
sub do_cmd_term{
local($_) = @_;
my $term = next_argument();
my($name,$aname,$ahref) = new_link_info();
# could easily add an index entry here...
return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
}
# I don't recall exactly why this was needed, but it was very much needed.
# We'll see if anything breaks when I move the "code" line out -- some
# things broke with it in.
#code # {}
process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
declaremodule # [] # {} # {}
memberline # [] # {}
methodline # [] # {} # {}
modulesynopsis # {}
platform # {}
samp # {}
setindexsubitem # {}
withsubitem # {} # {}
_RAW_ARG_DEFERRED_CMDS_
$alltt_start = '<dl><dd><pre class="verbatim">';
$alltt_end = '</pre></dl>';
sub do_env_alltt {
local ($_) = @_;
local($closures,$reopens,@open_block_tags);
# get the tag-strings for all open tags
local(@keep_open_tags) = @$open_tags_R;
($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R);
# get the tags for text-level tags only
$open_tags_R = [ @keep_open_tags ];
local($local_closures, $local_reopens);
($local_closures, $local_reopens,@open_block_tags)
= &preserve_open_block_tags
if (@$open_tags_R);
$open_tags_R = [ @open_block_tags ];
do {
local($open_tags_R) = [ @open_block_tags ];
local(@save_open_tags) = ();
local($cnt) = ++$global{'max_id'};
$_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C
, $_ , $O, $global{'max_id'}, "$C$O$cnt$C");
$_ = &translate_environments($_);
$_ = &translate_commands($_) if (/\\/);
# preserve space-runs, using
while (s/(\S) ( +)/$1$2;SPMnbsp;/g){};
s/(<BR>) /$1;SPMnbsp;/g;
$_ = join('', $closures, $alltt_start, $local_reopens
, $_
, &balance_tags() #, $local_closures
, $alltt_end, $reopens);
undef $open_tags_R; undef @save_open_tags;
};
$open_tags_R = [ @keep_open_tags ];
$_;
}
sub do_cmd_verbatiminput{
local($_) = @_;
my $fname = next_argument();
my $file;
my $found = 0;
my $texpath;
# Search TEXINPUTS for the input file, the way we're supposed to:
foreach $texpath (split /$envkey/, $TEXINPUTS) {
$file = "$texpath$dd$fname";
last if ($found = (-f $file));
}
my $srcname;
my $text;
if ($found) {
open(MYFILE, "<$file") || die "\n$!\n";
read(MYFILE, $text, 1024*1024);
close(MYFILE);
use File::Basename;
my $srcdir, $srcext;
($srcname, $srcdir, $srcext) = fileparse($file, '\..*');
open(MYFILE, ">$srcname.txt");
print MYFILE $text;
close(MYFILE);
#
# These rewrites convert the raw text to something that will
# be properly visible as HTML and also will pass through the
# vagaries of conversion through LaTeX2HTML. The order in
# which the specific rewrites are performed is significant.
#
$text =~ s/\&/\&/g;
# These need to happen before the normal < and > re-writes,
# since we need to avoid LaTeX2HTML's attempt to perform
# ligature processing without regard to context (since it
# doesn't have font information).
$text =~ s/--/-&\#45;/g;
$text =~ s/<</\<\&\#60;/g;
$text =~ s/>>/\>\&\#62;/g;
# Just normal re-writes...
$text =~ s/</\</g;
$text =~ s/>/\>/g;
# These last isn't needed for the HTML, but is needed to get
# past LaTeX2HTML processing TeX macros. We use \ instead
# of / since many browsers don't support that.
$text =~ s/\\/\&\#92;/g;
}
else {
$text = '<b>Could not locate requested file <i>$fname</i>!</b>\n';
}
return ('<dl><dd><pre class="verbatim">'
. $text
. "</pre>\n<div class=\"verbatiminput-footer\">\n"
. "<a href=\"$srcname.txt\" type=\"text/plain\""
. ">Download as text.</a>"
. "\n</div>\n</dd></dl>"
. $_);
}
1; # This must be the last line
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -