%\iffalse
%
% file: htmlstuf.dtx
% Copyright (C) 1996-1997 by Frank Bennett.  All rights reserved.
%
% IMPORTANT NOTICE:
% 
% You are not allowed to change this file.  You may however copy
% this file to a file with a different name and then change the
% copy if (a) you do not charge for the modified code, (b) you
% acknowledge the author of this file in the new file, if it
% is distributed to others, and (c) you attach these same
% conditions to the new file.
% 
% You are not allowed to distribute this file alone.  You are not
% allowed to take money for the distribution or use of this file
% (or a changed version) except for a nominal charge for copying
% etc.
% 
% You are allowed to distribute this file under the condition that
% it is distributed with all of its contents, intact.
% 
% For error reports, or offers to help make this a more powerful,
% friendlier, and altogether more thrilling package, please contact me on
% fb@soas.ac.uk.  Better yet, make a contribution to
% my pension.  Account details available on request.
%
%\fi
%
% \def\fileversion{3.1.1.1}
% \def\filedate{1998/01/17 18:15:02}
%
% \iffalse
%
%<*driver>
\documentclass{ltxdoc}
%\CodelineIndex
%\EnableCrossrefs
\begin{document}
\OnlyDescription    % Comment out for implementation details
\DocInput{htmlstuf.dtx}
\end{document}
%</driver>
%\fi
%
%\iffalse
% htmlstuf.dtx,v
% Revision 3.1.1.1  1998/01/17 18:15:02  root
% Release code, checksum verified
%
% Revision 3.1  1998/01/17 17:13:14  root
% Release code
%
% Revision 1.11  1998/01/17 16:48:35  root
% *** empty log message ***
%
% Revision 1.10  1998/01/17 11:07:21  root
% *** empty log message ***
%
% Revision 1.9  1998/01/17 11:05:29  root
% *** empty log message ***
%
% Revision 1.8  1998/01/17 10:48:00  root
% *** empty log message ***
%
% Revision 1.7  1998/01/17 06:14:32  root
% *** empty log message ***
%
% Revision 1.6  1998/01/16 21:33:57  root
% *** empty log message ***
%
% Revision 1.5  1998/01/16 21:16:47  root
% *** empty log message ***
%
% Revision 1.4  1998/01/16 21:09:07  root
% *** empty log message ***
%
% Revision 1.3  1998/01/16 19:16:11  root
% *** empty log message ***
%
% Revision 1.2  1998/01/16 18:40:07  root
% *** empty log message ***
%
%\fi
%
% \title{User's Guide to the HTML Calendar
%    package\thanks{This file is version number
%    \fileversion{}.  It was last revised on
%    \filedate{}.}}
%
% \author{Frank G. Bennett, Jr.}
%
% \maketitle
%
% \setcounter{StandardModuleDepth}{1}
% \DeleteShortVerb{\|}
% \MakeShortVerb{\"}
%
% \begin{abstract}
% \noindent This package makes a cronological list
%  of events.
% \end{abstract}
%
% \CheckSum{524}
%
% Please see the file \texttt{calguide.tex} for details on the
% use of this package.
%
% \StopEventually{\PrintIndex}
%
% \section{The Class Files}
%
% \subsection{HTML Month}
%    \begin{macrocode}
%<*htmlmonth>
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{hmonth}
          [1998/01/17 18:15:02 3.1.1.1 HTML calendar (Frank Bennett)]
\RequirePackage{calendar}
\input calopts.cfg
\InputIfFileExists{dates.cfg}{}{}
\ProcessOptions
\define@key{opt}{title}{%
  \def\yrly@title{#1}}
\define@key{opt}{labels}{%
  \@storelabels#1,,{}}
\define@key{opt}{firstday}{%
  \yrly@firstday=#1}
\define@key{opt}{outputfile}{%
  \@ifundefined{html@outputfile}
    {\newwrite\html@output
     \gdef\html@outputfile{#1}%
     \immediate\openout\html@output=\html@outputfile}
    {\gdef\hm@temp{#1}%
     \ifx\html@outputfile\hm@temp%
       \relax%
     \else%
       \immediate\closeout\html@output%
       \gdef\html@outputfile{#1}%
       \immediate\openout\html@output=\html@outputfile\relax
     \fi}}
\def\yrly@title{\themonth}
\newcount\yrly@firstday
\yrly@firstday=3\relax
\newtoks\yrly@tempreg@a
\newcount\yrly@tempcount
\def\@storelabels{%
  \def\yrly@labeltext{}%
  \@@storelabels}
\def\@@storelabels#1,#2#{%
  \ifcat$#1$%
    \yrly@tempreg@a=\expandafter{\yrly@labeltext}%
    \edef\yrly@labeltext{\the\yrly@tempreg@a}%
    \let\next\@gobble%
  \else%
    \let\next\@@storelabels%
    \yrly@tempreg@a=\expandafter{\yrly@labeltext}%
    \protected@edef\yrly@labeltext{\the\yrly@tempreg@a\space#1}%
  \fi%
    \next#2{}}
\newcount\thumbnails%
\newtoks\hm@line@a%
\def\hm@line{}
\def\hm@writeout#1{%
    \edef\hm@temp{#1}%
    \immediate\write\html@output{\hm@line\hm@temp}%
    \def\hm@line{}}
\def\hm@spaces{\ifcase\hm@spacenum\or\space\or\space\space\or\space\space\space%
  \or\space\space\space\space\fi}
\newcount\hm@spacenum
\newcalendar%
 {htmlmonth}
 {\el@output}
 {\yrly@firstday}
 {\dates@days}
 {7}
 {\hm@spaces}
 {I}
 {<pre><B>\themonth</B>^^J\yrly@labeltext^^J}%
 {^^J^^J</pre>}
 {\cal@footer%
  \cal@header}
 {^^J}
 {}
 {\global\dates@day=1%
  \dates@fix%
  \cal@range@start\dates@date%
  \message{^^JStart: \theshortweekday\space%
    \theday\space\theshortmonth\space\theyear}%
  \global\dates@date\cal@range@end%
  \caldate%  
  \global\dates@day\dates@days%
  \dates@fix%
  \cal@range@end\dates@date%
  \message{^^JEnd: \theshortweekday\space%
    \theday\space\theshortmonth\space\theyear}%
  \global\dates@date=\cal@range@start%
  \caldate%
  \@ifundefined{yrly@labeltext}{%
    \def\yrly@defaultlabels{}%
    \yrly@tempcount=1%
    \global\advance\dates@date by-\dates@weekd%
    \global\advance\dates@date by\yrly@firstday%
    \caldate%
    \loop%
      \yrly@tempreg@a=\expandafter{\yrly@defaultlabels}%
      \edef\yrly@defaultlabels{\the\yrly@tempreg@a\theshortweekday,}%
    \ifnum\yrly@tempcount<7%
     \global\advance\dates@date by1%
     \caldate% 
     \advance\yrly@tempcount by 1\relax%
    \repeat%
    \expandafter\@storelabels\yrly@defaultlabels,,{}%
    \dates@date\cal@range@start%
    \caldate}%
    {}%
  \def\el@output##1{%
    \def\hm@temp{##1}%
    \def\hm@temptwo{\cal@groupbreak}%
    \ifx\hm@temp\hm@temptwo%
      \hm@spacenum=4\relax%
    \fi%
    \ifnum\cal@subgroup@count>6\relax%
      \hm@writeout{##1}%
    \else%
      \def\hm@temptwo{\cal@footer}%
      \ifx\hm@temp\hm@temptwo%
        \hm@writeout{##1}%
      \else%
        \hm@line@a=\expandafter{\hm@line}%
        \edef\hm@line{\the\hm@line@a\hm@temp}%
      \fi%
    \fi}%
  \hm@spacenum=4\relax}%
  {}%
  {\ifnum\dates@day<9\hm@spacenum=3\else\hm@spacenum=2\fi%
   \cal@get@appointments\cal@get@events}%
  {\protected@edef\cal@entry@text{X}}%
  {\ifnum\dates@weekd=\yrly@firstday%
     \hm@spaces%
     \ifnum\theday=9%
       \space\space%
     \fi%
   \else%
     \ifnum\dates@day=1%
       \space\hm@spaces%
     \fi%
   \fi%
   \ifcat$\theappointments\theevents$%
   \else%
     <A HREF="\expandafter\@gobble\string\#\the\dates@date">%
   \fi%
   \theday%
   \ifcat$\theappointments\theevents$%
   \else%
     </A>%
   \fi}
%</htmlmonth>
%    \end{macrocode}
%
% \subsection{HTML Event List}
%
%    \begin{macrocode}
%<*htmlevent>
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{hlist}
          [1997/11/07 10:44:05 2.2 HTML Event List (Frank Bennett)]
\input calopts.cfg
\InputIfFileExists{dates.cfg}{}{}
\ProcessOptions
\ProcessOptions
\RequirePackage{calendar}
\define@key{opt}{textnum}{%
  \dates@textnum=#1\relax}
\define@key{opt}{outputfile}{%
  \@ifundefined{html@outputfile}
    {\newwrite\html@output%
     \gdef\html@outputfile{#1}%
     \immediate\openout\html@output=\html@outputfile}
    {\gdef\el@temp{#1}%
     \ifx\html@outputfile\el@temp%
       \relax%
     \else%
       \immediate\closeout\html@output%
       \gdef\html@outputfile{#1}%
       \immediate\openout\html@output=\html@outputfile\relax%
    \fi}}
\def\el@item{<LI><A NAME="\the\dates@date">\theday\space\themonth\space\theyear</A>}
\newcalendar%
{htmllist}
{\el@output}
{8}
{1}
{1}
{}
{I}
{<UL>}
{</UL>}
{}
{}
{\dates@requiremonthtrue\dates@requiredaytrue}
{\global\dates@date\cal@range@start%
 \caldate%
  \message{^^JStart: \theshortweekday\space%
    \theday\space\theshortmonth\space\theyear}%
  \global\dates@date\cal@range@end%
  \caldate%
  \message{^^JEnd: \theshortweekday\space%
    \theday\space\theshortmonth\space\theyear}%
  \global\dates@date\cal@range@start%
  \caldate%
  \def\el@output##1{\ifcat$##1$\else\immediate\write\html@output{##1}\fi}}%
{}%
{\cal@get@appointments\cal@get@events}%
{\relax%
   \ifnum\dates@time@start>0\relax%
    \ifnum\dates@time@start=\dates@time@end%
      \protected@edef\cal@entry@text{%
        ^^J\space\space\space\space<LI>\thetimestart\space%
        \thelongtext}%
    \else%
      \protected@edef\cal@entry@text{%
        ^^J\space\space\space\space<LI>\thetimestart--\thetimeend\space%
        \thelongtext}%
    \fi%
  \else%
      \protected@edef\cal@entry@text{%
      ^^J<BR>\thelongtext}%
  \fi}%
{\ifcat$\theevents\theappointments$\else%
\el@item%
\fi%
\ifcat$\theevents$\else%
  \theevents%
\fi%
\ifcat$\theappointments$\else%
 ^^J\space\space\space\space<UL>%
 \theappointments%
 ^^J\space\space\space\space</UL>%
\fi}
%</htmlevent>
%    \end{macrocode}
% \subsection{HTML Month and Event List}
%    \begin{macrocode}
%<*htmlmonthevent>
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{hml}
          [1997/11/06 07:33:21 2.1.1.6 HTML calendar (Frank Bennett)]
\RequirePackage{hmonth}
\RequirePackage{hlist}
\newtoks\hml@one
\newtoks\hml@two
\def\htmlmonthlist#1#2{%
  \hml@one={#1}
  \hml@two={#2}
  \dateread{}}
\def\endhtmlmonthlist{%
  \ifnum\dates@subrange@start=0%
    \dates@subrange@start\dates@date%
    \dates@subrange@end\dates@date%
  \fi%
  \global\dates@date\dates@subrange@start%
  \global\dates@day=1\relax%
  \dates@fix%
  \cal@range@start\dates@date%
  \global\dates@date\dates@subrange@end%
  \caldate%
  \global\dates@day\dates@days%
  \dates@fix%
  \cal@range@end\dates@date%
  \global\dates@date=\cal@range@start
  \caldate
  \edef\hml@start{\theday\space\themonth\space\theyear\space}
  \global\dates@date=\cal@range@end
  \caldate
  \edef\hml@end{\theday\space\themonth\space\theyear}
  \edef\hml@range{\hml@start to \hml@end\space}
  \edef\hml@htmlmonth{\noexpand\begin{htmlmonth}{\the\hml@one}{\the\hml@two}}
  \edef\hml@htmllist{\noexpand\begin{htmllist}{\the\hml@one}{\the\hml@two}}
  \expandafter\hml@htmlmonth\hml@range\end{htmlmonth}
  \expandafter\hml@htmllist\hml@range\end{htmllist}x}
%<*htmlmonthevent>
%    \end{macrocode}
% \Finale \PrintChanges

