9 process(sys
.stdin
, sys
.stdout
)
11 dashes
= regex
.compile('^-+[ \t]*$')
12 equals
= regex
.compile('^=+[ \t]*$')
13 stars
= regex
.compile('^\*+[ \t]*$')
14 blank
= regex
.compile('^[ \t]*$')
15 indented
= regex
.compile('^\( *\t\| \)[ \t]*[^ \t]')
20 nextline
= fi
.readline()
24 nextline
= fi
.readline()
26 if dashes
.match(nextline
) >= 0:
27 fmt
= '\\subsection{%s}\n'
28 elif equals
.match(nextline
) >= 0:
29 fmt
= '\\section{%s}\n'
30 elif stars
.match(nextline
) >= 0:
31 fmt
= '\\chapter{%s}\n'
34 line
= fmt
% string
.strip(line
)
36 line
= regsub
.gsub('[a-zA-Z0-9_]+()',
39 if blank
.match(line
) >= 0 and \
40 indented
.match(nextline
) < 0:
42 fo
.write('\\end{verbatim}\n')
44 if indented
.match(line
) >= 0 and \
45 blank
.match(prevline
) >= 0:
47 fo
.write('\\begin{verbatim}\n')
49 line
= string
.expandtabs(line
, 4)
50 elif not fmt
and '(' in line
:
51 line
= regsub
.gsub('[a-zA-Z0-9_]+()',
52 '\\\\code{\\0}', line
)