[system] / trunk / pg / macros / unionLists.pl Repository:
ViewVC logotype

View of /trunk/pg/macros/unionLists.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6518 - (download) (as text) (annotate)
Thu Nov 11 21:35:05 2010 UTC (9 years ago) by gage
File size: 3476 byte(s)
correct bug declaring eHTML and bHTML are undefined


    1 ######################################################################
    2 ##
    3 ##  Functions used to make <UL> and <OL> lists in HTML files
    4 ##  and corresponding lists in TeX mode.
    5 ##
    6 ##    BeginList()             starts a list
    7 ##    $ITEM                   start a list item
    8 ##    $ITEMSEP                puts spacing between items
    9 ##    EndList()               ends a list
   10 ##
   11 ##    BeginParList()          starts a list of paragraphs
   12 ##    EndParList()            ends such a list
   13 ##
   14 
   15 sub _unionLists_init {}; # don't reload this file
   16 
   17 =head2 unionLists.pl
   18 
   19  ######################################################################
   20  #
   21  #  Usage:  BeginList(type,options);
   22  #
   23  #  Produces <OL> and <UL> lists.  Type must be either "OL" or "UL",
   24  #  (and defaults to "OL").  The options are
   25  #
   26  #    type => "type"            Specifies the type of marker
   27  #                              (default is none specified)
   28  #
   29  #    value => num or string    Specified the initial value of the
   30  #                              item numbering
   31  #
   32  #    tex_par => 1 or 0         Set paragraph spacing in TeX mode
   33  #                              (default is 0)
   34  #
   35  #    noTopSkip => 1 or 0       Remove top skip produced by enumerate
   36  #                              in TeX mode
   37  #                              (default is 0)
   38  #
   39  #  Example:
   40  #
   41  #    BEGIN_TEXT
   42  #      \{BeginList("OL")\}
   43  #      $ITEM This is the first item
   44  #      $ITEM This is the second
   45  #      \{EndList("OL")\}
   46  #    END_TEXT
   47  #
   48  #
   49  #  Usage:  EndList(type)
   50  #
   51  #  where type is the list type (and must match the BeginList type).
   52  #
   53 
   54 
   55 
   56 =cut
   57 
   58 our $bHTML = '\begin{rawhtml}';
   59 our $eHTML = '\end{rawhtml}';
   60 
   61 sub BeginList {
   62   my $LIST = 'OL';
   63   $LIST = shift if (uc($_[0]) eq "OL" or uc($_[0]) eq "UL");
   64   my $enum = ($LIST eq 'OL' ? "enumerate" : "itemize");
   65   my %options = @_;
   66   $LIST .= ' TYPE="'.$options{type}.'"' if defined($options{type});
   67   $LIST .= ' START="'.$options{value}.'"' if defined($options{value});
   68   $LIST = "<$LIST>";
   69   my $tex = ""; my $type = ""; my $top = "";
   70   $tex .= "\\parindent=0pt \\parskip=.75\\baselineskip\n" if $options{tex_par};
   71   $tex .= "\\setcounter{enumi}{".($options{value}-1)."}" if defined($options{value}) && $LIST eq 'OL';
   72   $type = "[\\quad $options{type}.]" if defined($options{type}) && $LIST eq 'OL';
   73   $top = '\vskip-\parskip\hrule height 0pt' if $options{noTopSkip};
   74 
   75   MODES(
   76     TeX => "\\par${top}{\\parskip=0pt\\begin{$enum}$type\n$tex",
   77     Latex2HTML => $bHTML.$LIST.$eHTML,
   78     HTML => $LIST."\n"
   79   );
   80 }
   81 
   82 #
   83 #  Usage:  EndList(type)
   84 #
   85 #  where type is the list type (and must match the BeginList type).
   86 #
   87 sub EndList {
   88   my $LIST = shift; $LIST = 'OL' unless defined $LIST;
   89   my $enum = ($LIST eq 'OL' ? "enumerate" : "itemize");
   90   $LIST = "</$LIST>";
   91   MODES(
   92     TeX => "\\end{$enum}}",
   93     Latex2HTML => $bHTML.$LIST.$eHTML,
   94     HTML => $LIST."\n"
   95   );
   96 }
   97 
   98 #
   99 #  Syntactic sugar for making lists of paragraphs
  100 #
  101 sub BeginParList {
  102   my $LIST = 'OL';
  103   $LIST = shift if (uc($_[0]) eq "OL" or uc($_[0]) eq "UL");
  104   BeginList($LIST,tex_par=>1,@_);
  105 }
  106 
  107 sub EndParList {EndList(@_)};
  108 
  109 
  110 #
  111 #  Use $ITEM to introduce a new list item
  112 #
  113 $ITEM = MODES(
  114   TeX => '\item\ignorespaces ',
  115   Latex2HTML => $bHTML.'<LI>'.$eHTML,
  116   HTML => "<LI>"
  117 );
  118 
  119 #
  120 #  This is a hack for when you want MSIE to handle
  121 #  space between list items properly
  122 #
  123 $ITEMSEP = MODES(
  124   TeX => '\par\vskip-\parskip\vskip\baselineskip ',
  125   Latex2HTML => $bHTML."<BR><BR>".$eHTML,
  126   HTML => "<BR><BR>"
  127 );
  128 
  129 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9