📄 texi2www
字号:
# > a + b = c ==> > a + b = c# > @end example > </PRE>{ local ($block,$pre) = @_; local ($started_at); $started_at = $start_index; &printHTML("$paragraph_end") if $in_paragraph; $in_paragraph = 0; if ($pre eq '>PRE') { &printHTML("<DL><DT><DD>\n<PRE>\n"); } else { &printHTML("<$pre>\n") unless ($pre eq '-'); } $in_preformatted = $block; while ($texinfo_index < @texinfo) { &get_more_stuff_to_parse(); if (/^\@end\s+$block/) { if ($pre eq 'HR') { &printHTML("</HR>\n"); } elsif ($pre eq '>PRE') { &printHTML("</PRE>\n</DL>\n"); } else { &printHTML("</$pre>\n") unless ($pre eq '-'); } $in_preformatted = 0; return; } &parse(); } print "**ERROR** reached EOF while searching for end of the \@$block " . "block that started on $origin[$started_at]\n";} # parse_block########################################################################sub parse_def# $_ contains a @def* command{ local ($def) = @_; local ($started_at,$in_dd); $started_at = $start_index; &printHTML("$paragraph_end") if $in_paragraph; $in_paragraph = 0; &printHTML("<DL>\n"); &printdef(); while ($texinfo_index < @texinfo) { &get_more_stuff_to_parse(); if (/^\@end\s+$def/) { &printHTML("</DL>\n"); $in_paragraph = 0; return; } if (s/^(\@def\w+)x\s/$1 /) {&printdef();} else { unless ($in_dd) { &printHTML("<DD>\n"); ++$in_dd; $in_paragraph = 1; $paragraph_end = "\n"; } &parse(); } } print "**ERROR** reached EOF while searching for end of the $def " . "definition that started on $origin[$started_at]\n";} # parse_defsub printdef{ s/\@defun(x?)\s/\@deffn Function / || s/\@defmac(x?)\s/\@deffn Macro / || s/\@defspec(x?)\s/\@deffn \{Special Form\} / || s/\@defvar(x?)\s/\@defvr Variable / || s/\@defopt(x?)\s/\@defvr \{User Option\} / || s/\@deftypefun(x?)\s/\@deftypefn Function / || s/\@deftypevar(x?)\s/\@deftypefn Variable / || s/\@defivar(x?)\s/\@defcv \{Instance Variable\} / || s/\@defmethod(x?)\s/\@defop Method /; s/(\@\w+)x\s/$1 /; @words = split; $i = 1; $category = $words[$i++]; while ($i < @words && $category =~ /^\{[^}]*$/) { $category .= ' ' . $words[$i++]; } if ($i>=@words) { print "def error at $origin{$started_at}\n"; } $category =~ s/^\{//; $category =~ s/\}$//; &printHTML("<DT>$category: "); if ($words[0] eq '@deftypefn' || $words[0] eq '@deftypevr' || $words[0] eq '@defcv' || $words[0] eq '@defop') { if ($words[$i] =~ s/^\{//) { &printHTML("<VAR>"); until ($words[$i] =~ s/\}$//) {&printHTML("$words[$i++]");} &printHTML("$words[$i++]</VAR> "); } else { &printHTML("<VAR>$words[$i++]</VAR> "); } $words[0] =~ /.*([a-z][a-z])/; $_ = "\@" . $1 . "index " . $words[$i]; &process_index; } &printHTML("<STRONG>$words[$i++]</STRONG>\n<VAR>"); while ($i < @words) {&printHTML(" $words[$i++]");} &printHTML("</VAR>\n");} # printdef########################################################################sub parse_enumerate# $_ is `@enumerate'. Note that @enumerate with an arg (`@enumerate 3',# for example) is kinda funky due to HTML limitations.{ local ($count,$started_at); $started_at = $start_index; &printHTML("$paragraph_end") if $in_paragraph; $in_paragraph = 0; if (/^\@enumerate\s*(\S+)/) {$count = $1;} &printHTML("<" . ($count ? "UL" : "OL") . ">\n"); while ($texinfo_index < @texinfo) { &get_more_stuff_to_parse(); if (/^\@end\s+enumerate/) { &printHTML("</" . ($count ? "UL" : "OL") . ">\n"); return; } if (/^\@item\s+(.*)/ || /^\@item()$/) { if ($count) { &printHTML("<LI>$count: $1\n"); ++$count; } else { &printHTML("<LI>$1\n"); } $in_paragraph = 1; $paragraph_end = "\n"; } else { &parse(); } } print "**ERROR** reached EOF while searching for end of the \@enumerate " . "that started on $origin[$started_at]\n";} # parse_enumerate########################################################################sub parse_flush{ local ($started_at,$flush); /^\@(\w+)\s/; $flush = $1; $started_at = $start_index; &printHTML("$paragraph_end") if $in_paragraph; $in_paragraph = 0; while ($texinfo_index < @texinfo) { &get_more_stuff_to_parse(); if (/^\@end\s+$flush/) { return; } &parse(); } print "**ERROR** reached EOF while searching for end of the $flush " . "that started on $origin[$started_at]\n";} # parse_flush########################################################################sub parse_itemize# $_ is `@itemize'. Due to HTML limitation, `@itemize @bullet' comes# out the same as `@itemize @minus'.{ local ($started_at); $started_at = $start_index; &printHTML("$paragraph_end") if $in_paragraph; $in_paragraph = 0; &printHTML("<UL>\n"); while ($texinfo_index < @texinfo) { &get_more_stuff_to_parse(); if (/^\@end\s+itemize/) { &printHTML("</UL>\n"); return; } if (/^\@item\s+(.*)/ || /^\@item()$/) { &printHTML("<LI>$1\n"); $in_paragraph = 1; $paragraph_end = "\n"; } else { &parse(); } } print "**ERROR** reached EOF while searching for end of the itemize " . "that started on $origin[$started_at]\n";} # parse_itemize########################################################################sub parse_menu{ local ($started_at); $started_at = $start_index; &printHTML("$paragraph_end") if $in_paragraph; $in_paragraph = 0; &printHTML("<MENU>\n"); while ($texinfo_index < @texinfo) { &get_more_stuff_to_parse(); if (/^\@end\s+menu/) { &printHTML("</MENU>\n"); return; } # Like ` * menu-item:: description of item' if (/^\s*\*\s*([^:]*)\s*::\s*(.*)$/) { &printHTML("$paragraph_end") if $in_paragraph; $in_paragraph = 0; $node = &canonical($1); &printHTML("<LI><A HREF=\"$node\">$1</A>\n"); &printHTML("$2\n") if $2; # Like ` * menu-item: cross-reference. description of item' } elsif (/^\s*\*\s*([^:]*)\s*:([^.]*)\.\s*(.*)$/) { &printHTML("$paragraph_end") if $in_paragraph; $in_paragraph = 0; $node = &canonical($2); &printHTML("<LI><A HREF=\"$node\">$1</A>\n"); &printHTML("$3\n"); } elsif (/^\@/) { print "**WARNING** Don\'t know how to process \`$_\' inside " . "a menu!\n"; } else { if (/^\s*$/ && !$in_paragraph) { &printHTML("<P>"); $in_paragraph = "1"; $paragraph_end = "</P>\n"; } &printHTML("$_"); } } print "**ERROR** reached EOF while searching for end of the menu " . "that started on $origin[$started_at]\n";} # parse_menu########################################################################sub parse_table# $_ is `@itemize'. Due to HTML limitation, `@itemize @bullet' comes# out the same as `@itemize @minus'.{ local ($table,$ttype,$after_DT,$started_at,$first_para); ($table,$ttype) = @_; $started_at = $start_index; &printHTML("$paragraph_end") if $in_paragraph; $in_paragraph = 0; &printHTML("<DL>\n"); while ($texinfo_index < @texinfo) { &get_more_stuff_to_parse(); if (/^\@end\s+$table/) { &printHTML("</DL>\n"); return; } if (/^\@item(x?)\s+(.*)/ || /^\@item(x?)()$/) { $atarg = $2; if ($ttype) { if ($ttype =~ /(.+),(.+),(.+)/) { $left = $1; $z = $2; $right = $3; } else { $left = ''; $z = $ttype; $right = ''; } if ($z =~ s/^\^//) {$atarg =~ tr/a-z/A-Z/;} &printHTML("<DT>$left<$z>$atarg</$z>$right\n"); } else { &printHTML("<DT>$2\n"); } $item = $2; if ($item && $table =~ /([fv])table/) { $_ = "\@" . $1 . "index " . $item; &process_index; } $after_DT = 1; } else { if ($after_DT) { &printHTML("<DD>\n"); $in_paragraph = 1; $paragraph_end = "\n"; $after_DT = 0; $first_para = 1; } unless ($first_para && /^\s*$/) { $first_para = 0; &parse(); } } } print "**ERROR** reached EOF while searching for end of the table " . "that started on $origin[$started_at]\n";} # parse_table########################################################################sub print_index{ local ($index) = @_; $index = $index_name{$index}; eval "\@keys = keys \%$index"; &printHTML("<MENU>\n"); foreach $item (sort texinfo_sort @keys) { eval "\$val = \$$index\{\$item\}"; &printHTML("<LI>$val\n"); } &printHTML("</MENU>\n");} # print_indexsub texinfo_sort{ $x = $a; $x =~ s/<[^>]*>//g; $x =~ tr/A-Z/a-z/; $y = $b; $y =~ s/<[^>]*>//g; $y =~ tr/A-Z/a-z/; $x cmp $y;} # texinfo_sort########################################################################sub process_index## For example, `@cindex whatever' generates an entry in %cpindex#{ s/\@cindex/\@cpindex/ || s/\@findex/\@fnindex/ || s/\@vindex/\@vrindex/ || s/\@kindex/\@kyindex/ || s/\@pindex/\@pgindex/ || s/\@tindex/\@tpindex/; /\@(..)index\s+(.*)/; if ($x=$index_style{$1}) { $entry = "<A HREF=\"$cthis\"><$x>$2</$x></A>"; } else { $entry = "<A HREF=\"$cthis\">$2</A>"; } print "*** \$$index_name{$1}\{$2\} = $entry\n" if $debug{'index'}; eval "\$$index_name{$1}\{\$2\} = \$entry";} # process_index########################################################################sub print_arrows{ &printHTML("<LINK REL=\"Precedes\" HREF=\"$cnext\">\n") if $next; &printHTML("<LINK REV=\"Precedes\" HREF=\"$cprev\">\n") if $prev; &printHTML("<LINK REV=\"Subdocument\" HREF=\"$cup\">\n") if $up; &printHTML("<LINK REV=\"Library\" HREF=\"$dirfile\">\n") if $dirfile; &printHTML("</HEAD><BODY><P>\n"); if ($cprev) { &printHTML("<A HREF=\"$cprev\"><IMG ALIGN=MIDDLE " . "SRC=\"$icons/prev-arrow.gif\" ALT=\"PREV\"></A>\n"); } else { &printHTML("<A><IMG ALIGN=MIDDLE " . "SRC=\"$icons/missing-arrow.gif\" ALT=\"prev\"></A>\n"); } if ($cup) { &printHTML("<A HREF=\"$cup\"> <IMG ALIGN=MIDDLE " . "SRC=\"$icons/up-arrow.gif\" ALT=\"UP\"></A>\n"); } else { &printHTML("<A><IMG ALIGN=MIDDLE " . "SRC=\"$icons/missing-arrow.gif\" ALT=\"up\"></A>\n"); } if ($cnext) { &printHTML("<A HREF=\"$cnext\"><IMG ALIGN=MIDDLE " . "SRC=\"$icons/next-arrow.gif\" ALT=\"NEXT\"></A>\n"); } else { &printHTML("<A><IMG ALIGN=MIDDLE " . "SRC=\"$icons/missing-arrow.gif\" ALT=\"next\"></A>\n"); } if ($dirfile) {# XXX need new graphic for this one &printHTML("<A HREF=\"$dirfile\"> <IMG ALIGN=MIDDLE " . "SRC=\"$icons/dir-arrow.gif\" ALT=\"Bookshelf\"></A>\n"); } else { &printHTML("<A><IMG ALIGN=MIDDLE " . "SRC=\"$icons/missing-arrow.gif\" ALT=\"Bookshelf\"></A>\n"); } &printHTML("<CITE>$title</CITE>") if $title;}########################################################################sub process_node# On entry, $_ is an @node line.{ s/^\@node\s+//; ($this,$next,$prev,$up) = split(/,/); &deduce_node_links() unless ($next || $prev || $up); &terminate_node(); $cthis = &canonical($this); $cnext = &canonical($next); $cprev = &canonical($prev); $cup = &canonical($up); print "... opening $dir$cthis ...\n" if $debug{nodes}; open(HTML,">$dir/$cthis") || die "Couldn't open $dir$cthis -- $!\n"; $nfootnotes = 0; &printHTML("<HTML>\n"); &printHTML("<!-- created $today from " .
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -