summaryrefslogtreecommitdiffstats
path: root/Doc/text2latex.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1998-03-06 21:16:47 (GMT)
committerFred Drake <fdrake@acm.org>1998-03-06 21:16:47 (GMT)
commit2023d38a58047b5971a8c2b099e92898ddeff1a8 (patch)
tree07ac3e5f2a1b3102c0f677004c37b47efc5ce92b /Doc/text2latex.py
parent0b0e7b56865aad1c08f8f7d5f32534a92e59e90c (diff)
downloadcpython-2023d38a58047b5971a8c2b099e92898ddeff1a8.zip
cpython-2023d38a58047b5971a8c2b099e92898ddeff1a8.tar.gz
cpython-2023d38a58047b5971a8c2b099e92898ddeff1a8.tar.bz2
Relocating file to Doc/tools.
Diffstat (limited to 'Doc/text2latex.py')
-rw-r--r--Doc/text2latex.py55
1 files changed, 0 insertions, 55 deletions
diff --git a/Doc/text2latex.py b/Doc/text2latex.py
deleted file mode 100644
index 93d0587..0000000
--- a/Doc/text2latex.py
+++ /dev/null
@@ -1,55 +0,0 @@
-import os
-import sys
-import regex
-import regsub
-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)
- if '(' in line:
- line = regsub.gsub('[a-zA-Z0-9_]+()',
- '{\\\\tt \\0}', line)
- 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)
- elif not fmt and '(' in line:
- line = regsub.gsub('[a-zA-Z0-9_]+()',
- '\\\\code{\\0}', line)
- fo.write(line)
-
-main()