\nopagenumbers
\input makor2
\advance\hsize by-3in
\tolerance=8000 

%% The file PRIMER.TEX: typesetting Hebrew-English language primers.
%% =================================================================
%%
%% The output of this file should be regarded as a work in progress
%% rather than as a finished product.  It turns out to be unexpectedly
%% difficult to create TeX macros that handle this situation; that is,
%% the situation of (1) numbering lines in some fashion (often
%% desirable in language texts to make it easy to refer to the line),
%% and (2) placing an unknown word and its definition in the margin,
%% but placing this definition next to the appearance of the original
%% word in the source file.  The main reason for the difficulty lies
%% in the fact that in the transformation between Hebrew and English,
%% there are a few \catcode changes.  Category codes are often stamped
%% irrevocably on characters when TeX slurps up an input file, and so
%% agonizing care must be taken to deal with this problem.  One
%% approach is to write problem phrases out to a file and to then
%% re-read the file when the text is needed.  This works because text
%% read from a file can be assigned catcodes on the basis of the
%% context at the time this temp file is read.  Also, the current
%% macros work only for a portion of text.  Some additional work would
%% be necessary to typeset several pages-worth of primer.
%%
%% Directions for compiling: One of the output files of the process is
%% called primer.voc.  When you have made all your revisions, copy
%% primer.voc to a file called primer.v.  The macros expect this file
%% to be present.  The skeleton of operations would look something
%% like this:
%%   omega primer
%%   cp primer.voc primer.v
%%   omega primer
%%   odvips primer
%% (cp is the Unix 'copy' command; your operating system may use
%% something different.)
%%
%% Anyone interested in pursuing these issues further is invited to
%% get in touch with me.
%%
%% ---Alan Hoenig
%% ahoenig@suffolk.lib.ny.us
%%
%% 4 Oct 2002

%% SOme fonts...
\hfontdef{QAL}{osheb2}{16pt}
\hfontdef{HDEFAULTFONT}{osheb2}{12pt}
\hfontdef{Qal}{osheb2}{8pt}
\font\qalrm=pacr9t at 7pt 
\font\xxx=cmsy10 at 8pt 
\baselineskip=15pt 

%% Macros for formatting this primer page...
\def\category#1{\ifcase\catcode`#1
        escape\or bgroup\or egroup\or math\or
        align\or endline\or parameter\or superscript\or
        otherchar\or active\or comment\or invalid\fi}
\def\HINDENT{\noindent\textdir TRT}
\newbox\xxxbox 
\setbox\xxxbox=\hbox{\xxx\char14}
\newdimen\dingwd \dingwd = \wd\xxxbox 
\def\DING#1{\raise#1\copy\xxxbox }
%% POOR MAN'S BOLD (from the TeXbook) is useful in cases where a genuine
%% bold-face font is not available, such as osheb2
\newbox\pmbbox
\def\PMB#1{\setbox\pmbbox=\hbox{#1}% for larger fonts
  \kern-.015em\copy\pmbbox\kern-\wd\pmbbox
  \kern.03em\copy\pmbbox\kern-\wd\pmbbox
  \kern-.015em\raise.025em\box\pmbbox }

%% Some macros in the .voc temporary file...
\def\VF{\hsize=6.5pc \leftskip=.5pc \parindent=0pt
        \noindent}
\let\BG=\bgroup\let\EG=\egroup \def\Q{\ \qalrm\clearocplists}
\let\eg=\endgraf

%% Reading the voc file...
\newread\vin \newwrite\vout
\immediate\openin\vin=\jobname.v
\newif\ifvocabfile \vocabfiletrue
\ifeof\vin \vocabfilefalse \immediate\closein\vin \fi

%% Preparing the voc file...
\immediate\openout\vout=\jobname.voc
\def\VOCAB#1#2{\DING{3.3pt}\mark{#2}% use the English text as a mark
  \bgroup\let\[=0\let\]=0\catcode`\^=\LETTER \catcode`\_=\LETTER
  \let\hfont=0\let\qalrm=0\let\Q=0\let\X=0\let\edef=0%
  \let\csname=0\let\endcsname=0\let\Q=0%
  \immediate\write\vout{%
      \hbox\BG\[\hfont{Qal}#1 \]\EG\Q #2\ }\egroup}

%% Output shenanigans...

\newbox\partialpage 
\newdimen\savedvsize \savedvsize=\vsize
\newtoks\savedoutput \savedoutput=\output
\newdimen\savedprevdepth \savedprevdepth=\prevdepth

\newcount\currline \newcount\currtextline

\setbox4=\vbox\bgroup\noindent\[\hfont{QAL}ch:agiygath hau'aeroo.siyn sh^el
chayoothauh\CENTERLASTLINE\]\egroup

\setbox2=\vbox\bgroup\noindent\[\hfont{Qal}.svywn
lyvrkh.t\CENTERLASTLINE\]\egroup

\setbox0=\vbox{\noindent\PMB{\box4}\smallskip\box2\smallskip
  \hrule\smallskip}\dimen0=\ht0 \advance\dimen0 by\dp0
\currline=\dimen0 \divide\currline by\baselineskip \advance\currline
  by1

\box0
\output={\global\setbox\partialpage=\vbox{\unvbox255\unskip}}\vfill\break

\setbox2=\hbox{\[\hfont{QAL}l\]}
\topskip=\ht2 
\vsize=\topskip \currtextline = 1
\newcount\scr 
\def\testlinedp{\advance\dimen0 by-\savelinedp
  \ifdim\dimen0>0pt \scr=\dimen0 \dimen0=1sp \divide\scr by \dimen0
  \showthe\scr\fi}
\newcount\everyfewlines \everyfewlines = 2
\def\printlinenumber{\scr=\currtextline \divide\scr by\everyfewlines
\multiply\scr by\everyfewlines 
\ifnum\scr=\currtextline\llap{\qalrm\the\currtextline\hskip.5pc}\fi
   \global\advance\currtextline by 1}
\newbox\vobox \newwrite\tst 
\def\iwrite{\immediate\write}\def\iopenout{\immediate\openout}
\def\icloseout{\immediate\closeout}
\def\iread{\immediate\read}\def\iopenin{\immediate\openin}
\def\iclosein{\immediate\closein}
\ifvocabfile
        \iopenin\vin=\jobname.v
\else
        \message{You're missing \jobname.v! Help...}
\fi
\def\getvocab{\iread\vin to\temp % but catcodes are frozen, so...
        \iopenout\tst=\jobname.tst
        \bgroup
                \let\BG=0\let\[=0\let\]=0\let\hfont=0\let\EG=0\let\Q=0%
                \iwrite\tst{\temp}%
        \egroup
        \icloseout\tst
        \input \jobname.tst}
\def\getvocabdef{\edef\One{\topmark}\edef\Two{\firstmark}%
        \edef\Three{\botmark}\ifx\One\Two % no word defs; do nothing
        \G\setbox\vobox=\vtop to\topskip\BG\baselineskip=7pt
  \else \G\setbox\vobox=\vtop to\topskip\BG\baselineskip=7pt
        \noindent\raggedright\getvocab
  \fi}
\def\testforsecondvocab{\ifx\Two\Three % only one word on that line
        \else \hfill\break\getvocab\fi
        \endgraf\vss\EG\dp\vobox=0pt}
\output={\ifnum\currtextline<15 % assumes 15 lines in our display
        \global\setbox\partialpage=\vbox{\unvbox\partialpage
            \getvocabdef\testforsecondvocab
                \line{\printlinenumber\box255
                \rlap{\box\vobox}}}\else
        \shipout\vbox{\unvbox\partialpage \unvbox255}\fi
}
\noindent\['eth ch:agiygath
\VOCAB{'rw.syn}{engagement}%
hau'aeroo.siyn 
sh^el chayoothauh qauv'`oo
bim'hiyrooth, 'ach:araey sh^ehats'`iyriym hOdiy`oo `al kaukh'
pith'\/'Om lahOriym.\HPAR

\newdimen\hparindent \hparindent = 1pc
\def\MYHEBREW{\HEBREW\hskip\hparindent}

\HINDENT \MYHEBREW
ch:amiysh^auh-`au^saur yaumiym lif'naey hach:agiygauh, 
`:adayin lo'
chaush^av 'iysh^ `al 
\VOCAB{vwshh}{shame}%
haboosh^auh 
\VOCAB{`lwl}{liable, likely}%
sh^e`au{l}ool .sabauh men'd'l
l'hauviy\/' `al koolaum.\HPAR

\HINDENT\MYHEBREW koolaum hauyoo `:a.sooqiym: 
`aur'khoo \VOCAB{rshymh}{list}r'sh^iymOth sh^el hau'Or'chiym, 
hama\/':akhauliym,
hakaeliym sh^eyaesh^ l'haukhiyn,
hash^'khaeniym sh^emookhauniym la`:azOr, hamauthaunOth sh^echayoothauh
m'vaqesh^eth l'qabael.\HPAR

\HINDENT\MYHEBREW belauh, 'imauhh sh^el chayoothauh, hibiy.tauh babayith
\VOCAB{nvhl}{be frightened}w'niv'h:alauh.
\HPAR

\HINDENT\MYHEBREW\null\hskip-\dingwd\VOCAB{khthm}{stain}hak'thaumiym `al 
\VOCAB{vdy rfwd}{upholstery}badaey
hauripood 
nir'\/'oo lauhh qOf'tsiym lau`ayin, 
hawiylOnOth k'vaur y'sh^auniym, 
`al n'yar haqiyr bach:adar hau'Okhel
rO\/'iym 'eth ha.siymauniym sh^el haki.s''Oth.
\HPAR

\HINDENT\MYHEBREW w'khaukh' nO.s'fauh gam r'sh^iymauh sh^el ch:anooyOth
l'vadaey ripood
\VOCAB{v`l-mqtsw`}{professional}ool'va`:alaey-miq'tsO`a.
\HPAR

\HINDENT\MYHEBREW b'thOkh' kaul haura`ash^ niz'k'rauh belauh sh^ehiy^'
`adayin lo' hech'liy.tauh 'aeyzO ^sim'lauh thaukhiyn l'`ats'mauhh
lach:agiygauh. 
\HPAR\]\vfill\break

\output={\shipout\vbox{\unvbox\partialpage \unvbox255}}\vfill\break

\bye
