1%%%%%%%%%%%%%%%%%%%%%%%%%%% witbhs.sty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2% witbhs.sty
3% Scanner for a variant of the encoding used in the machine-readable
4% Biblia Hebraica Stuttgartensia
5% to install it, include it as a LaTeX package or style option "witbhs"
6% with Plain TeX, say "\input witbhs.sty"
7% to activate it, say "\setcode {witbhs}
8% 14.09.2001
9%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10% about the encoding contact: arian@th.vu.nl
11% Dr Arian J.C.Verheij
12% NWO / VU, Dpt. Biblical Studies & CS
13% De Boelelaan 1105, kr. 14A-38
14% NL 1081 HV Amsterdam
15%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16% (c) Klaus Lagally
17%     Institut fuer Informatik
18%     Universitaet Stuttgart
19%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20
21\ifx \bhsatcode \undefined \else \expandafter \endinput
22\fi % load only once
23
24\chardef \bhsatcode = \catcode`\@  \catcode`\@ = 11
25
26\a@ident {witbhs.sty} {3.10 read WITBHS Hebrew encoding} {14.09.2001}
27
28\UsePackage {bhslabel} % process BHS labels
29
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31% dynamic definitions for WITBHS Hebrew coding
32{\catcode `\^ 7 \catcode `\ =9 \catcode `\^^M=9 \catcode `\^^I=9
33\catcode `\"=12 \catcode `\>=11 \catcode `\&=12
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35\gdef \setwitbhs@codes {% activate and change some codes
36\globaldefs=1
37%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38\def \sc@A {a}   \def \sc@B {b}   \def \sc@C {x}   \def \sc@D {d}
39\def \sc@E {e} \def\sc@F{\n@xp\a@s} \def\sc@G{g}   \def \sc@H {h}
40\def \sc@I {i}   \def \sc@J {y}   \def \sc@K {k}   \def \sc@L {l}
41\def \sc@M {m}  \def \sc@N {n} \def\sc@O{\n@xp\a@o}\def \sc@P {p}
42\def \sc@Q {q}   \def \sc@R {r}   \def \sc@S {s}   \def \sc@T {t}
43\def \sc@U {u}   \def \sc@V {C}   \def \sc@W {w}   \def \sc@X {X}
44\def \sc@Y {S}   \def \sc@Z {z}   \def \sc@@ {A}
45\a@digits = {0123456789}     	\a@paren  = {[]}
46\a@first = {>+<##&$":.,*0123456789}
47\globaldefs=0 }
48%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49}% end of dynamic definitions for WITBHS
50%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51
52{\arab@codes \catcode `\> 11
53
54\gdef \witbhs@beg #1#2{% start WITBHS scanner
55\@ssimfalse \def \next {\witbhs@word #1#2}%
56\ifx #1\@\def \next {\sc@endscan #2}\else			% finished
57\ifx #2\@\def \next {\witbhs@testpara #1#2}\else
58\ifx #2?\def \next {\witbhs@testpara #1#2}\else
59\fi\fi\fi \next }
60
61\gdef \witbhs@word #1#2{% transform input into internal notation
62\case #1\of
63{      \@{\sc@endscan #2}
64	]{\witbhs@word }
65	/{\witbhs@word #2}
66	0{\witbhs@zero #2}
67	7{\witbhs@seven #2}
68 12345689{\witbhs@word }
69	?{\witbhs@query #2}
70	:{\witbhs@colon #2}
71%	O{\witbhs@O #2}
72	W{\witbhs@W #2}
73	*{\witbhs@star #2}
74%       #2{\witbhs@word #1|#2}
75\default {\witbhs@rest #1#2}
76}\endcase }
77
78\gdef \witbhs@rest #1#2{% transform input into internal notation
79     \def \next {\sc@put \witbhs@word #2}%
80\case #1\of
81{	.{\def \sc@char {\nxp \a@Zu }}
82	|{\def \sc@char {\nxp \a@U }}
83	'{\def \sc@char {'}}
84	>{\def \sc@char {Q}}
85	+{\def \sc@char {N}}	% phantom carrier
86	${\def \sc@char {M}}	% phantom carrier
87	={\def \sc@char {-}}	% medial form at end
88	<{\def \sc@char {P}}
89	&{\def \sc@char {\nxp \a@s }}
90	;{\def \sc@char {\nxp \a@E }}
91	-{\def \sc@char {B}}
92\default {\ifcat \nxp #1\relax \def \next {\sc@back #1{#2}}\else
93	\if \nxp #1\a@hash \def \sc@char {\nxp \a@S }\else
94	\ifcat \nxp #1a\edef \sc@char {\csname sc@#1\endcsname }%
95	\fi\fi\fi }
96}\endcase \next }
97
98%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99
100\gdef \witbhs@star {% qere / qetiv
101\def \sc@char {*}\sc@put \witbhs@word }
102
103\gdef \witbhs@colon #1{% shwa or chatef
104\def \next {\witbhs@word }%
105\ifx #1A\def \sc@char {\nxp \a@A }\else
106\ifx #1@\def \sc@char {\nxp \a@O }\else
107\ifx #1E\def \sc@char {\nxp \a@I }\else
108\def \sc@char {\nxp \a@e }\def \next {\witbhs@word #1}%
109\fi\fi\fi \sc@put \next }
110
111\iffalse
112\gdef \witbhs@O {% cholem or cholem waw
113\def \sc@char {\nxp \a@o }\sc@put \witbhs@word }
114\fi
115
116\gdef \witbhs@W #1{% waw or shureq
117\def \sc@char {w}\def \next {\witbhs@word #1}%
118\ifx #1.\def \sc@char {U}\def \next {\witbhs@word }%
119\fi \sc@put \next }
120
121\gdef \witbhs@seven #1{% meteg
122\def \next {\witbhs@word }%
123\ifx #15\def \sc@char {|}\sc@put \else
124\if\is@in@set #1\a@digits \else \def \next {\witbhs@word #1}%
125\fi\fi \next }
126
127\gdef \witbhs@zero #1{% sop pasuq and pasuq
128\def \next {\witbhs@word }%
129\ifx #10\def \sc@char {:}\sc@put \else
130%\ifx #15\def \sc@char {K}\sc@put \else
131\ifx #15\def \next {\witbhs@pasuq }\else
132\if\is@in@set #1\a@digits \else \def \next {\witbhs@word #1}%
133\fi\fi\fi \next }
134
135}% \arab@codes
136
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138
139\def \witbhs@testpara #1#2{% single initial P ?
140\ifx #1P\def \next {\witbhs@para #1#2}%
141\else \def \next {\witbhs@word #1#2}%
142\fi \next }
143
144\def \a@c@witbhspara {% small paragraph mark
145\putwordb@x {\small \heb@font \heb@testfont
146\act@cd '164 \advance \act@cd \heb@dsp
147\space \char \act@cd \space }\test@token }
148
149\def \a@c@pasuq {% verse division
150\putwordb@x {\small $\!|\!$}\test@token }
151
152\def \witbhs@para P#1\@ \@@ {% prepare paragraph mark
153\sc@back \witbhspara #1\@ \@@ }
154
155\def \witbhs@pasuq #1\@ \@@ {% prepare verse division
156\sc@back \pasuq #1\@ \@@ }
157
158%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159
160\def \witbhs@query #1\@ \@@ {% new line, push back the rest
161\ifnum \bhsmode = 1 \sc@back \\#1\@ \@@ \else % finish line
162\ifnum \bhsmode = 2 \sc@back \|#1\@ \@@ \else % stretch line
163			\sc@back #1\@ \@@     % start next word
164\fi\fi }
165
166\newcount \bhsmode	\bhsmode 0
167
168%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169
170\def \set@witbhs {% substitute the BHS scanner
171\let \sc@beg \witbhs@beg 	\let \sc@word \witbhs@word
172\let \sc@back \sc@@back         \let \sc@endscan \sc@@endscan
173\let \a@scan \a@@scan           \setwitbhs@codes
174\let \arab@codes \wit@arab@codes
175\let \unarab@codes \wit@unarab@codes
176\a@message {input encoding set to WITBHS conventions}}
177
178\xpa \def \xpa \sc@table \xpa {\sc@table % add the BHS encoding
179witbhs\set@witbhs }
180
181%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182
183\def \wit@arab@codes {% save and set special characters
184\csname originalTeX\endcsname
185\chardef \spc@de = \catcode`\ 	\catcode`\  = 10
186\chardef \dqc@de = \catcode`\"	\catcode`\" = \@other
187\chardef \lsc@de = \catcode`\<	\catcode`\< = \@other
188\chardef \gtc@de = \catcode`\>	\catcode`\> = 11
189\chardef \atc@de = \catcode`\@	\catcode`\@ = 11
190\chardef \hsc@de = \catcode`\#	\catcode`\# = \@other
191\chardef \amc@de = \catcode`\&	\catcode`\& = \@other
192\arab@charsubdefmax \charsubdefmax \charsubdefmax \m@ne }
193
194\def \wit@unarab@codes {% reset catcodes
195\catcode`\  = \spc@de \catcode`\< = \lsc@de \catcode`\" = \dqc@de
196\catcode`\#  = \hsc@de \catcode`\>  = \gtc@de \catcode`\@  = \atc@de
197\catcode`\&  = \amc@de
198\charsubdefmax \arab@charsubdefmax }
199
200{\catcode`\# = \@other \gdef \a@hash {#}}
201
202%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203
204\a@message {scanner for WITBHS encoding installed.}
205
206\catcode `\@ = \bhsatcode
207\endinput
208%%%%%%%%%%%%%%%%%%%%%%%% EOF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209
210