* ext.tex: documentation for extending, reference counts, and embedding
(formerly ../misc/{EXTENDING,REFCNT,EMBEDDING}). Also affects Makefile.
* text2latex.py: script to do part of the conversion from an plain ASCI
text file (in my particular style) to LaTeX.
(Chapter/section/subsection headers, and verbatim sections.)
* partparse.py, texipre.dat, fix.el, Makefile: Minor cleanup of latex ->
info conversion process (at least it works again, and with less
debugging output). Removed fix.sh.
* lib1.tex (section{Built-in Functions}): adapt description of str() and
repr() to new situation.
* lib3.tex (Module os): added exec*() variants.
* lib3.tex (Module posix): added execve().
* lib2.tex (Module array): documented reality; remove typecode and
itemsize, add byteswap, rename read/write to fromfile/tofile, and
re-alphabetized.
* lib1.tex (Built-in Functions): renamed bagof() to filter().
1993-11-05 10:45:11 -04:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import regex
|
1993-11-05 13:11:16 -04:00
|
|
|
import regsub
|
* ext.tex: documentation for extending, reference counts, and embedding
(formerly ../misc/{EXTENDING,REFCNT,EMBEDDING}). Also affects Makefile.
* text2latex.py: script to do part of the conversion from an plain ASCI
text file (in my particular style) to LaTeX.
(Chapter/section/subsection headers, and verbatim sections.)
* partparse.py, texipre.dat, fix.el, Makefile: Minor cleanup of latex ->
info conversion process (at least it works again, and with less
debugging output). Removed fix.sh.
* lib1.tex (section{Built-in Functions}): adapt description of str() and
repr() to new situation.
* lib3.tex (Module os): added exec*() variants.
* lib3.tex (Module posix): added execve().
* lib2.tex (Module array): documented reality; remove typecode and
itemsize, add byteswap, rename read/write to fromfile/tofile, and
re-alphabetized.
* lib1.tex (Built-in Functions): renamed bagof() to filter().
1993-11-05 10:45:11 -04:00
|
|
|
import string
|
|
|
|
import getopt
|
|
|
|
|
|
|
|
def main():
|
|
|
|
process(sys.stdin, sys.stdout)
|
|
|
|
|
|
|
|
dashes = regex.compile('^-+[ \t]*$')
|
|
|
|
equals = regex.compile('^=+[ \t]*$')
|
|
|
|
stars = regex.compile('^\*+[ \t]*$')
|
|
|
|
blank = regex.compile('^[ \t]*$')
|
|
|
|
indented = regex.compile('^\( *\t\| \)[ \t]*[^ \t]')
|
|
|
|
|
|
|
|
def process(fi, fo):
|
|
|
|
inverbatim = 0
|
|
|
|
line = '\n'
|
|
|
|
nextline = fi.readline()
|
|
|
|
while nextline:
|
|
|
|
prevline = line
|
|
|
|
line = nextline
|
|
|
|
nextline = fi.readline()
|
|
|
|
fmt = None
|
|
|
|
if dashes.match(nextline) >= 0:
|
|
|
|
fmt = '\\subsection{%s}\n'
|
|
|
|
elif equals.match(nextline) >= 0:
|
|
|
|
fmt = '\\section{%s}\n'
|
|
|
|
elif stars.match(nextline) >= 0:
|
|
|
|
fmt = '\\chapter{%s}\n'
|
|
|
|
if fmt:
|
|
|
|
nextline = '\n'
|
|
|
|
line = fmt % string.strip(line)
|
1993-11-05 13:11:16 -04:00
|
|
|
if '(' in line:
|
|
|
|
line = regsub.gsub('[a-zA-Z0-9_]+()',
|
|
|
|
'{\\\\tt \\0}', line)
|
* ext.tex: documentation for extending, reference counts, and embedding
(formerly ../misc/{EXTENDING,REFCNT,EMBEDDING}). Also affects Makefile.
* text2latex.py: script to do part of the conversion from an plain ASCI
text file (in my particular style) to LaTeX.
(Chapter/section/subsection headers, and verbatim sections.)
* partparse.py, texipre.dat, fix.el, Makefile: Minor cleanup of latex ->
info conversion process (at least it works again, and with less
debugging output). Removed fix.sh.
* lib1.tex (section{Built-in Functions}): adapt description of str() and
repr() to new situation.
* lib3.tex (Module os): added exec*() variants.
* lib3.tex (Module posix): added execve().
* lib2.tex (Module array): documented reality; remove typecode and
itemsize, add byteswap, rename read/write to fromfile/tofile, and
re-alphabetized.
* lib1.tex (Built-in Functions): renamed bagof() to filter().
1993-11-05 10:45:11 -04:00
|
|
|
elif inverbatim:
|
|
|
|
if blank.match(line) >= 0 and \
|
|
|
|
indented.match(nextline) < 0:
|
|
|
|
inverbatim = 0
|
|
|
|
fo.write('\\end{verbatim}\n')
|
|
|
|
else:
|
|
|
|
if indented.match(line) >= 0 and \
|
|
|
|
blank.match(prevline) >= 0:
|
|
|
|
inverbatim = 1
|
|
|
|
fo.write('\\begin{verbatim}\n')
|
|
|
|
if inverbatim:
|
|
|
|
line = string.expandtabs(line, 4)
|
1993-11-05 13:11:16 -04:00
|
|
|
elif not fmt and '(' in line:
|
|
|
|
line = regsub.gsub('[a-zA-Z0-9_]+()',
|
|
|
|
'\\\\code{\\0}', line)
|
* ext.tex: documentation for extending, reference counts, and embedding
(formerly ../misc/{EXTENDING,REFCNT,EMBEDDING}). Also affects Makefile.
* text2latex.py: script to do part of the conversion from an plain ASCI
text file (in my particular style) to LaTeX.
(Chapter/section/subsection headers, and verbatim sections.)
* partparse.py, texipre.dat, fix.el, Makefile: Minor cleanup of latex ->
info conversion process (at least it works again, and with less
debugging output). Removed fix.sh.
* lib1.tex (section{Built-in Functions}): adapt description of str() and
repr() to new situation.
* lib3.tex (Module os): added exec*() variants.
* lib3.tex (Module posix): added execve().
* lib2.tex (Module array): documented reality; remove typecode and
itemsize, add byteswap, rename read/write to fromfile/tofile, and
re-alphabetized.
* lib1.tex (Built-in Functions): renamed bagof() to filter().
1993-11-05 10:45:11 -04:00
|
|
|
fo.write(line)
|
|
|
|
|
|
|
|
#main()
|
|
|
|
process(open('ext.tex', 'r'), sys.stdout)
|