File: kb2lex.tex

package info (click to toggle)
tetex-french 4.02-1
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 3,572 kB
  • ctags: 137
  • sloc: ansic: 1,455; makefile: 74; csh: 43; sh: 31
file content (100 lines) | stat: -rw-r--r-- 4,765 bytes parent folder | download
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
% kb2lex.tex                               An idea of Bernard Gaulle 07/19/92
%                                                            V1.6 of 97/10/10
%                           Copyright GUTenberg-Bernard Gaulle as in french.doc
%
% Running this code will produce two files: kbtex7a8.lex and kbtex8a7.lex
% These files are the result of the understanding of xxx.kbc in which
% the user has specified the special 8-bit characters he is using via
% his own keyboard. "xxx" is generally provided by the file keyboard.dat. 
% A document typed in with this encoding can't be send
% to anyone else except people having exactly the same keyboard.
% kb2lex is a way to produce programs that will allow to translate .tex
% files from 8-bit to single 7-bit ASCII standard that everyone normally
% is able to use.
%
% Of course you need the (Unix) pgm "lex" to generate the appropriate pgms.
% But if you don't have it, I've given in this directory kbtex7a8.c and
% kb8a7.c that were produced on my machine with the default keyboard.dat.
%
%  1- Configurate your keyboard.dat to your input encoding ("xxx").
%     You can create your own keyboard.dat and even define new a xxx.kbc file.
%  2- TeX or LaTeX this file (with any TeX V3.14xxx engine)
%     if not OK go back to 1- for corrections (notice that it must run
%                                            with the distributed keyboard.dat)
%     All processed characters are displayed to your screen (and in the .log 
%     file). Check if no character is displayed in TeX hexadecimal format 
%     (^^xx). In which case, you must be aware that these will never be 
%     converted to 7-bit. Since you can't display it as usual on your screen
%     and probably you can't also input it asis, you should  chose to delete
%     them from  xxx.kbc. Do it and rerun this step.
%  3- Type in: 
%              (as i type in Unix but may need to be adapted...)
%              lex -v kb8to7.lex;cc -o kb8to7 lex.yy.c -ll
%         and: lex -v kb7to8.lex;cc -o kb7to8 lex.yy.c -ll;rm lex.yy.c
%     (if any pb on your platform try flex instead of lex)
%  4- Test kb7to8 and kb8to7 to your modified kbto.tex file:
%              kb7to8 <kbto.tex
%              kb8to7 <kbto.tex
%  5- Copy the pgms kb8to7 and kb7to8 
%     in a public (/local/bin) directory so they will be available for 
%     everybody.
%
%%
%%      checksum        = "40935 100 556 4765"
%%
\global\newlinechar`\^^J%
\newif\ifLEX\LEXtrue
\let\ifLEXhic\iftrue% for any debugging
\newwrite\kbseven\immediate\openout\kbseven=kb8to7.lex
\newwrite\kbeight\immediate\openout\kbeight=kb7to8.lex
%%%% Check if we can output 8bit without translation to ^^codes
{\catcode`\@=11
\def\@tempc{%
\ifEightBitOutput\else%
\message{^^J -47- i must stop because your TeX engine is unable to 
         generate 8bit output codes, sorry!}
\fi%
\stop}
\ifx\EightBitOuputfalse\undefined\else\expandafter\@tempc\fi%
\global\let\@tempc=\undefined% so if someone use it...
}
\message{^^J -40- Writing kb8to7.lex and kb7to8.lex}
{\catcode`\%=11
\immediate\write\kbseven{%% /* kb8to7.lex converts my 8-bit TeX documents 
                               to a standard 7-bit ASCII */}
\immediate\write\kbeight{%% /* kb7to8.lex converts std 7-bit ASCII TeX
                               documents to my prefered 8-bit */} 
}
\let\protect\empty% nothing need to be protect in the output
                             \def\tempfmt{lplain}%
                             \ifx\fmtname\tempfmt\else\def\tempfmt{LaTeX2e}\fi%
                             \ifx\fmtname\tempfmt%
\documentclass[titlepage]{article}
%\usepackage[T1]{fontenc}% l'encodage ne devrait rien changer
%\usepackage{keyboard}% see below
\nofiles
\begin{document} 
                                                          \fi
\ifx\undefined\makeatletter%
  \def\makeatletter{\catcode`\@=11\relax}\fi%...................\makeatletter
\ifx\undefined\makeatother%
  \def\makeatother{\catcode`\@=12\relax}\fi%....................\makeatother
\ifx\kbencoding\undefined%
\makeatletter%
     \def\kbencoding#1{%\makeatletter%
                       \def\@kbencoding{#1}\@@input kbconfig.tex %
                       %\makeatother
                      }%
\makeatother
\fi%
\catcode`@=11% if coming from plain
\input keyboard.dat % load it directly  with TeX 
\gdef\folio{}%
\message{-33- (CHECK the list for hexadecimal TeX codes you can't  display and
          must be eliminated from \@kbencoding.kbc)}
                                        \ifx\fmtname\tempfmt\def\tempa
{\end{document}}% LaTeX end
                                        \else\def\tempa{\csname bye\endcsname}
                                        \fi\tempa%
\endinput%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%