################################################################################ # Copyright 1998-1999 by Jens Lippmann (lippmann@rbg.informatik.tu-darmstadt.de) # # Permission to use, copy, modify, and distribute this software for any # purpose and without fee is hereby granted, provided that the above # copyright notice appears in all copies. This software is provided "as is" # and without any express or implied warranties. # ################################################################################ # # HTCWEB.PERL # # Extension to LaTeX2HTML to translate HyTeX specific commands. # See also htcweb.tex, htcweb.sty. # # $Source: /home/latex2ht/cvs/latex2html/user/cweb2html/htcweb.perl,v $ # $RCSfile: htcweb.perl,v $ # $Revision: 1.3 $ # $Date: 1999/10/15 22:05:37 $ # $Author: JCL $ # $State: Exp $ # ################################################################################ # History # # $Log: htcweb.perl,v $ # Revision 1.3 1999/10/15 22:05:37 JCL # small patch to get real node names with l2h 99.2 instead subsequent M.html or N.html # # Revision 1.2 1999/04/09 19:25:33 JCL # changed my e-Mail address # # Revision 1.1 1998/02/24 02:29:50 latex2html # for 98.1 # # Revision 1.1 1998/02/24 02:15:57 latex2html # ready for 98.1 # # Revision 1.13 1997/11/10 09:24:32 zohar # th-darmstadt -> tu... # # Revision 1.12 1997/09/13 01:07:04 lippmann # improved support of LoI, LoR navigation buttons # # Revision 1.11 1997/06/26 19:00:11 lippmann # improved input logic for .scn .idx files (seeks TEXINPUTS) # # Revision 1.10 1997/06/01 13:20:20 lippmann # more enhancements depending on HTCwebmode (titles, \A, \As etc.) # # Revision 1.9 1997/06/01 11:56:08 lippmann # o changed name from htmlmac to htcweb # o htcweb.perl takes different actions depending on $HTCwebmode # (\U, \Us, \Q, \Qs string translation currently) # # Revision 1.8 1997/06/01 10:42:49 lippmann # o handles now enumerations of section cited along \U, \Q, \Us and \Qs # occurring in cweave generated output # o variable names adhere to HTCweb name space # o uses initialisation function # # Revision 1.7 1997/06/01 08:18:23 lippmann # Introduced the name space HTCweb, which will be used both in TeX and Perl # packages and for mapping to some CWEB internals hidden from LaTeX2HTML. # # HTmode, HTpretty, HTnoderef -> HTCweb... # HTweb -> HTCweb # \ciao -> \HTCwebdocumentend # 1 -> HTCweboneright # 2 -> HTCweboneleft # 3 -> HTCweboptbreak # 4 -> HTCwebthisleft # 5 -> HTCwebbigoptbreak # 6 -> HTCwebbreak # 7 -> HTCwebbigbreak # 8 -> HTCwebclearleft # 9 -> HTCwebempty # idit -> HTCwebidit # idma -> HTCwebidma # idbo -> HTCwebidbo # idtt -> HTCwebidtt # discr -> HTCwebdiscr # mathque -> HTCwebmathque # smllspc -> HTCwebsmllspc # # Revision 1.6 1997/05/31 01:52:35 lippmann # handles new synopsis of \HTwebNodeRef to translate multi-part refinement # types in the list of refinements # # Revision 1.5 1997/05/25 22:34:12 lippmann # added some interesting parsing logic to process list of identifiers/refinements # - calls pre_process, substitute_meta_cmds (and wrap_shorthand_environments) # - &do_cmd_fin keeps its contents mostly processed by l2h, this enabled me # to remove redundant parsing # # Revision 1.4 1997/05/25 21:17:49 lippmann # o handles cweave generated list of identifiers # o handling of multi-part refinements is missing # # Revision 1.3 1997/01/26 19:31:30 lippmann # improved handling of external labels # # Revision 1.2 1996/12/11 11:16:07 lippmann # adapted to work with new htmlmac macros # # Revision 1.1.1.1 1996/07/08 15:46:25 liefke # initial version for Darmstadt # # Revision 1.1.1.1 1996/07/08 15:46:25 liefke # initial version for Darmstadt # # Revision 1.6 1996/06/25 20:58:52 lippmann # - external bubble names handled conditionally on whether it's been found # in label files or not # - suitable standard output for above cases # # Revision 1.5 1996/06/20 02:04:53 lippmann # - HTweb macros are handled, stand-alone web documents may be # interlinked now ... yeah! # # Revision 1.4 1996/06/09 17:49:18 lippmann # slightly revised, glossar feature improved # # Revision 1.3 1996/05/16 00:53:34 lippmann # change for do_cmd_N # # Revision 1.2 1996/05/10 17:38:45 lippmann # needed to introduce \ciao as substitution for \end{document}. # This is a hack. # # Revision 1.1 1996/04/25 12:31:40 lippmann # new home for these files # ################################################################################ package main; # latex2html adds
when a non-ignored command appears at the line end, # even if the command has a perl function. Hence we have to ignore some # commands explicitely if we don't want a
(such as \6,\7,\SHC,..).
&ignore_commands( <<"#IGNORED_CMDS");
NODECOMMAND
ADDCONTENTSCOMMAND
HTCwebdiscr
PB
MRL
HTCweboptbreak#{}
HTCwebbigoptbreak
5
LASTM#{}
LIXM#{}
GLOSSARM#{}
HyTeXSetDown
addvspace
HTCwebdocumentend
HTCwebX
fi
hbox
mathrel
#IGNORED_CMDS
%section_commands = ('N', 'H1', 'M', 'H2', 'inx', 'H2', 'fin', 'H2', %section_commands);
$CUSTOM_TITLES = 1;
sub custom_title_hook {
local($title) = @_;
print "XXX customize title <$title> to ", $_[0]);
}
sub do_cmd_HTCwebbigbreak {
&do_cmd_7;
}
sub do_cmd_8 {
local($full_skip) = $HTCweb_cmode_indent;
$full_skip =~ s/<\/DL>//;
$HTCweb_skip_indent = $full_skip;
$HTCweb_skip_indent =~ s/\///g;
$HTCweb_cmode_break = "";
join('',"$full_skip", $_[0]);
}
sub do_cmd_HTCwebclearleft {
&do_cmd_8;
}
#...
sub do_cmd_HTCwebmathque {
join('','?', $_[0]);
}
#...
sub do_cmd_A {
local($_)=@_;
# If raw digits follow the command, it's a cweave-like reference.
# Get a list of numbers terminated by a dot and hyperize them.
s/^([^\.]*)/&HTCweb_replace_refs($1)/e
if /^\s*\d/;
join('', $HTCweb_also_string, ' ', $_);
}
sub do_cmd_As {
local($_)=@_;
# If raw digits follow the command, it's a cweave-like reference.
# Get a list of numbers terminated by a dot and hyperize them.
s/^([^\.]*)/&HTCweb_replace_refs($1)/e
if /^\s*\d/;
join('', $HTCweb_alsos_string, ' ', $_);
}
# Backwards compatiblity
sub do_cmd_B {
$HTCweb_skip_indent = "";
$HTCweb_cmode_indent = "";
join('',' ", $_[0]);
}
sub do_cmd_Z {
join('','<=', $_[0]);
}
#ZZ?
sub do_cmd_secttag {
# section changed tag
join('','*', $_[0]);
}
sub do_cmd_oct {
join('','0', $_[0]);
}
sub do_cmd_hex {
join('','0x', $_[0]);
}
sub do_cmd_vb{
local($_) = @_;
s/$next_pair_pr_rx//o;
join(''," $2 ",$_);
}
#... ?
sub do_cmd_HTCwebsmllspc {
join('',' ', $_[0]);
}
# Backwards compatiblity
sub do_cmd_cio {
local($indent) = $HTCweb_skip_indent . $HTCweb_cmode_indent;
$HTCweb_cmode_indent = "";
join('',"$indent ", $_[0]);
}
# Formerly do_cmd_cio
sub do_cmd_HTCwebpar {
local($indent) = $HTCweb_skip_indent . $HTCweb_cmode_indent;
$HTCweb_cmode_indent = "";
join('',"$indent ", $_[0]);
}
sub do_cmd_noderef {
local($_) = @_;
local($id,$label);
s/$next_pair_pr_rx/($id, $label) = ($1, $2);''/eo;
s/$next_pair_pr_rx//o;
join('',"$2<\/A>",$_);
}
sub do_cmd_HTCwebNodeRef {
local($_) = @_;
# get comma separated list of {";
local($lor_img) = "
";
$GLOSSARY = &add_special_link($glossary_visible_mark, $gls_file, $file)
if ($styles_loaded{'lips'} && $INDEX_IN_NAVIGATION);
($LOI,$LOR) = (&add_special_link($loi_img, $HTCweb_loi_file, $file),
&add_special_link($lor_img, $HTCweb_lor_file, $file))
if $INDEX_IN_NAVIGATION;
"" .
# Now add a few buttons with a space between them
"$NEXT $UP $PREVIOUS $CONTENTS $INDEX $GLOSSARY $LOI $LOR $CUSTOM_BUTTONS" .
"\n
" . # Line break
# If ``next'' section exists, add its title to the navigation panel
($NEXT_TITLE ? "\n Next: $NEXT_TITLE" : undef) .
# Similarly with the ``up'' title ...
($UP_TITLE ? "\n Up: $UP_TITLE" : undef) .
# ... and the ``previous'' title
($PREVIOUS_TITLE ? "\n Previous: $PREVIOUS_TITLE" : undef) .
# These
s separate it from the text body.
"\n
"
}
# The following functions reflect the translation of the TeX macro
# as defined in roughly the same order in cwebmac.tex (hywebmac.tex).
#
# A function starting with 'HTCweb' is the translation for the synonym
# to Cweb defined in htcweb.sty and occurs beneath the original one.
#
# Some Cweb macros simply need to be ignored, hereto belongs a list of
# ignored commands defined in this file.
#
# Some of the Cweb macros didn't make sense to get translated, such
# omissions are marked with (#...).
# This had been the case when no occurrence of such macros within
# any of the CWEB generated TeX files (except hycweave.tex) has been
# noticed (sorry but empirical to me are our project sources and I do
# not support esoteric stuff until I see a reason)
#
# Functions #xyz needed no translation, their argument(s)
# are simply passed through LaTeX2HTML.
#
# See also the htcweb.sty documentation.
#...
sub do_cmd_hT {
join('','HyTeX', $_[0]);
}
sub do_cmd_cweb {
join('','CWEB ', $_[0]);
}
#...
sub do_cmd_CEE {
join('','C ', $_[0]);
}
sub do_cmd_UNIX {
join('','UNIX ', $_[0]);
}
sub do_cmd_TEX {
join('','TeX', $_[0]);
}
sub do_cmd_CPLUSPLUS {
join('','C++ ', $_[0]);
}
sub do_cmd_Cee {
join('','C ', $_[0]);
}
sub do_cmd_9{
local($_) = @_;
s/$next_pair_pr_rx//o;
$_;
}
sub do_cmd_HTCwebempty{
&do_cmd_9;
}
sub do_cmd_HTCwebidit{
local($_) = @_;
s/$next_pair_pr_rx//o;
join(''," $2 ",$_);
}
sub do_cmd_HTCwebidma{
local($_) = @_;
s/$next_pair_pr_rx//o;
join(''," $2 ",$_);
}
sub do_cmd_HTCwebidbo{
local($_) = @_;
s/$next_pair_pr_rx//o;
join(''," $2 ",$_);
}
sub do_cmd_HTCwebidtt{
local($_) = @_;
s/$next_pair_pr_rx//o;
join(''," $2 ",$_);
}
#HTCwebdiscr
#...
#PB
sub do_cmd_AM {
join('','&', $_[0]);
}
sub do_cmd_BS {
join('','\', $_[0]);
}
sub do_cmd_LB {
join('','{', $_[0]);
}
sub do_cmd_RB {
join('','}', $_[0]);
}
sub do_cmd_SP {
join('',' ', $_[0]);
}
sub do_cmd_TL {
join('','~', $_[0]);
}
sub do_cmd_UL {
join('','_', $_[0]);
}
sub do_cmd_CF {
join('','^', $_[0]);
}
sub do_cmd_PP {
join('','+ +', $_[0]);
}
# contiguous minuses might be compressed by LaTeX2HTML
# to mimick TeX behaviour.
sub do_cmd_MM {
join('','- -', $_[0]);
}
sub do_cmd_MG {
join('','->', $_[0]);
}
#MRL
sub do_cmd_GG {
join('','>>', $_[0]);
}
sub do_cmd_LL {
join('','<<', $_[0]);
}
sub do_cmd_NULL {
join('','NULL', $_[0]);
}
sub do_cmd_AND {
join('','&', $_[0]);
}
sub do_cmd_OR {
join('','|', $_[0]);
}
sub do_cmd_XOR {
join('','^', $_[0]);
}
sub do_cmd_CM {
join('','~', $_[0]);
}
sub do_cmd_MOD {
join('','%', $_[0]);
}
sub do_cmd_DC {
join('','::', $_[0]);
}
sub do_cmd_PA {
join('','.*', $_[0]);
}
sub do_cmd_MGA {
join('','->*', $_[0]);
}
sub do_cmd_this {
join('','this', $_[0]);
}
sub do_cmd_1 {
$HTCweb_cmode_indent = join("","",$HTCweb_cmode_indent);
$HTCweb_cmode_break = "";
join('',"", $_[0]);
}
sub do_cmd_HTCweboneright {
&do_cmd_1;
}
sub do_cmd_2 {
$HTCweb_cmode_indent =~ s/<\/DL>//;
join('',"
", $_[0]);
}
sub do_cmd_HTCweboneleft {
&do_cmd_2;
}
#3
sub do_cmd_HTCweboptbreak {
$_[0] =~ s/^\d//;
$_[0];
}
sub do_cmd_4 {
$HTCweb_skip_indent = join("","",$HTCweb_skip_indent);
$HTCweb_cmode_break = "";
join('',"
", $_[0]);
}
sub do_cmd_HTCwebthisleft {
&do_cmd_4;
}
#5
sub do_cmd_6 {
local($indent,$break) = ($HTCweb_skip_indent,$HTCweb_cmode_break);
$HTCweb_skip_indent = "";
$HTCweb_cmode_break = "
";
join('',"$break$indent", $_[0]);
}
sub do_cmd_HTCwebbreak {
&do_cmd_6;
}
sub do_cmd_7 {
local($indent) = $HTCweb_skip_indent;
$HTCweb_skip_indent = "";
$HTCweb_cmode_break = "
";
join('',"$indent
";
join('','', $_[0]);
}
# Formerly do_cmd_B
sub do_cmd_HTCwebB {
$HTCweb_skip_indent = "";
$HTCweb_cmode_indent = "
', $_[0]);
}
sub do_cmd_C{
local($_) = @_;
s/$next_pair_pr_rx//o;
join(''," /* $2 */",$_);
}
sub do_cmd_SHC{
&do_cmd_C;
}
sub do_cmd_D {
join('','#define ', $_[0]);
}
sub do_cmd_E {
join('','==', $_[0]);
}
sub do_cmd_ET {
join('',' and ', $_[0]);
}
sub do_cmd_ETs {
join('',',and ', $_[0]);
}
sub do_cmd_F {
join('','format ', $_[0]);
}
sub do_cmd_G {
join('','>=', $_[0]);
}
sub do_cmd_I {
join('','!=', $_[0]);
}
sub do_cmd_K {
join('','=', $_[0]);
}
# This is sectioning command, care for '<<','>>' delimiters of next pair
sub do_cmd_M {
local($_) = @_;
s/$next_pair_rx//o;
local($no) = $2;
# build title string and capitalize first letter
$TITLE = "$HTCweb_chunkname $no";
$TITLE =~ s/^(\w)/chr(ord($1)-32)/e;
join('',&anchor_label(&HTCweb_seclabel_from_no($no),$CURRENT_FILE,"
$no.
"),$_);
}
sub do_cmd_N {
local($_) = @_;
# skip depth
s/$next_pair_rx//o;
s/$next_pair_rx//o;
local($no) = $2;
# build title string and capitalize first letter
$TITLE = "$HTCweb_chunkname $no";
$TITLE =~ s/^(\w)/chr(ord($1)-32)/e;
local($label) = &HTCweb_seclabel_from_no($no);
# get the title and build the complete header.
# Cweb limits its \N caption to the first dot
s/^([^\.]*)\.//;
local($head) = $1;
$head =~ s/\n/ /g;
local($dot) = ($HTCwebmode eq "hyweb" ? "." : "");
join('',&anchor_label($label,$CURRENT_FILE,"$no. $head$dot
"),$_);
}
#LASTM
#LIXM
#GLOSSARM
sub do_cmd_Q {
local($_)=@_;
# If raw digits follow the command, it's a cweave-like reference.
# Get a list of numbers terminated by a dot and hyperize them.
s/^([^\.]*)/&HTCweb_replace_refs($1)/e
if /^\s*\d/;
join('', $HTCweb_cite_string, ' ', $_);
}
sub do_cmd_Qs {
local($_)=@_;
# If raw digits follow the command, it's a cweave-like reference.
# Get a list of numbers terminated by a dot and hyperize them.
s/^([^\.]*)/&HTCweb_replace_refs($1)/e
if /^\s*\d/;
join('', $HTCweb_cites_string, ' ', $_);
}
sub do_cmd_R {
join('','!', $_[0]);
}
sub do_cmd_T {
local($_) = @_;
s/$next_pair_pr_rx//o;
local($value) = $2;
# care of extras for constants
# octal, hexadecimal trailer already handled by \oct, \hex
# exponents
$value =~ s/_/e/g;
# next is subcripted suffix, could be in some time
$value =~ s/\$//g;
join('',"$value",$_);
}
sub do_cmd_U {
local($_)=@_;
# If raw digits follow the command, it's a cweave-like reference.
# Get a list of numbers terminated by a dot and hyperize them.
s/^([^\.]*)/&HTCweb_replace_refs($1)/e
if /^\s*\d/;
join('', $HTCweb_use_string, ' ', $_);
}
sub do_cmd_Us {
local($_)=@_;
# If raw digits follow the command, it's a cweave-like reference.
# Get a list of numbers terminated by a dot and hyperize them.
s/^([^\.]*)/&HTCweb_replace_refs($1)/e
if /^\s*\d/;
join('', $HTCweb_uses_string, ' ', $_);
}
sub do_cmd_V {
join('','||', $_[0]);
}
sub do_cmd_W {
join('','&&', $_[0]);
}
sub do_cmd_Y {
join('',"