blob: 0e1c03862c6ddcf0eb409ef01818ba684d428590 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
%\tracingmacros=1
%\tracingonline=1
%\tolerance=10000
\font\ivrit=redis10
\hyphenchar\ivrit=-1
% The two lines below are taken from D.Knuth and P.MacKay
% TuGBoat vol.8,#1,page 14.
\def\hebrew#1{{\ivrit \reflect#1\empty\tcelfer }}
\def\reflect#1#2\tcelfer{\ifx#1\empty\else\reflect#2\tcelfer#1\fi}
\let\ivrswch=| % This is the Hebrew-Latin toggle
\def\ivrbar{\vrule height7pt width0.5pt} % This makes the vertical bar printabl
\newbox\ivrbox % The Hebrew box to test full line condition
\newbox\ivrstrbox % The box to hold the current Hebrew string
\setbox\ivrbox=\hbox{}
\setbox\ivrstrbox=\hbox{}
\newif\ifivrmd % Mode flag defaults to false
\def\ivrswitch{
\ifivrmd \message{Latin } % Toggle Hebrew on / Hebrew off
\hbox to\hsize{\hfil \unhbox\ivrstrbox \unskip} \par \ivrmdfalse
\else \message{Hebrew } \unskip \par \setbox\ivrstrbox=\hbox{}
\ivrmdtrue \parindent=0pt
\fi }
\def\ivrconcat#1#2{#1 #2}
\newif\ifivrscrboxfull % Verify if scratch box is full
\def\ivrcheckscrbox{
\setbox\ivrbox=\hbox{\ivrconcat{\blabla}{\unhcopy\ivrstrbox}}
\ivrscrboxfullfalse
\ifdim \hsize < \wd\ivrbox \ivrscrboxfulltrue \fi}
\newif\ifivrmorinp % Stuff waiting for processing?
\def\ivrmorinp{\ivrmorinptrue\ifeof\ivrfile\ivrmorinpfalse\fi}
\def\ivrplugword{\read\ivrfile to\blabla % Process a token from input file
\if\ivrswch\blabla \ivrswitch % Watch for a V-bar
\else
\ifivrmd \ivrcheckscrbox
% \immediate\write16{\blabla}
\ifivrscrboxfull \hbox to\hsize{\unhcopy\ivrstrbox \unskip}
\setbox\ivrstrbox=\hbox{\blabla}
\else \setbox\ivrstrbox=\hbox{\ivrconcat{\blabla}{\unhcopy\ivrstrbox}} \fi
\else \blabla \fi % Hebrew mode
\fi} % Switcher
\newread\ivrfile
\openin\ivrfile=hebtext.tex
\loop \ivrmorinp \ifivrmorinp \ivrplugword \repeat
\ifivrmd \ivrstr \fi
\closein\ivrfile
\bye
|