summaryrefslogtreecommitdiff
path: root/support/l2a
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/l2a
Initial commit
Diffstat (limited to 'support/l2a')
-rw-r--r--support/l2a/Makefile37
-rw-r--r--support/l2a/l2a.178
-rw-r--r--support/l2a/l2a.l385
-rw-r--r--support/l2a/l2a.pdfbin0 -> 43384 bytes
-rw-r--r--support/l2a/l2a.tex156
5 files changed, 656 insertions, 0 deletions
diff --git a/support/l2a/Makefile b/support/l2a/Makefile
new file mode 100644
index 0000000000..9aa6e3d113
--- /dev/null
+++ b/support/l2a/Makefile
@@ -0,0 +1,37 @@
+# Makefile for l2a 27 dec. 1988 [gh]
+#-----------------------------------------------------------------------------
+# Abstract:
+# Filter to detexify texts (handles both tex and latex).
+#
+# Compilation:
+# Tested using a Sun 3/50 and SunOS 3.5. Believed to be portable.
+#-----------------------------------------------------------------------------
+
+OBJ = l2a.o
+SHR = l2a.tex Makefile l2a.l l2a.1
+BINDIR = /local/bin
+MANDIR = /local/man
+
+l2a: $(OBJ)
+ cc -o l2a $(OBJ) -ll
+
+$(OBJ): l2a.l
+
+install:
+ cp l2a $(BINDIR)/l2a
+ cp l2a.1 $(MANDIR)/man1/l2a.1
+
+clean:
+ \rm -f l2a.txt l2a.c lex.yy.c l2a l2a.aux l2a.log $(OBJ) *~
+
+test:
+ \rm -f l2a.txt
+ l2a < l2a.tex > l2a.txt
+
+dvi:
+ latex l2a.tex
+
+shar:
+ shar -a $(SHR) > l2a.shar
+
+# EOF
diff --git a/support/l2a/l2a.1 b/support/l2a/l2a.1
new file mode 100644
index 0000000000..c758a9bcd8
--- /dev/null
+++ b/support/l2a/l2a.1
@@ -0,0 +1,78 @@
+.\" @(#)l2a.1 2.0 89/12/10 [gh]
+.\" Usage:
+.\" nroff -man l2a.1
+.TH L2A 1L "8 October 1990" "Version 1.0"
+.SH NAME
+l2a \- a LaTeX detergent
+.SH SYNOPSIS
+.B l2a
+[
+.B \-a
+]
+[
+.B \-h
+]
+[
+.B \-n
+]
+.SH DESCRIPTION
+.LP
+.B L2a
+is a filter to ``detexify'' texts. That is, it attempts to
+remove LaTeX markup commands, leaving only the body of
+text. It is intended to be used when journal editors request plain
+ASCII text for typesetting, or when you want to post a plain version
+of a LaTeX document on an electronic conference system.
+.PP
+.B L2a
+is a filter. Its default operation is to read from standard input
+(the keyboard) and write on standard output (the terminal).
+.SH OPTIONS
+.TP
+.B \-a
+Write out information about
+.B
+l2a.
+.TP
+.B \-h
+Write out a brief summary of options.
+.TP
+.B \-n
+Generate norwegian headings.
+.SH DIAGNOSTICS
+.PP
+Unrecognized markup commands generate an error message on the screen.
+There are no return code.
+
+.SH AUTHOR
+.PP
+Copyright \(co 1988, 1990 Gisle Hannemyr.
+.PP
+.B L2a
+may be freely distributed and copied, as long as this file
+is included in the distribution and that these statements
+about authorship and copyright is not altered or removed.
+.PP
+Bug reports, improvements, comments, suggestions and flames to:
+.ti +0.2i
+Snail: Gisle Hannemyr, Brageveien 3A, 0452 Oslo, Norway.
+.ti +0.2i
+Email: gisle.hannemyr@nr.no (EAN);
+.ti +0.9i
+gisle@ifi.uio.no (Internet);
+.ti +0.9i
+\|.\|.\|.\|!mcsun!ifi!gisle (UUCP);
+.ti +0.9i
+(and several BBS mailboxes).
+.SH BUGS
+.PP
+There is some Norwegian bias in
+.B l2a.
+In particular,
+there exists several national versions of the ISO 646 7-bit
+character set; but
+.B l2a
+bluntly assumes the standard Norwegian version of the ISO 646.
+.PP
+Only a subset of LaTeX is understood.
+.\" EOF
diff --git a/support/l2a/l2a.l b/support/l2a/l2a.l
new file mode 100644
index 0000000000..0e6b127191
--- /dev/null
+++ b/support/l2a/l2a.l
@@ -0,0 +1,385 @@
+ /* l2a.l -*- C -*-
+ +-----------------------------------------------------------------------------
+ | Abstract:
+ | Lex filter to detexify texts (handles really LaTeX, and a bit of TeX).
+ |
+ | Authorship:
+ | Copyright (c) 1988, 1990 Gisle Hannemyr.
+ |
+ | Permission is granted to hack, make and distribute copies of this program
+ | as long as this notice and the copyright notices are not removed.
+ | If you intend to distribute changed versions of this program, please make
+ | an entry in the "history" log (below) and mark the hacked lines with your
+ | initials. I maintain the program, and shall appreiciate copies of bug
+ | fixes and new versions.
+ | Flames, bug reports, comments and improvements to:
+ | snail: Gisle Hannemyr, Brageveien 3A, 0452 Oslo, Norway
+ | EAN: C=no;PRMD=uninett;O=nr;S=Hannemyr;G=Gisle (X.400 SA format)
+ | gisle.hannemyr@nr.no (RFC-822 format)
+ | Inet: gisle@ifi.uio.no
+ | UUCP: ...!mcsun!ifi!gisle
+ |
+ | History:
+ | 1.0 8 oct 90 [gh] Version 1 posted on comp.sources.misc.
+ | 0.0 27 dec 88 [gh] Started it.
+ |
+ | Bugs:
+ | * Works for my style of Latex, but will proably barf on other peoples
+ | files.
+ | * I can't see how \kill can be handled by lex only.
+ | * \cite is hacked. Should be fixed.
+ |
+ | Environment:
+ | None.
+ |
+ | Diagnostics:
+ | Prints plain error messages. Does not return error codes.
+ +---------------------------------------------------------------------------*/
+
+
+%{
+
+ /*---( start of user written lex prologue )---------------------------------*/
+
+
+#include <stdio.h>
+#include <string.h>
+
+#define VERSION "1.0"
+#define MAXEROR 100
+#define ENGLISH 0
+#define NORWEGIAN 1
+
+ void parseerror();
+ void bibhead();
+ void ptabular();
+ void pfigure();
+ void pcaption();
+ void phorline();
+ void pappendix();
+ void verbatim();
+ void pfotnote();
+ void footnote();
+
+
+ /*---( globals )------------------------------------------------------------*/
+
+char About[] = "\
+L2A is a filter to remove markup commands from LaTeX manuscripts.\n\n\
+Flames, bug reports, comments and improvements to:\n\
+ snail: Gisle Hannemyr, Brageveien 3A, 0452 Oslo, Norway\n\
+ EAN: C=no;PRMD=uninett;O=nr;S=Hannemyr;G=Gisle (X.400 SA format)\n\
+ gisle.hannemyr@nr.no (RFC-822 format)\n\
+ Inet: gisle@ifi.uio.no\n\
+ UUCP: ...!mcsun!ifi!gisle\n";
+
+char Usage[] = " Usage: l2a (options)\n\
+ Valid options:\n\
+\t-a -- about l2a\n\
+\t-h -- print this\n\
+\t-n -- norwegian text\n";
+
+int LineNo; /* Line number for debugging */
+int Enumber; /* Number for enumerate */
+int Fnumber = 0; /* Number for footnotes/endnotes */
+FILE *BFile; /* Bibliography file. */
+FILE *FNote; /* Temp. file for footnotes. */
+int Language = ENGLISH; /* language for inserted text */
+
+ /*---( end of user written lex prologue )-----------------------------------*/
+
+%}
+
+%START EN FN IT QU MM
+%n 1000
+%p 6000
+%a 4000
+%e 2000
+
+sp [ \t\n]*
+an [0-9a-zA-Z]+
+
+%%
+
+^"\\begin{thebibliography".* { bibhead(); }
+^"\\end{thebibliography}" { ; }
+^"\\bibitem["{an}"]{"{an}"}" { fputs(yytext,stderr); }
+"\\cite{"[^{\n]*"}" { yytext[0] = '('; yytext[strlen(yytext)] = ')'; printf("@CITE%s@ ",yytext); }
+"\\ref{"[^{\n]*"}" { yytext[0] = '('; yytext[strlen(yytext)] = ')'; printf("@REF%s@ ", yytext); }
+^"\\begin{enumerate}" { BEGIN EN; Enumber = 0; }
+^"\\end{enumerate}" { BEGIN 0; }
+^"\\begin{itemize}" { BEGIN IT; }
+^"\\end{itemize}" { BEGIN 0; }
+^"\\begin{quote}" { BEGIN QU; }
+^"\\end{quote}" { BEGIN 0; }
+^"\\begin{quotation}" { BEGIN QU; }
+^"\\end{quotation}" { BEGIN 0; }
+<IT>"\\item" { putchar('*'); }
+<EN>"\\item" { Enumber++; printf("%d)",Enumber); }
+"\\item" { putchar('+'); }
+<QU>\n { ECHO; LineNo++; fputs(" ",stdout); }
+<FN>. { footnote(); BEGIN 0; }
+"$" { BEGIN MM; }
+<MM>"$" { BEGIN 0; }
+<MM>"\\langle" { putchar('<'); }
+<MM>"\\rangle" { putchar('>'); }
+<MM>"\\backslash" { putchar('\\'); }
+^"\\begin{tabular".* { ptabular(); }
+^"\\end{tabular}" { phorline(); }
+^"\\begin{figure".* { pfigure(); }
+^"\\end{figure}" { phorline(); }
+^"\\caption{" { pcaption(); }
+"\\footnote" { Fnumber++; printf("<%d>",Fnumber); BEGIN FN; }
+"\\appendix" { pappendix(); }
+"\\verb" { verbatim(); }
+"\\'{e}"{sp} { putchar('e'); }
+\\ae{sp} { putchar('{'); }
+\\o{sp} { putchar('|'); }
+\\aa{sp} { putchar('}'); }
+\\AE{sp} { putchar('['); }
+\\O{sp} { putchar('\\'); }
+\\AA{sp} { putchar(']'); }
+"&" { putchar('\t'); }
+"\\>" { putchar('\t'); }
+"~" { putchar(' '); }
+"\\ " { putchar(' '); }
+"\\$" { putchar('$'); }
+"\\&" { putchar('&'); }
+"\\%" { putchar('%'); }
+"\\#" { putchar('#'); }
+"\\_" { putchar('_'); }
+"\\{" { putchar('{'); }
+"\\}" { putchar('{'); }
+"\\\\"{sp} { putchar('\n'); }
+^"\\vspace".* { putchar('\n'); }
+^"\\title" { putchar('\n'); }
+^"\\author" { putchar('\n'); }
+^"\\date".* { putchar('\n'); }
+^"\\maketitle" { putchar('\n'); }
+^"\\part" { putchar('\n'); }
+^"\\chapter" { putchar('\n'); }
+^"\\section" {;}
+^"\\subsection" {;}
+^"\\subsubsection" {;}
+^"\\paragraph" {;}
+^"\\subparagraph" {;}
+^"\\input lcustom" {;}
+^"\\documentstyle".* {;}
+^"\\pagenumbering".* {;}
+^"\\setcounter".* {;}
+^"\\newcommand".* {;}
+^"\\setlength".* {;}
+^"\\hyphenation".* {;}
+^"\\label".* {;}
+^"\\draftfalse" {;}
+^"\\begin{document}" {;}
+^"\\end{document}" {;}
+^"\\begin{sloppypar}" {;}
+^"\\end{sloppypar}" {;}
+^"\\begin{tabbing}" {;}
+^"\\end{tabbing}" {;}
+"\\TeX" { fputs("TeX", stdout); }
+"\\LaTeX" { fputs("LaTeX", stdout); }
+"\\LtoA" { fputs("L2A", stdout); }
+"\\ldots" { fputs("...", stdout); }
+"\\tiny" {;}
+"\\scriptsize" {;}
+"\\footnotesize" {;}
+"\\small" {;}
+"\\normalsize" {;}
+"\\large" {;}
+"\\Large" {;}
+"\\LARGE" {;}
+"\\huge" {;}
+"\\Huge" {;}
+"\\rm"{sp} {;}
+"\\em"{sp} {;}
+"\\bf"{sp} {;}
+"\\it"{sp} {;}
+"\\sl"{sp} {;}
+"\\sf"{sp} {;}
+"\\sc"{sp} {;}
+"\\tt"{sp} {;}
+"{" {;}
+"}" {;}
+"%".* {;}
+"\\-" {;}
+\n { ECHO; LineNo++; }
+. { ECHO; }
+"\\"[@A-Za-z]+ { parseerror(12,yytext); yytext[0] = '('; printf("@%s)@ ",yytext); }
+
+%%
+
+ /*---( routines )-----------------------------------------------------------*/
+
+ void parseerror(type,ss)
+ int type;
+ char *ss;
+ {
+ static errcnt = 0;
+
+ fprintf(stderr,"l2a: Error %d -- ",type);
+ switch (type) {
+ case 1: fputs("Instruction not recognized",stderr); break;
+ case 2: fputs("Wrong number of parameters",stderr); break;
+ case 3: fputs("Bad parameter received",stderr); break;
+ case 5: fputs("Unknown character set",stderr); break;
+ case 6: fputs("Position overflow",stderr); break;
+ case 10: fputs("Bogus output request",stderr); break;
+ case 11: fputs("Unimplemented command",stderr); break; /* No function */
+ case 12: fputs("Unrecognized markup command",stderr); break; /* No grammar */
+ case 13: fputs("Unhandled command",stderr); break; /* No semantic */
+ default: fputs("Unknown error (internal)",stderr); break;
+ } /* switch */
+ fprintf(stderr,"\n @ line %3d: \"%s\"\n",LineNo,ss);
+ errcnt++;
+ if (errcnt > MAXEROR) {
+ fputs(" Too many errors -- aborting\n",stderr);
+ exit(-1);
+ }
+ } /* parseerror */
+
+
+ void bibhead()
+ {
+ switch (Language) {
+ case ENGLISH: puts("\nReferences:"); break;
+ case NORWEGIAN: puts("\nLitteratur:"); break;
+ } /* switch */
+ } /* bibhead */
+
+
+ void ptabular()
+ {
+ switch (Language) {
+ case ENGLISH: puts("\t<<=============== NB! Typeset as table. NB! ================>>"); break;
+ case NORWEGIAN: puts("\t<<============== NB! Settes som tabell. NB! ================>>"); break;
+ } /* switch */
+ }
+
+
+ void pfigure()
+ {
+ switch (Language) {
+ case ENGLISH: puts("\t<<=========== NB! Please insert figure here. NB! ===========>>"); break;
+ case NORWEGIAN: puts("\t<<=========== NB! Figur skal settes inn her. NB! ===========>>"); break;
+ } /* switch */
+
+ }
+
+
+ void pcaption()
+ {
+ switch (Language) {
+ case ENGLISH: puts("\t --------------- Caption for figure or table: -------------"); break;
+ case NORWEGIAN: puts("\t --------------- Undertekst for bilde/tabell: -------------"); break;
+ } /* switch */
+ }
+
+
+ void phorline()
+ {
+ puts("<<==========================================================>>");
+ }
+
+
+ void pappendix()
+ {
+ switch (Language) {
+ case ENGLISH: puts("\n\nAPPENDIX\n========\n"); break;
+ case NORWEGIAN: puts("\n\nAPPENDIX\n========\n"); break;
+ } /* switch */
+ }
+
+ void verbatim()
+ {
+ int cc, ts;
+
+ ts = input();
+ for (;;) {
+ cc = input();
+ if (cc == ts) break;
+ putchar(cc);
+ } /* forever */
+ } /* verbatim */
+
+
+ void pfotnote()
+ {
+ switch (Language) {
+ case ENGLISH: puts("\n\nENDNOTES\n========\n"); break;
+ case NORWEGIAN: puts("\n\nNOTER\n=====\n"); break;
+ } /* switch */
+ }
+
+
+ void footnote()
+ {
+ int cc, be = 1;
+
+ fprintf(FNote,"<%d>: ", Fnumber);
+ while (be) {
+ cc = input();
+ if (cc == '{') be++;
+ else if (cc == '}') be--;
+ else putc(cc,FNote);
+ }
+ putc('\n',FNote);
+ putc('\n',FNote);
+ } /* footnote */
+
+
+ void bibitem()
+ {
+ int cc, be = 1;
+
+ fprintf(FNote,"<%d>: ", Fnumber);
+ while (be) {
+ cc = input();
+ if (cc == '{') be++;
+ else if (cc == '}') be--;
+ else putc(cc,FNote);
+ }
+ putc('\n',FNote);
+ putc('\n',FNote);
+ } /* footnote */
+
+ /*---( main )---------------------------------------------------------------*/
+
+ main (argc, argv)
+ int argc;
+ char **argv;
+ {
+
+ fprintf(stderr,"l2a, version %s -- Copyright (c) 1988, 1990 Gisle Hannemyr\n\n",VERSION);
+
+ argc--; argv++; /* skip program name */
+ while (argc && (**argv == '-')) {
+ (*argv)++; /* skip initial '-' */
+ switch (**argv) {
+ case 'a': fputs(About,stderr); exit(1);
+ case 'n': Language = NORWEGIAN; break;
+ default : fputs(Usage,stderr); exit(1);
+ } /* switch */
+ argc--; argv++;
+ } /* while options */
+ if (argc) { fputs(Usage,stderr); exit(1); }
+
+ BEGIN 0;
+ LineNo = 0;
+ FNote = fopen("FN.TMP","w");
+ /* BFile = fopen("references.tex","r"); */
+ yylex();
+
+ fclose(FNote);
+ if (Fnumber) {
+ char buff[80];
+ FNote = fopen("FN.TMP","r");
+ pfotnote();
+ while (fgets(buff,80,FNote)) fputs(buff,stdout);
+ } /* if */
+ unlink("FN.TMP");
+ puts("..EOF");
+ } /* main */
+
+ /*---( EOF lex input file )-------------------------------------------------*/
diff --git a/support/l2a/l2a.pdf b/support/l2a/l2a.pdf
new file mode 100644
index 0000000000..4e6d291371
--- /dev/null
+++ b/support/l2a/l2a.pdf
Binary files differ
diff --git a/support/l2a/l2a.tex b/support/l2a/l2a.tex
new file mode 100644
index 0000000000..8cdb63a3b5
--- /dev/null
+++ b/support/l2a/l2a.tex
@@ -0,0 +1,156 @@
+% run this through LaTeX or L2A -*- text -*-
+\documentstyle[12pt]{article}
+\pagenumbering{arabic}
+\setlength{\parindent}{0em}
+\setlength{\parskip}{1ex}
+\setcounter{secnumdepth}{0}
+\newcommand{\LtoA}{$L_{2}\cal A$}
+
+\begin{document}
+\title{\LtoA{} --- a LaTeX detergent}
+\author{Gisle Hannemyr \\ Norwegian Computing Center}
+\maketitle
+
+
+\section{Introduction}
+
+\LtoA\ is a filter to ``detexify'' texts. That is, it attempts to
+remove \LaTeX{} markup commands, leaving only the body of
+text. It is intended to be used when journal editors request plain
+ASCII text for typesetting, or when you want to post a plain version
+of a \LaTeX{} document on an electronic conference system.
+
+The author's address is:
+
+\begin{tabbing}
+UUCP: \= C=no;PRMD=uninett;O=nr;S=Hannemyr;G=Gisle \= (X.400 SA format) \kill
+ \> Gisle Hannemyr \\
+ \> Norwegian Computing Center \\
+ \> P.O.\ 114 Blindern \\
+ \> N-0314 Oslo 3 \\
+ \> Norway \\
+\\
+EAN: \> C=no;PRMD=uninett;O=nr;S=Hannemyr;G=Gisle \> (X.400 SA) \\
+ \> gisle.hannemyr@nr.no \> (RFC-822 ) \\
+Inet: \> gisle@ifi.uio.no \\
+UUCP: \> ...!mcsun!ifi!gisle \\
+\end{tabbing}
+
+
+\section{Description}
+
+\LtoA\ is a filter. It reads from standard input and writes to
+standard output. Typical usage would be:
+
+\begin{quote}
+\verb+l2a < foobar.tex > foobar.txt+
+\end{quote}
+
+It accepts three switches:
+
+{\tt -a} displays copyright etc.
+
+{\tt -h} displays brief help
+
+{\tt -n} uses Norwegian for texts etc.
+
+\section{Current state}
+
+\LtoA{} handles a subset \LaTeX{}. Most if the missing things I
+plan to add when I need them, but there are some features of \LaTeX{}
+(e.g.\ the $\backslash$kill function) that I can not see how can
+be handled with lex. Some manual polishing of the output will always
+be required.
+
+Some Norwegian bias is present in the source code. In particular
+some Scandinavian characters are translated to their counterparts
+in the Norwegian/Danish version of the ISO 7-bit character set.
+
+\LtoA{} works for my style of \LaTeX{} usage, but proably barf when fed
+other people's input. Consider the current state of \LtoA{} as a
+starting point: If you want to use it, then it is up to you to hack it
+into shape for your style. Btw.\ if you teach \LtoA{} new tricks, I
+would like to get back a copy of your enhancements\ldots
+
+% I plan to post \LtoA{} on the net in the near future. The current
+% version is a sort of ``beta'' release I mail to people who have shown
+% some interest in it. Any feedback you can give on the current version
+% will be appreciated.
+
+
+\section{Diagnostics}
+
+Unrecognized markup commands generate an error message on the screen.
+They are also retained in the text, enclosed in a brackets looking
+like this: {\tt @( )@}. This style of bracketing was chosen so that
+it should be simple to use a text editor to search the output file for
+these commands and edit the context they appear in.
+
+
+\section{Footnotes}
+
+\LtoA{} does not recognize such advanced concepts as a
+``page''. To avoid having do deal with pages, it will transform
+{\em footnotes} to {\em endnotes} (i.e.\ the footnotes are moved to
+the end of file, and renumbered). \LtoA{} will take care of the
+renumbering. It will insert numbers in angle brackets
+(e.g.\ $\langle{}3\rangle{}$) to number the footnotes in the text.
+
+
+\section{Tables, figures and captions}
+
+Tables and figures are stripped from the text. They are however
+clearly outlined with lines like this\footnote{The text inserted is
+actually dependent on which language you have selected.} in the text:
+
+{ \small
+\verb+<<=============== NB! Typeset as table. NB! ================>>+\\
+\verb+<<=========== NB! Please insert figure here. NB! ===========>>+
+}
+
+This should make the missing bits stand out to the dullest of editors.
+
+Captions for figures and tables are marked like this, with the actual
+text of the caption on the next line.
+
+{ \small
+\verb+ --------------- Caption for figure or table: -------------+
+}
+
+A line like this is used to mark when end of the point where the table
+or figure should be inserted.
+
+{ \small
+\verb+<<==========================================================>>+
+}
+
+Please equip the editor with scissors and glue and refer him/her to
+the paper version typeset with \LaTeX{} to find the actual
+figures and tables (or submit them on separate sheets of paper).
+
+
+\section*{To do}
+
+\LtoA{} is far from complete. It is very weak as far as mathematical
+mode are concerned (I don't write much mathematics).
+
+However, I hope the current version still are of some use. The lex
+source is easy to maintain. I suggest that users add the stuff they
+need when they need it.
+
+The most urgent thins on the ``to do'' list is functions to handle
+included files, cross-references, citations and bibliographies.
+
+\LtoA{} should also have an option to use an 8-bit character set
+(ISO~8859/1) for accented characters.
+
+Finally, I nurse a secret dream of having \LtoA{} generate
+{\em WordPerfect} or {\em Word} files preserving italics etc.
+
+Enjoy!
+
+\end{document}
+
+% EOF
+
+