📄 texi2html
字号:
sub next_line{ local($fh, $line); if (@input_spool) { $line = shift(@input_spool); return($line); } while (@fhs) { $fh = $fhs[0]; $line = <$fh>; return($line) if $line; close($fh); shift(@fhs); } return(undef);}# used in pass 1, use &next_linesub skip_until{ local($tag) = @_; local($_); while ($_ = &next_line) { return if /^\s*\@end\s+$tag\s*$/; } die "* Failed to find '$tag' after: " . $lines[$#lines];}## HTML stacking to have a better HTML output#sub html_reset{ @html_stack = ('html'); $html_element = 'body';}sub html_push{ local($what) = @_; push(@html_stack, $html_element); $html_element = $what;}sub html_push_if{ local($what) = @_; push(@html_stack, $html_element) if ($html_element && $html_element ne 'P'); $html_element = $what;}sub html_pop{ $html_element = pop(@html_stack);}sub html_pop_if{ local($elt); if (@_) { foreach $elt (@_) { if ($elt eq $html_element) { $html_element = pop(@html_stack) if @html_stack; last; } } } else { $html_element = pop(@html_stack) if @html_stack; }}sub html_debug{ local($what, $line) = @_; return("<!-- $line @html_stack, $html_element -->$what") if $debug & $DEBUG_HTML; return($what);}# to debug the output...sub debug{ local($what, $line) = @_; return("<!-- $line -->$what") if $debug & $DEBUG_HTML; return($what);}sub normalise_node{ $_[0] =~ s/\s+/ /g; $_[0] =~ s/ $//; $_[0] =~ s/^ //;}sub menu_entry{ local($entry, $node, $descr) = @_; local($href); &normalise_node($node); $href = $node2href{$node}; if ($href) { $descr =~ s/^\s+//; $descr = ": $descr" if $descr; push(@lines2, "<LI>" . &anchor('', $href, $entry) . "$descr\n"); } else { warn "$ERROR Undefined node ($node): $_"; }}sub do_ctrl { "^$_[0]" }sub do_sc { "\U$_[0]\E" }sub fix_image{ my($text) = @_; my($arg1, $ext); $text =~ /^([^,]*)$/; die "error in image: '$text'" unless defined($1); $arg1 = $1; $arg1 =~ s/@@/@/g; $ext = "jpg" if -f "$arg1.jpg"; $ext = "gif" if -f "$arg1.gif"; if (defined($ext)) { "<IMG SRC=\"$arg1.$ext\">"; } else { warn "Image $arg1 not found"; ""; }}sub fix_url{ my($text) = @_; $text =~ s/@@/@/g; $text;}sub fix_uref{ my($text) = @_; my($arg1, $arg2); $text =~ /^([^,]*),?([^,]*)?$/; die "error in uref: '$text'" unless defined($1); $arg1 = $1; $arg2 = (defined($2) && $2) ? $2 : $arg1; $arg1 =~ s/@@/@/g; $arg2 =~ s/@@/@/g; "<a HREF=\"$arg1\">$arg2</a>";}sub fix_email{ my($text) = @_; my($arg1, $arg2); $text =~ /^([^,]*)(,[^,]*)?$/; die "error in email: '$text'" unless defined($1); $arg1 = $1; $arg2 = defined($2) ? $2 : $arg1; $arg1 =~ s/@@/@/g; $arg2 =~ s/@@/@/g; "<a HREF=\"mailto:$arg1\">$arg2</a>";}sub apply_style{ local($texi_style, $text) = @_; local($style); $style = $style_map{$texi_style}; if (defined($style)) { # known style if ($style =~ /^\"/) { # add quotes $style = $'; $text = "\`$text\'"; } if ($style =~ /^\&/) { # custom $style = $'; $text = &$style($text); } elsif ($style) { # good style $text = "<$style>$text</$style>"; } else { # no style } } else { # unknown style $text = undef; } return($text);}# remove Texinfo stylessub remove_style{ local($_) = @_; s/\@\w+{([^\{\}]+)}/$1/g; return($_);}sub substitute_style{ local($_) = @_; local($changed, $done, $style, $text); $changed = 1; while ($changed) { $changed = 0; $done = ''; while (/\@(\w+){([^\{\}]+)}/) { $text = &apply_style($1, $2); if ($text) { $_ = "$`$text$'"; $changed = 1; } else { $done .= "$`\@$1"; $_ = "{$2}$'"; } } $_ = $done . $_; } return($_);}sub anchor{ local($name, $href, $text, $newline) = @_; local($result); $result = "<A"; $result .= " NAME=\"$name\"" if $name; $result .= " HREF=\"$href\"" if $href; $result .= ">$text</A>"; $result .= "\n" if $newline; return($result);}sub pretty_date{ local(@MoY, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); @MoY = ('January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); $year += ($year < 70) ? 2000 : 1900; return("$mday $MoY[$mon] $year");}sub doc_name{ local($num) = @_; my($real_name, $link_name); $real_name = ($opt_use_numbers) ? $num : $doc_node_name[$num]; $link_name = ($opt_special_links) ? $doc_node_name_links[$num] : $real_name; # print "# num $num osl $opt_special_links link $link_name\n"; return("${docu_name}_$real_name.html", "$opt_special_links${docu_name}_$link_name.html");}sub next_doc{ ($docu_doc, $link_doc) = &doc_name(++$doc_num);}sub print{ local(*lines, $fh) = @_; local($_); while (@lines) { $_ = shift(@lines); if (/^$PROTECTTAG/o) { $_ = $tag2pro{$_}; } else { &unprotect_texi; } print $fh $_; }}sub print_ruler{ print FILE "<P><HR><P>\n";}sub print_header{ local($_); # clean the title $_ = &remove_style($_[0]); &unprotect_texi; # print the header if ($doctype eq 'html2') { print FILE $html2_doctype; } elsif ($doctype) { print FILE $doctype; } my($tags) = defined($value{"_body_tags"}) ? " " . $value{"_body_tags"} : ""; my($et) = defined($value{"_extra_head"}) ? " " . $value{"_extra_head"} : ""; $et = &unprotect_html($et); print FILE <<EOT; <HTML> <HEAD> $header <TITLE>$_</TITLE> $et </HEAD> <BODY$tags>EOT}sub print_toplevel_header{ local($_); &print_header; # pass given arg... print FILE $full_title; if ($value{'_subtitle'}) { $value{'_subtitle'} =~ s/\n+$//; foreach (split(/\n/, $value{'_subtitle'})) { $_ = &substitute_style($_); &unprotect_texi; print FILE "<H2>$_</H2>\n"; } } if ($value{'_author'}) { $value{'_author'} =~ s/\n+$//; foreach (split(/\n/, $value{'_author'})) { $_ = &substitute_style($_); &unprotect_texi; s/[\w.-]+\@[\w.-]+/<A HREF="mailto:$&">$&<\/A>/g; print FILE "<ADDRESS>$_</ADDRESS>\n"; } } print FILE "<P>\n";}sub print_footer{ print FILE <<EOT; </BODY> </HTML>EOT}sub print_toplevel_footer{ &print_ruler; print FILE <<EOT;This document was generated on $TODAY using the<A HREF=\"$HOMEPAGE\">texi2html</A>translator version 1.52 (extended by davida\@detron.se).</P>EOT &print_footer;}sub protect_texi{ # protect @ { } ` ' s/\@\@/$;0/go; s/\@\{/$;1/go; s/\@\}/$;2/go; s/\@\`/$;3/go; s/\@\'/$;4/go;}sub protect_html{ local($what) = @_; # protect & < > # Avoid loop in & replacement. This instead bugs out for &# in text.. $what =~ s/\&([^#]|$)/\&\#38;$1/g; $what =~ s/\</\&\#60;/g; $what =~ s/\>/\&\#62;/g; # but recognize some HTML things $what =~ s/\&\#60;\/A\&\#62;/<\/A>/g; # </A> $what =~ s/\&\#60;A ([^\&]+)\&\#62;/<A $1>/g; # <A [^&]+> $what =~ s/\&\#60;IMG ([^\&]+)\&\#62;/<IMG $1>/g; # <IMG [^&]+> return($what);}sub unprotect_texi{ s/$;0/\@/go; s/$;1/\{/go; s/$;2/\}/go; s/$;3/\`/go; s/$;4/\'/go;}sub unprotect_html{ local($what) = @_; $what =~ s/\&\#38;/\&/g; $what =~ s/\&\#60;/\</g; $what =~ s/\&\#62;/\>/g; return($what);}sub byalpha{ $key2alpha{$a} cmp $key2alpha{$b};}############################################################################## # These next few lines are legal in both Perl and nroff. .00 ; # finish .ig 'di \" finish diversion--previous line must be blank.nr nl 0-1 \" fake up transition to first page again.nr % 0 \" start at page 1'; __END__ ############# From here on it's a standard manual page ############.TH TEXI2HTML 1 "09/10/96".AT 3.SH NAMEtexi2html \- a Texinfo to HTML converter.SH SYNOPSIS.B texi2html [options] file.PP.B texi2html -check [-verbose] files.SH DESCRIPTION.I Texi2htmlconverts the given Texinfo file to a set of HTML files. It tries to handlemost of the Texinfo commands. It creates hypertext links for cross-references,footnotes....PPIt also tries to add links from a reference to its corresponding entry in thebibliography (if any). It may also handle a glossary (see the.B \-glossaryoption)..PP.I Texi2htmlcreates several files depending on the contents of the Texinfo file and onthe chosen options (see FILES)..PPThe HTML files created by.I texi2htmlare closer to TeX than to Info, that's why.I texi2htmlconverts @iftex sections and not @ifinfo ones by default. You can reversethis with the \-expandinfo option..SH OPTIONS.TP 12.B \-checkCheck the given file and give the list of all things that may be Texinfo commands.This may be used to check the output of.I texi2htmlto find the Texinfo commands that have been left in the HTML file..TP.B \-expandinfoExpand @ifinfo sections, not @iftex ones..TP.B \-glossaryUse the section named 'Glossary' to build a list of terms and put links in the HTMLdocument from each term toward its definition..TP.B \-invisible \fIname\fPUse \fIname\fP to create invisible destination anchors for index links. This is a workaroundfor a known bug of many WWW browsers, including xmosaic..TP.B \-I \fIdir\fPLook also in \fIdir\fP to find included files..TP.B \-menuShow the Texinfo menus; by default they are ignored..TP.B \-monolithicOutput only one file, including the table of contents and footnotes..TP.B \-numberNumber the sections..TP.B \-split_chapterSplit the output into several HTML files (one per main section:chapter, appendix...)..TP.B \-split_nodeSplit the output into several HTML files (one per node)..TP.B \-usagePrint usage instructions, listing the current available command-line options..TP.B \-verboseGive a verbose output. Can be used with the.B \-checkoption..PP.SH FILESBy default.I texi2htmlcreates the following files (foo being the name of the Texinfo file):.TP 16.B foo_toc.htmlThe table of contents..TP.B foo.htmlThe document's contents..TP.B foo_foot.htmlThe footnotes (if any)..PPWhen used with the.B \-splitoption, it creates several files (one per chapter or node), named.B foo_n.html(n being the indice of the chapter or node), instead of the single.B foo.htmlfile..PPWhen used with the.B \-monolithicoption, it creates only one file:.B foo.html.SH VARIABLES.I texi2htmlpredefines the following variables: \fBhtml\fP, \fBtexi2html\fP..SH ADDITIONAL COMMANDS.I texi2htmlimplements the following non-Texinfo commands:.TP 16.B @ifhtmlThis indicates the start of an HTML section, this section will passed throughwithout any modofication..TP.B @end ifhtmlThis indcates the end of an HTML section..SH VERSIONThis is \fItexi2html\fP version 1.52, 09/10/96..PPThe latest version of \fItexi2html\fP can be found in WWW, cf. URLhttp://wwwcn.cern.ch/dci/texi2html/.SH AUTHORThe main author is Lionel Cons, CERN CN/DCI/UWS, Lionel.Cons@cern.ch.Many other people around the net contributed to this program..SH COPYRIGHTThis program is the intellectual property of the EuropeanLaboratory for Particle Physics (known as CERN). No guarantee whatsoever isprovided by CERN. No liability whatsoever is accepted for any loss or damageof any kind resulting from any defect or inaccuracy in this information orcode..PPCERN, 1211 Geneva 23, Switzerland.SH "SEE ALSO"GNU Texinfo Documentation Format,HyperText Markup Language (HTML),World Wide Web (WWW)..SH BUGSThis program does not understand all Texinfo commands (yet)..PPTeX specific commands (normally enclosed in @iftex) will bepassed unmodified..ex
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -