annotate Tools/scripts/texi2html.py @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents 01ae962df885
children 02c5045d5b4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1 #! /usr/bin/env python
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # Convert GNU texinfo files into HTML, one file per node.
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 # Based on Texinfo 2.14.
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
5 # Usage: texi2html [-d] [-d] [-c] inputfile outputdirectory
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 # The input file must be a complete texinfo file, e.g. emacs.texi.
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 # This creates many files (one per info node) in the output directory,
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 # overwriting existing files of the same name. All files created have
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 # ".html" as their extension.
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 # XXX To do:
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 # - handle @comment*** correctly
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 # - handle @xref {some words} correctly
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 # - handle @ftable correctly (items aren't indexed?)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 # - handle @itemx properly
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 # - handle @exdent properly
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 # - add links directly to the proper line from indices
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 # - check against the definitive list of @-cmds; we still miss (among others):
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 # - @defindex (hard)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 # - @c(omment) in the middle of a line (rarely used)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 # - @this* (not really needed, only used in headers anyway)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 # - @today{} (ever used outside title page?)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
25 # More consistent handling of chapters/sections/etc.
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
26 # Lots of documentation
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
27 # Many more options:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
28 # -top designate top node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
29 # -links customize which types of links are included
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
30 # -split split at chapters or sections instead of nodes
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
31 # -name Allow different types of filename handling. Non unix systems
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
32 # will have problems with long node names
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
33 # ...
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
34 # Support the most recent texinfo version and take a good look at HTML 3.0
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
35 # More debugging output (customizable) and more fexible error handling
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
36 # How about icons ?
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 import os
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 import string
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
40 import re
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
41
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 MAGIC = '\\input texinfo'
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
43
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
44 cmprog = re.compile('^@([a-z]+)([ \t]|$)') # Command (line-oriented)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
45 blprog = re.compile('^[ \t]*$') # Blank line
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
46 kwprog = re.compile('@[a-z]+') # Keyword (embedded, usually
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
47 # with {} args)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
48 spprog = re.compile('[\n@{}&<>]') # Special characters in
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 9309
diff changeset
49 # running text
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
50 #
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
51 # menu item (Yuck!)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
52 miprog = re.compile('^\* ([^:]*):(:|[ \t]*([^\t,\n.]+)([^ \t\n]*))[ \t\n]*')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
53
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
54
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 9309
diff changeset
55
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
56 class HTMLNode:
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
57 """Some of the parser's functionality is separated into this class.
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
58
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
59 A Node accumulates its contents, takes care of links to other Nodes
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
60 and saves itself when it is finished and all links are resolved.
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
61 """
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
62
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
63 DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
64
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
65 type = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
66 cont = ''
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
67 epilogue = '</BODY></HTML>\n'
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
68
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
69 def __init__(self, dir, name, topname, title, next, prev, up):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
70 self.dirname = dir
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
71 self.name = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
72 if topname:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
73 self.topname = topname
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
74 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
75 self.topname = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
76 self.title = title
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
77 self.next = next
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
78 self.prev = prev
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
79 self.up = up
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
80 self.lines = []
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
81
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
82 def write(self, *lines):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
83 map(self.lines.append, lines)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
84
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
85 def flush(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
86 fp = open(self.dirname + '/' + makefile(self.name), 'w')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
87 fp.write(self.prologue)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
88 fp.write(self.text)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
89 fp.write(self.epilogue)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
90 fp.close()
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
91
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
92 def link(self, label, nodename, rel=None, rev=None):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
93 if nodename:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
94 if string.lower(nodename) == '(dir)':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
95 addr = '../dir.html'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
96 title = ''
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
97 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
98 addr = makefile(nodename)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
99 title = ' TITLE="%s"' % nodename
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
100 self.write(label, ': <A HREF="', addr, '"', \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
101 rel and (' REL=' + rel) or "", \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
102 rev and (' REV=' + rev) or "", \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
103 title, '>', nodename, '</A> \n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
104
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
105 def finalize(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
106 length = len(self.lines)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
107 self.text = string.joinfields(self.lines, '')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
108 self.lines = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
109 self.open_links()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
110 self.output_links()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
111 self.close_links()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
112 links = string.joinfields(self.lines, '')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
113 self.lines = []
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
114
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
115 self.prologue = (
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
116 self.DOCTYPE +
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
117 '\n<HTML><HEAD>\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
118 ' <!-- Converted with texi2html and Python -->\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
119 ' <TITLE>' + self.title + '</TITLE>\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
120 ' <LINK REL=Next HREF="'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
121 + makefile(self.next) + '" TITLE="' + self.next + '">\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
122 ' <LINK REL=Previous HREF="'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
123 + makefile(self.prev) + '" TITLE="' + self.prev + '">\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
124 ' <LINK REL=Up HREF="'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
125 + makefile(self.up) + '" TITLE="' + self.up + '">\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
126 '</HEAD><BODY>\n' +
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
127 links)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
128 if length > 20:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
129 self.epilogue = '<P>\n%s</BODY></HTML>\n' % links
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
130
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
131 def open_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
132 self.write('<HR>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
133
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
134 def close_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
135 self.write('<HR>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
136
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
137 def output_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
138 if self.cont != self.next:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
139 self.link(' Cont', self.cont)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
140 self.link(' Next', self.next, rel='Next')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
141 self.link(' Prev', self.prev, rel='Previous')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
142 self.link(' Up', self.up, rel='Up')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
143 if self.name <> self.topname:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
144 self.link(' Top', self.topname)
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
145
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
146
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
147 class HTML3Node(HTMLNode):
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
148
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
149 DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 3//EN//3.0">'
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
150
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
151 def open_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
152 self.write('<DIV CLASS=Navigation>\n <HR>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
153
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
154 def close_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
155 self.write(' <HR>\n</DIV>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
156
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
157
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
158 class TexinfoParser:
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
159
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
160 COPYRIGHT_SYMBOL = "&copy;"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
161 FN_ID_PATTERN = "(%(id)s)"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
162 FN_SOURCE_PATTERN = '<A NAME=footnoteref%(id)s' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
163 ' HREF="#footnotetext%(id)s">' \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
164 + FN_ID_PATTERN + '</A>'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
165 FN_TARGET_PATTERN = '<A NAME=footnotetext%(id)s' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
166 ' HREF="#footnoteref%(id)s">' \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
167 + FN_ID_PATTERN + '</A>\n%(text)s<P>\n'
4405
e528c0ace4e5 (texi2html.py): Added CLASS=Navigation attribute to DIV around top/bottom
Fred Drake <fdrake@acm.org>
parents: 4392
diff changeset
168 FN_HEADER = '\n<P>\n<HR NOSHADE SIZE=1 WIDTH=200>\n' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
169 '<STRONG><EM>Footnotes</EM></STRONG>\n<P>'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
170
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
171
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
172 Node = HTMLNode
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
173
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
174 # Initialize an instance
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
175 def __init__(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
176 self.unknown = {} # statistics about unknown @-commands
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
177 self.filenames = {} # Check for identical filenames
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
178 self.debugging = 0 # larger values produce more output
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
179 self.print_headers = 0 # always print headers?
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
180 self.nodefp = None # open file we're writing to
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
181 self.nodelineno = 0 # Linenumber relative to node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
182 self.links = None # Links from current node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
183 self.savetext = None # If not None, save text head instead
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
184 self.savestack = [] # If not None, save text head instead
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
185 self.dirname = 'tmp' # directory where files are created
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
186 self.includedir = '.' # directory to search @include files
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
187 self.nodename = '' # name of current node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
188 self.topname = '' # name of top node (first node seen)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
189 self.title = '' # title of this whole Texinfo tree
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
190 self.resetindex() # Reset all indices
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
191 self.contents = [] # Reset table of contents
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
192 self.numbering = [] # Reset section numbering counters
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
193 self.nofill = 0 # Normal operation: fill paragraphs
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
194 self.values={'html': 1} # Names that should be parsed in ifset
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
195 self.stackinfo={} # Keep track of state in the stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
196 # XXX The following should be reset per node?!
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
197 self.footnotes = [] # Reset list of footnotes
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
198 self.itemarg = None # Reset command used by @item
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
199 self.itemnumber = None # Reset number for @item in @enumerate
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
200 self.itemindex = None # Reset item index name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
201 self.node = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
202 self.nodestack = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
203 self.cont = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
204 self.includedepth = 0
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
205 # Set (output) directory name
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
206 def setdirname(self, dirname):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
207 self.dirname = dirname
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
208
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
209 # Set include directory name
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
210 def setincludedir(self, includedir):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
211 self.includedir = includedir
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
212
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
213 # Parse the contents of an entire file
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
214 def parse(self, fp):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
215 line = fp.readline()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
216 lineno = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
217 while line and (line[0] == '%' or blprog.match(line)):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
218 line = fp.readline()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
219 lineno = lineno + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
220 if line[:len(MAGIC)] <> MAGIC:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
221 raise SyntaxError, 'file does not begin with '+`MAGIC`
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
222 self.parserest(fp, lineno)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
223
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
224 # Parse the contents of a file, not expecting a MAGIC header
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
225 def parserest(self, fp, initial_lineno):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
226 lineno = initial_lineno
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
227 self.done = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
228 self.skip = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
229 self.stack = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
230 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
231 while not self.done:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
232 line = fp.readline()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
233 self.nodelineno = self.nodelineno + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
234 if not line:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
235 if accu:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
236 if not self.skip: self.process(accu)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
237 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
238 if initial_lineno > 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
239 print '*** EOF before @bye'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
240 break
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
241 lineno = lineno + 1
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
242 mo = cmprog.match(line)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
243 if mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
244 a, b = mo.span(1)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
245 cmd = line[a:b]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
246 if cmd in ('noindent', 'refill'):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
247 accu.append(line)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
248 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
249 if accu:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
250 if not self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
251 self.process(accu)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
252 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
253 self.command(line, mo)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
254 elif blprog.match(line) and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
255 'format' not in self.stack and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
256 'example' not in self.stack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
257 if accu:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
258 if not self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
259 self.process(accu)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
260 if self.nofill:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
261 self.write('\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
262 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
263 self.write('<P>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
264 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
265 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
266 # Append the line including trailing \n!
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
267 accu.append(line)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
268 #
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
269 if self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
270 print '*** Still skipping at the end'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
271 if self.stack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
272 print '*** Stack not empty at the end'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
273 print '***', self.stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
274 if self.includedepth == 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
275 while self.nodestack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
276 self.nodestack[-1].finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
277 self.nodestack[-1].flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
278 del self.nodestack[-1]
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
279
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
280 # Start saving text in a buffer instead of writing it to a file
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
281 def startsaving(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
282 if self.savetext <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
283 self.savestack.append(self.savetext)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
284 # print '*** Recursively saving text, expect trouble'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
285 self.savetext = ''
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
286
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
287 # Return the text saved so far and start writing to file again
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
288 def collectsavings(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
289 savetext = self.savetext
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
290 if len(self.savestack) > 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
291 self.savetext = self.savestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
292 del self.savestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
293 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
294 self.savetext = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
295 return savetext or ''
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
296
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
297 # Write text to file, or save it in a buffer, or ignore it
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
298 def write(self, *args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
299 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
300 text = string.joinfields(args, '')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
301 except:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
302 print args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
303 raise TypeError
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
304 if self.savetext <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
305 self.savetext = self.savetext + text
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
306 elif self.nodefp:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
307 self.nodefp.write(text)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
308 elif self.node:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
309 self.node.write(text)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
310 # Complete the current node -- write footnotes and close file
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
311 def endnode(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
312 if self.savetext <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
313 print '*** Still saving text at end of node'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
314 dummy = self.collectsavings()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
315 if self.footnotes:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
316 self.writefootnotes()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
317 if self.nodefp:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
318 if self.nodelineno > 20:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
319 self.write('<HR>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
320 [name, next, prev, up] = self.nodelinks[:4]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
321 self.link('Next', next)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
322 self.link('Prev', prev)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
323 self.link('Up', up)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
324 if self.nodename <> self.topname:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
325 self.link('Top', self.topname)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
326 self.write('<HR>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
327 self.write('</BODY>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
328 self.nodefp.close()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
329 self.nodefp = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
330 elif self.node:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
331 if not self.cont and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
332 (not self.node.type or \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
333 (self.node.next and self.node.prev and self.node.up)):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
334 self.node.finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
335 self.node.flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
336 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
337 self.nodestack.append(self.node)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
338 self.node = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
339 self.nodename = ''
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
340
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
341 # Process a list of lines, expanding embedded @-commands
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
342 # This mostly distinguishes between menus and normal text
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
343 def process(self, accu):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
344 if self.debugging > 1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
345 print self.skip, self.stack,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
346 if accu: print accu[0][:30],
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
347 if accu[0][30:] or accu[1:]: print '...',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
348 print
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
349 if self.stack and self.stack[-1] == 'menu':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
350 # XXX should be done differently
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
351 for line in accu:
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
352 mo = miprog.match(line)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
353 if not mo:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
354 line = string.strip(line) + '\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
355 self.expand(line)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
356 continue
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
357 bgn, end = mo.span(0)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
358 a, b = mo.span(1)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
359 c, d = mo.span(2)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
360 e, f = mo.span(3)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
361 g, h = mo.span(4)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
362 label = line[a:b]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
363 nodename = line[c:d]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
364 if nodename[0] == ':': nodename = label
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
365 else: nodename = line[e:f]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
366 punct = line[g:h]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
367 self.write(' <LI><A HREF="',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
368 makefile(nodename),
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
369 '">', nodename,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
370 '</A>', punct, '\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
371 self.expand(line[end:])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
372 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
373 text = string.joinfields(accu, '')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
374 self.expand(text)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
375
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
376 # Write a string, expanding embedded @-commands
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
377 def expand(self, text):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
378 stack = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
379 i = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
380 n = len(text)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
381 while i < n:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
382 start = i
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
383 mo = spprog.search(text, i)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
384 if mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
385 i = mo.start()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
386 else:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
387 self.write(text[start:])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
388 break
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
389 self.write(text[start:i])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
390 c = text[i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
391 i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
392 if c == '\n':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
393 self.write('\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
394 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
395 if c == '<':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
396 self.write('&lt;')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
397 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
398 if c == '>':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
399 self.write('&gt;')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
400 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
401 if c == '&':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
402 self.write('&amp;')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
403 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
404 if c == '{':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
405 stack.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
406 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
407 if c == '}':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
408 if not stack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
409 print '*** Unmatched }'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
410 self.write('}')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
411 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
412 cmd = stack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
413 del stack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
414 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
415 method = getattr(self, 'close_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
416 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
417 self.unknown_close(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
418 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
419 method()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
420 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
421 if c <> '@':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
422 # Cannot happen unless spprog is changed
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
423 raise RuntimeError, 'unexpected funny '+`c`
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
424 start = i
18781
01ae962df885 Use string.ascii_letters instead of string.letters (SF bug #226706).
Fred Drake <fdrake@acm.org>
parents: 15930
diff changeset
425 while i < n and text[i] in string.ascii_letters: i = i+1
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
426 if i == start:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
427 # @ plus non-letter: literal next character
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
428 i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
429 c = text[start:i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
430 if c == ':':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
431 # `@:' means no extra space after
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
432 # preceding `.', `?', `!' or `:'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
433 pass
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
434 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
435 # `@.' means a sentence-ending period;
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
436 # `@@', `@{', `@}' quote `@', `{', `}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
437 self.write(c)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
438 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
439 cmd = text[start:i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
440 if i < n and text[i] == '{':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
441 i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
442 stack.append(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
443 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
444 method = getattr(self, 'open_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
445 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
446 self.unknown_open(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
447 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
448 method()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
449 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
450 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
451 method = getattr(self, 'handle_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
452 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
453 self.unknown_handle(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
454 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
455 method()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
456 if stack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
457 print '*** Stack not empty at para:', stack
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
458
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
459 # --- Handle unknown embedded @-commands ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
460
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
461 def unknown_open(self, cmd):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
462 print '*** No open func for @' + cmd + '{...}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
463 cmd = cmd + '{'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
464 self.write('@', cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
465 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
466 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
467 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
468 self.unknown[cmd] = self.unknown[cmd] + 1
2705
9ed45dbf2765 mods by Gregor Schmid -- very nice!
Guido van Rossum <guido@python.org>
parents: 2551
diff changeset
469
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
470 def unknown_close(self, cmd):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
471 print '*** No close func for @' + cmd + '{...}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
472 cmd = '}' + cmd
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
473 self.write('}')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
474 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
475 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
476 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
477 self.unknown[cmd] = self.unknown[cmd] + 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
478
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
479 def unknown_handle(self, cmd):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
480 print '*** No handler for @' + cmd
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
481 self.write('@', cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
482 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
483 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
484 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
485 self.unknown[cmd] = self.unknown[cmd] + 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
486
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
487 # XXX The following sections should be ordered as the texinfo docs
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
488
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
489 # --- Embedded @-commands without {} argument list --
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
490
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
491 def handle_noindent(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
492
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
493 def handle_refill(self): pass
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
494
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
495 # --- Include file handling ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
496
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
497 def do_include(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
498 file = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
499 file = os.path.join(self.includedir, file)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
500 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
501 fp = open(file, 'r')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
502 except IOError, msg:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
503 print '*** Can\'t open include file', `file`
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
504 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
505 if self.debugging:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
506 print '--> file', `file`
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
507 save_done = self.done
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
508 save_skip = self.skip
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
509 save_stack = self.stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
510 self.includedepth = self.includedepth + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
511 self.parserest(fp, 0)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
512 self.includedepth = self.includedepth - 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
513 fp.close()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
514 self.done = save_done
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
515 self.skip = save_skip
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
516 self.stack = save_stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
517 if self.debugging:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
518 print '<-- file', `file`
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
519
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
520 # --- Special Insertions ---
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
521
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
522 def open_dmn(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
523 def close_dmn(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
524
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
525 def open_dots(self): self.write('...')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
526 def close_dots(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
527
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
528 def open_bullet(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
529 def close_bullet(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
530
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
531 def open_TeX(self): self.write('TeX')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
532 def close_TeX(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
533
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
534 def handle_copyright(self): self.write(self.COPYRIGHT_SYMBOL)
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
535 def open_copyright(self): self.write(self.COPYRIGHT_SYMBOL)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
536 def close_copyright(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
537
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
538 def open_minus(self): self.write('-')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
539 def close_minus(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
540
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
541 # --- Special Glyphs for Examples ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
542
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
543 def open_result(self): self.write('=&gt;')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
544 def close_result(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
545
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
546 def open_expansion(self): self.write('==&gt;')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
547 def close_expansion(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
548
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
549 def open_print(self): self.write('-|')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
550 def close_print(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
551
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
552 def open_error(self): self.write('error--&gt;')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
553 def close_error(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
554
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
555 def open_equiv(self): self.write('==')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
556 def close_equiv(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
557
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
558 def open_point(self): self.write('-!-')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
559 def close_point(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
560
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
561 # --- Cross References ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
562
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
563 def open_pxref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
564 self.write('see ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
565 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
566 def close_pxref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
567 self.makeref()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
568
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
569 def open_xref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
570 self.write('See ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
571 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
572 def close_xref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
573 self.makeref()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
574
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
575 def open_ref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
576 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
577 def close_ref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
578 self.makeref()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
579
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
580 def open_inforef(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
581 self.write('See info file ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
582 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
583 def close_inforef(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
584 text = self.collectsavings()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
585 args = string.splitfields(text, ',')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
586 n = len(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
587 for i in range(n):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
588 args[i] = string.strip(args[i])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
589 while len(args) < 3: args.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
590 node = args[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
591 file = args[2]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
592 self.write('`', file, '\', node `', node, '\'')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
593
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
594 def makeref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
595 text = self.collectsavings()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
596 args = string.splitfields(text, ',')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
597 n = len(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
598 for i in range(n):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
599 args[i] = string.strip(args[i])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
600 while len(args) < 5: args.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
601 nodename = label = args[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
602 if args[2]: label = args[2]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
603 file = args[3]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
604 title = args[4]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
605 href = makefile(nodename)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
606 if file:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
607 href = '../' + file + '/' + href
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
608 self.write('<A HREF="', href, '">', label, '</A>')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
609
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
610 # --- Marking Words and Phrases ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
611
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
612 # --- Other @xxx{...} commands ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
613
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
614 def open_(self): pass # Used by {text enclosed in braces}
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
615 def close_(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
616
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
617 open_asis = open_
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
618 close_asis = close_
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
619
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
620 def open_cite(self): self.write('<CITE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
621 def close_cite(self): self.write('</CITE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
622
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
623 def open_code(self): self.write('<CODE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
624 def close_code(self): self.write('</CODE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
625
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
626 def open_t(self): self.write('<TT>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
627 def close_t(self): self.write('</TT>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
628
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
629 def open_dfn(self): self.write('<DFN>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
630 def close_dfn(self): self.write('</DFN>')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
631
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
632 def open_emph(self): self.write('<EM>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
633 def close_emph(self): self.write('</EM>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
634
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
635 def open_i(self): self.write('<I>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
636 def close_i(self): self.write('</I>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
637
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
638 def open_footnote(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
639 # if self.savetext <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
640 # print '*** Recursive footnote -- expect weirdness'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
641 id = len(self.footnotes) + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
642 self.write(self.FN_SOURCE_PATTERN % {'id': `id`})
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
643 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
644
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
645 def close_footnote(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
646 id = len(self.footnotes) + 1
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
647 self.footnotes.append((id, self.collectsavings()))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
648
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
649 def writefootnotes(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
650 self.write(self.FN_HEADER)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
651 for id, text in self.footnotes:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
652 self.write(self.FN_TARGET_PATTERN
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
653 % {'id': `id`, 'text': text})
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
654 self.footnotes = []
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
655
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
656 def open_file(self): self.write('<CODE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
657 def close_file(self): self.write('</CODE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
658
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
659 def open_kbd(self): self.write('<KBD>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
660 def close_kbd(self): self.write('</KBD>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
661
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
662 def open_key(self): self.write('<KEY>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
663 def close_key(self): self.write('</KEY>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
664
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
665 def open_r(self): self.write('<R>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
666 def close_r(self): self.write('</R>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
667
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
668 def open_samp(self): self.write('`<SAMP>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
669 def close_samp(self): self.write('</SAMP>\'')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
670
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
671 def open_sc(self): self.write('<SMALLCAPS>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
672 def close_sc(self): self.write('</SMALLCAPS>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
673
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
674 def open_strong(self): self.write('<STRONG>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
675 def close_strong(self): self.write('</STRONG>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
676
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
677 def open_b(self): self.write('<B>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
678 def close_b(self): self.write('</B>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
679
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
680 def open_var(self): self.write('<VAR>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
681 def close_var(self): self.write('</VAR>')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
682
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
683 def open_w(self): self.write('<NOBREAK>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
684 def close_w(self): self.write('</NOBREAK>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
685
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
686 def open_url(self): self.startsaving()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
687 def close_url(self):
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
688 text = self.collectsavings()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
689 self.write('<A HREF="', text, '">', text, '</A>')
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
690
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
691 def open_email(self): self.startsaving()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
692 def close_email(self):
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
693 text = self.collectsavings()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
694 self.write('<A HREF="mailto:', text, '">', text, '</A>')
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
695
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
696 open_titlefont = open_
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
697 close_titlefont = close_
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
698
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
699 def open_small(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
700 def close_small(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
701
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
702 def command(self, line, mo):
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
703 a, b = mo.span(1)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
704 cmd = line[a:b]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
705 args = string.strip(line[b:])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
706 if self.debugging > 1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
707 print self.skip, self.stack, '@' + cmd, args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
708 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
709 func = getattr(self, 'do_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
710 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
711 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
712 func = getattr(self, 'bgn_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
713 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
714 # don't complain if we are skipping anyway
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
715 if not self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
716 self.unknown_cmd(cmd, args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
717 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
718 self.stack.append(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
719 func(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
720 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
721 if not self.skip or cmd == 'end':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
722 func(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
723
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
724 def unknown_cmd(self, cmd, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
725 print '*** unknown', '@' + cmd, args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
726 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
727 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
728 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
729 self.unknown[cmd] = self.unknown[cmd] + 1
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
730
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
731 def do_end(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
732 words = string.split(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
733 if not words:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
734 print '*** @end w/o args'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
735 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
736 cmd = words[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
737 if not self.stack or self.stack[-1] <> cmd:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
738 print '*** @end', cmd, 'unexpected'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
739 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
740 del self.stack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
741 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
742 func = getattr(self, 'end_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
743 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
744 self.unknown_end(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
745 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
746 func()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
747
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
748 def unknown_end(self, cmd):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
749 cmd = 'end ' + cmd
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
750 print '*** unknown', '@' + cmd
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
751 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
752 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
753 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
754 self.unknown[cmd] = self.unknown[cmd] + 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
755
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
756 # --- Comments ---
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
757
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
758 def do_comment(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
759 do_c = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
760
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
761 # --- Conditional processing ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
762
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
763 def bgn_ifinfo(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
764 def end_ifinfo(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
765
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
766 def bgn_iftex(self, args): self.skip = self.skip + 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
767 def end_iftex(self): self.skip = self.skip - 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
768
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
769 def bgn_ignore(self, args): self.skip = self.skip + 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
770 def end_ignore(self): self.skip = self.skip - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
771
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
772 def bgn_tex(self, args): self.skip = self.skip + 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
773 def end_tex(self): self.skip = self.skip - 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
774
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
775 def do_set(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
776 fields = string.splitfields(args, ' ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
777 key = fields[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
778 if len(fields) == 1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
779 value = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
780 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
781 value = string.joinfields(fields[1:], ' ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
782 self.values[key] = value
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
783 print self.values
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
784
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
785 def do_clear(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
786 self.values[args] = None
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
787
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
788 def bgn_ifset(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
789 if args not in self.values.keys() \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
790 or self.values[args] is None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
791 self.skip = self.skip + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
792 self.stackinfo[len(self.stack)] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
793 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
794 self.stackinfo[len(self.stack)] = 0
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
795 def end_ifset(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
796 print self.stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
797 print self.stackinfo
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
798 if self.stackinfo[len(self.stack) + 1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
799 self.skip = self.skip - 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
800 del self.stackinfo[len(self.stack) + 1]
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
801
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
802 def bgn_ifclear(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
803 if args in self.values.keys() \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
804 and self.values[args] is not None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
805 self.skip = self.skip + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
806 self.stackinfo[len(self.stack)] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
807 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
808 self.stackinfo[len(self.stack)] = 0
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
809
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
810 end_ifclear = end_ifset
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
811
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
812 def open_value(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
813 self.startsaving()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
814
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
815 def close_value(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
816 key = self.collectsavings()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
817 if key in self.values.keys():
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
818 self.write(self.values[key])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
819 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
820 print '*** Undefined value: ', key
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
821
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
822 # --- Beginning a file ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
823
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
824 do_finalout = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
825 do_setchapternewpage = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
826 do_setfilename = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
827
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
828 def do_settitle(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
829 print args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
830 self.startsaving()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
831 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
832 self.title = self.collectsavings()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
833 print self.title
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
834 def do_parskip(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
835
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
836 # --- Ending a file ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
837
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
838 def do_bye(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
839 self.endnode()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
840 self.done = 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
841
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
842 # --- Title page ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
843
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
844 def bgn_titlepage(self, args): self.skip = self.skip + 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
845 def end_titlepage(self): self.skip = self.skip - 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
846 def do_shorttitlepage(self, args): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
847
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
848 def do_center(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
849 # Actually not used outside title page...
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
850 self.write('<H1>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
851 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
852 self.write('</H1>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
853 do_title = do_center
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
854 do_subtitle = do_center
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
855 do_author = do_center
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
856
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
857 do_vskip = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
858 do_vfill = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
859 do_smallbook = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
860
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
861 do_paragraphindent = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
862 do_setchapternewpage = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
863 do_headings = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
864 do_footnotestyle = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
865
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
866 do_evenheading = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
867 do_evenfooting = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
868 do_oddheading = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
869 do_oddfooting = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
870 do_everyheading = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
871 do_everyfooting = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
872
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
873 # --- Nodes ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
874
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
875 def do_node(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
876 self.endnode()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
877 self.nodelineno = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
878 parts = string.splitfields(args, ',')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
879 while len(parts) < 4: parts.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
880 for i in range(4): parts[i] = string.strip(parts[i])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
881 self.nodelinks = parts
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
882 [name, next, prev, up] = parts[:4]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
883 file = self.dirname + '/' + makefile(name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
884 if self.filenames.has_key(file):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
885 print '*** Filename already in use: ', file
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
886 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
887 if self.debugging: print '--- writing', file
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
888 self.filenames[file] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
889 # self.nodefp = open(file, 'w')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
890 self.nodename = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
891 if self.cont and self.nodestack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
892 self.nodestack[-1].cont = self.nodename
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
893 if not self.topname: self.topname = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
894 title = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
895 if self.title: title = title + ' -- ' + self.title
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
896 self.node = self.Node(self.dirname, self.nodename, self.topname,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
897 title, next, prev, up)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
898
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
899 def link(self, label, nodename):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
900 if nodename:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
901 if string.lower(nodename) == '(dir)':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
902 addr = '../dir.html'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
903 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
904 addr = makefile(nodename)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
905 self.write(label, ': <A HREF="', addr, '" TYPE="',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
906 label, '">', nodename, '</A> \n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
907
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
908 # --- Sectioning commands ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
909
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
910 def popstack(self, type):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
911 if (self.node):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
912 self.node.type = type
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
913 while self.nodestack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
914 if self.nodestack[-1].type > type:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
915 self.nodestack[-1].finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
916 self.nodestack[-1].flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
917 del self.nodestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
918 elif self.nodestack[-1].type == type:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
919 if not self.nodestack[-1].next:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
920 self.nodestack[-1].next = self.node.name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
921 if not self.node.prev:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
922 self.node.prev = self.nodestack[-1].name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
923 self.nodestack[-1].finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
924 self.nodestack[-1].flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
925 del self.nodestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
926 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
927 if type > 1 and not self.node.up:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
928 self.node.up = self.nodestack[-1].name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
929 break
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
930
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
931 def do_chapter(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
932 self.heading('H1', args, 0)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
933 self.popstack(1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
934
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
935 def do_unnumbered(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
936 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
937 self.popstack(1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
938 def do_appendix(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
939 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
940 self.popstack(1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
941 def do_top(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
942 self.heading('H1', args, -1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
943 def do_chapheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
944 self.heading('H1', args, -1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
945 def do_majorheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
946 self.heading('H1', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
947
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
948 def do_section(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
949 self.heading('H1', args, 1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
950 self.popstack(2)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
951
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
952 def do_unnumberedsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
953 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
954 self.popstack(2)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
955 def do_appendixsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
956 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
957 self.popstack(2)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
958 do_appendixsection = do_appendixsec
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
959 def do_heading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
960 self.heading('H1', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
961
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
962 def do_subsection(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
963 self.heading('H2', args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
964 self.popstack(3)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
965 def do_unnumberedsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
966 self.heading('H2', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
967 self.popstack(3)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
968 def do_appendixsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
969 self.heading('H2', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
970 self.popstack(3)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
971 def do_subheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
972 self.heading('H2', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
973
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
974 def do_subsubsection(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
975 self.heading('H3', args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
976 self.popstack(4)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
977 def do_unnumberedsubsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
978 self.heading('H3', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
979 self.popstack(4)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
980 def do_appendixsubsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
981 self.heading('H3', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
982 self.popstack(4)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
983 def do_subsubheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
984 self.heading('H3', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
985
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
986 def heading(self, type, args, level):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
987 if level >= 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
988 while len(self.numbering) <= level:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
989 self.numbering.append(0)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
990 del self.numbering[level+1:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
991 self.numbering[level] = self.numbering[level] + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
992 x = ''
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
993 for i in self.numbering:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
994 x = x + `i` + '.'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
995 args = x + ' ' + args
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
996 self.contents.append((level, args, self.nodename))
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
997 self.write('<', type, '>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
998 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
999 self.write('</', type, '>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1000 if self.debugging or self.print_headers:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1001 print '---', args
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1002
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1003 def do_contents(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1004 # pass
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1005 self.listcontents('Table of Contents', 999)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1006
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1007 def do_shortcontents(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1008 pass
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1009 # self.listcontents('Short Contents', 0)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1010 do_summarycontents = do_shortcontents
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1011
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1012 def listcontents(self, title, maxlevel):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1013 self.write('<H1>', title, '</H1>\n<UL COMPACT PLAIN>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1014 prevlevels = [0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1015 for level, title, node in self.contents:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1016 if level > maxlevel:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1017 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1018 if level > prevlevels[-1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1019 # can only advance one level at a time
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1020 self.write(' '*prevlevels[-1], '<UL PLAIN>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1021 prevlevels.append(level)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1022 elif level < prevlevels[-1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1023 # might drop back multiple levels
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1024 while level < prevlevels[-1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1025 del prevlevels[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1026 self.write(' '*prevlevels[-1],
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1027 '</UL>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1028 self.write(' '*level, '<LI> <A HREF="',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1029 makefile(node), '">')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1030 self.expand(title)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1031 self.write('</A>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1032 self.write('</UL>\n' * len(prevlevels))
2705
9ed45dbf2765 mods by Gregor Schmid -- very nice!
Guido van Rossum <guido@python.org>
parents: 2551
diff changeset
1033
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1034 # --- Page lay-out ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1035
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1036 # These commands are only meaningful in printed text
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1037
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1038 def do_page(self, args): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1039
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1040 def do_need(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1041
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1042 def bgn_group(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1043 def end_group(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1044
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1045 # --- Line lay-out ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1046
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1047 def do_sp(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1048 if self.nofill:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1049 self.write('\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1050 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1051 self.write('<P>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1052
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1053 def do_hline(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1054 self.write('<HR>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1055
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1056 # --- Function and variable definitions ---
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1057
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1058 def bgn_deffn(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1059 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1060 self.do_deffnx(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1061
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1062 def end_deffn(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1063 self.write('</DL>\n')
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1064
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1065 def do_deffnx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1066 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1067 words = splitwords(args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1068 [category, name], rest = words[:2], words[2:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1069 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1070 for word in rest: self.expand(' ' + makevar(word))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1071 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1072 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1073 self.index('fn', name)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1074
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1075 def bgn_defun(self, args): self.bgn_deffn('Function ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1076 end_defun = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1077 def do_defunx(self, args): self.do_deffnx('Function ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1078
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1079 def bgn_defmac(self, args): self.bgn_deffn('Macro ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1080 end_defmac = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1081 def do_defmacx(self, args): self.do_deffnx('Macro ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1082
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1083 def bgn_defspec(self, args): self.bgn_deffn('{Special Form} ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1084 end_defspec = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1085 def do_defspecx(self, args): self.do_deffnx('{Special Form} ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1086
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1087 def bgn_defvr(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1088 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1089 self.do_defvrx(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1090
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1091 end_defvr = end_deffn
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1092
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1093 def do_defvrx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1094 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1095 words = splitwords(args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1096 [category, name], rest = words[:2], words[2:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1097 self.expand('@code{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1098 # If there are too many arguments, show them
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1099 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1100 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1101 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1102 self.index('vr', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1103
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1104 def bgn_defvar(self, args): self.bgn_defvr('Variable ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1105 end_defvar = end_defvr
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1106 def do_defvarx(self, args): self.do_defvrx('Variable ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1107
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1108 def bgn_defopt(self, args): self.bgn_defvr('{User Option} ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1109 end_defopt = end_defvr
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1110 def do_defoptx(self, args): self.do_defvrx('{User Option} ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1111
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1112 # --- Ditto for typed languages ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1113
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1114 def bgn_deftypefn(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1115 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1116 self.do_deftypefnx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1117
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1118 end_deftypefn = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1119
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1120 def do_deftypefnx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1121 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1122 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1123 [category, datatype, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1124 self.expand('@code{%s} @b{%s}' % (datatype, name))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1125 for word in rest: self.expand(' ' + makevar(word))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1126 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1127 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1128 self.index('fn', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1129
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1130
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1131 def bgn_deftypefun(self, args): self.bgn_deftypefn('Function ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1132 end_deftypefun = end_deftypefn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1133 def do_deftypefunx(self, args): self.do_deftypefnx('Function ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1134
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1135 def bgn_deftypevr(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1136 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1137 self.do_deftypevrx(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1138
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1139 end_deftypevr = end_deftypefn
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1140
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1141 def do_deftypevrx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1142 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1143 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1144 [category, datatype, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1145 self.expand('@code{%s} @b{%s}' % (datatype, name))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1146 # If there are too many arguments, show them
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1147 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1148 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1149 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1150 self.index('fn', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1151
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1152 def bgn_deftypevar(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1153 self.bgn_deftypevr('Variable ' + args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1154 end_deftypevar = end_deftypevr
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1155 def do_deftypevarx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1156 self.do_deftypevrx('Variable ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1157
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1158 # --- Ditto for object-oriented languages ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1159
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1160 def bgn_defcv(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1161 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1162 self.do_defcvx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1163
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1164 end_defcv = end_deftypevr
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1165
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1166 def do_defcvx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1167 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1168 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1169 [category, classname, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1170 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1171 # If there are too many arguments, show them
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1172 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1173 #self.expand(' -- %s of @code{%s}' % (category, classname))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1174 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1175 self.index('vr', '%s @r{on %s}' % (name, classname))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1176
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1177 def bgn_defivar(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1178 self.bgn_defcv('{Instance Variable} ' + args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1179 end_defivar = end_defcv
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1180 def do_defivarx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1181 self.do_defcvx('{Instance Variable} ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1182
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1183 def bgn_defop(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1184 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1185 self.do_defopx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1186
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1187 end_defop = end_defcv
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1188
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1189 def do_defopx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1190 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1191 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1192 [category, classname, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1193 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1194 for word in rest: self.expand(' ' + makevar(word))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1195 #self.expand(' -- %s of @code{%s}' % (category, classname))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1196 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1197 self.index('fn', '%s @r{on %s}' % (name, classname))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1198
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1199 def bgn_defmethod(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1200 self.bgn_defop('Method ' + args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1201 end_defmethod = end_defop
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1202 def do_defmethodx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1203 self.do_defopx('Method ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1204
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1205 # --- Ditto for data types ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1206
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1207 def bgn_deftp(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1208 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1209 self.do_deftpx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1210
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1211 end_deftp = end_defcv
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1212
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1213 def do_deftpx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1214 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1215 words = splitwords(args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1216 [category, name], rest = words[:2], words[2:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1217 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1218 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1219 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1220 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1221 self.index('tp', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1222
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1223 # --- Making Lists and Tables
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1224
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1225 def bgn_enumerate(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1226 if not args:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1227 self.write('<OL>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1228 self.stackinfo[len(self.stack)] = '</OL>\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1229 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1230 self.itemnumber = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1231 self.write('<UL>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1232 self.stackinfo[len(self.stack)] = '</UL>\n'
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1233 def end_enumerate(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1234 self.itemnumber = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1235 self.write(self.stackinfo[len(self.stack) + 1])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1236 del self.stackinfo[len(self.stack) + 1]
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1237
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1238 def bgn_itemize(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1239 self.itemarg = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1240 self.write('<UL>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1241 def end_itemize(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1242 self.itemarg = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1243 self.write('</UL>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1244
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1245 def bgn_table(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1246 self.itemarg = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1247 self.write('<DL>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1248 def end_table(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1249 self.itemarg = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1250 self.write('</DL>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1251
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1252 def bgn_ftable(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1253 self.itemindex = 'fn'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1254 self.bgn_table(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1255 def end_ftable(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1256 self.itemindex = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1257 self.end_table()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1258
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1259 def do_item(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1260 if self.itemindex: self.index(self.itemindex, args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1261 if self.itemarg:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1262 if self.itemarg[0] == '@' and self.itemarg[1:2] and \
18781
01ae962df885 Use string.ascii_letters instead of string.letters (SF bug #226706).
Fred Drake <fdrake@acm.org>
parents: 15930
diff changeset
1263 self.itemarg[1] in string.ascii_letters:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1264 args = self.itemarg + '{' + args + '}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1265 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1266 # some other character, e.g. '-'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1267 args = self.itemarg + ' ' + args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1268 if self.itemnumber <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1269 args = self.itemnumber + '. ' + args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1270 self.itemnumber = increment(self.itemnumber)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1271 if self.stack and self.stack[-1] == 'table':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1272 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1273 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1274 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1275 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1276 self.write('<LI>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1277 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1278 self.write(' ')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1279 do_itemx = do_item # XXX Should suppress leading blank line
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1280
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1281 # --- Enumerations, displays, quotations ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1282 # XXX Most of these should increase the indentation somehow
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1283
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1284 def bgn_quotation(self, args): self.write('<BLOCKQUOTE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1285 def end_quotation(self): self.write('</BLOCKQUOTE>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1286
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1287 def bgn_example(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1288 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1289 self.write('<PRE>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1290 def end_example(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1291 self.write('</PRE>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1292 self.nofill = self.nofill - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1293
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1294 bgn_lisp = bgn_example # Synonym when contents are executable lisp code
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1295 end_lisp = end_example
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1296
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1297 bgn_smallexample = bgn_example # XXX Should use smaller font
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1298 end_smallexample = end_example
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1299
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1300 bgn_smalllisp = bgn_lisp # Ditto
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1301 end_smalllisp = end_lisp
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1302
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1303 bgn_display = bgn_example
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1304 end_display = end_example
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1305
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1306 bgn_format = bgn_display
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1307 end_format = end_display
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1308
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1309 def do_exdent(self, args): self.expand(args + '\n')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1310 # XXX Should really mess with indentation
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1311
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1312 def bgn_flushleft(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1313 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1314 self.write('<PRE>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1315 def end_flushleft(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1316 self.write('</PRE>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1317 self.nofill = self.nofill - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1318
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1319 def bgn_flushright(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1320 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1321 self.write('<ADDRESS COMPACT>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1322 def end_flushright(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1323 self.write('</ADDRESS>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1324 self.nofill = self.nofill - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1325
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1326 def bgn_menu(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1327 self.write('<DIR>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1328 self.write(' <STRONG><EM>Menu</EM></STRONG><P>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1329 def end_menu(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1330 self.write('</DIR>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1331
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1332 def bgn_cartouche(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1333 def end_cartouche(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1334
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1335 # --- Indices ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1336
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1337 def resetindex(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1338 self.noncodeindices = ['cp']
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1339 self.indextitle = {}
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1340 self.indextitle['cp'] = 'Concept'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1341 self.indextitle['fn'] = 'Function'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1342 self.indextitle['ky'] = 'Keyword'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1343 self.indextitle['pg'] = 'Program'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1344 self.indextitle['tp'] = 'Type'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1345 self.indextitle['vr'] = 'Variable'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1346 #
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1347 self.whichindex = {}
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1348 for name in self.indextitle.keys():
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1349 self.whichindex[name] = []
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1350
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1351 def user_index(self, name, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1352 if self.whichindex.has_key(name):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1353 self.index(name, args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1354 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1355 print '*** No index named', `name`
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1356
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1357 def do_cindex(self, args): self.index('cp', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1358 def do_findex(self, args): self.index('fn', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1359 def do_kindex(self, args): self.index('ky', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1360 def do_pindex(self, args): self.index('pg', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1361 def do_tindex(self, args): self.index('tp', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1362 def do_vindex(self, args): self.index('vr', args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1363
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1364 def index(self, name, args):
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
1365 self.whichindex[name].append((args, self.nodename))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1366
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1367 def do_synindex(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1368 words = string.split(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1369 if len(words) <> 2:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1370 print '*** bad @synindex', args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1371 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1372 [old, new] = words
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1373 if not self.whichindex.has_key(old) or \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1374 not self.whichindex.has_key(new):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1375 print '*** bad key(s) in @synindex', args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1376 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1377 if old <> new and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1378 self.whichindex[old] is not self.whichindex[new]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1379 inew = self.whichindex[new]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1380 inew[len(inew):] = self.whichindex[old]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1381 self.whichindex[old] = inew
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1382 do_syncodeindex = do_synindex # XXX Should use code font
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1383
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1384 def do_printindex(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1385 words = string.split(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1386 for name in words:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1387 if self.whichindex.has_key(name):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1388 self.prindex(name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1389 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1390 print '*** No index named', `name`
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1391
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1392 def prindex(self, name):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1393 iscodeindex = (name not in self.noncodeindices)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1394 index = self.whichindex[name]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1395 if not index: return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1396 if self.debugging:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1397 print '--- Generating', self.indextitle[name], 'index'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1398 # The node already provides a title
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1399 index1 = []
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1400 junkprog = re.compile('^(@[a-z]+)?{')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1401 for key, node in index:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1402 sortkey = string.lower(key)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1403 # Remove leading `@cmd{' from sort key
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1404 # -- don't bother about the matching `}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1405 oldsortkey = sortkey
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1406 while 1:
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1407 mo = junkprog.match(sortkey)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1408 if not mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1409 break
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1410 i = mo.end()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1411 sortkey = sortkey[i:]
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
1412 index1.append((sortkey, key, node))
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1413 del index[:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1414 index1.sort()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1415 self.write('<DL COMPACT>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1416 prevkey = prevnode = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1417 for sortkey, key, node in index1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1418 if (key, node) == (prevkey, prevnode):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1419 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1420 if self.debugging > 1: print key, ':', node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1421 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1422 if iscodeindex: key = '@code{' + key + '}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1423 if key != prevkey:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1424 self.expand(key)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1425 self.write('\n<DD><A HREF="%s">%s</A>\n' % (makefile(node), node))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1426 prevkey, prevnode = key, node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1427 self.write('</DL>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1428
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1429 # --- Final error reports ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1430
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1431 def report(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1432 if self.unknown:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1433 print '--- Unrecognized commands ---'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1434 cmds = self.unknown.keys()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1435 cmds.sort()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1436 for cmd in cmds:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1437 print string.ljust(cmd, 20), self.unknown[cmd]
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1438
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1439
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1440 class TexinfoParserHTML3(TexinfoParser):
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1441
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1442 COPYRIGHT_SYMBOL = "&copy;"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1443 FN_ID_PATTERN = "[%(id)s]"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1444 FN_SOURCE_PATTERN = '<A ID=footnoteref%(id)s ' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1445 'HREF="#footnotetext%(id)s">' + FN_ID_PATTERN + '</A>'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1446 FN_TARGET_PATTERN = '<FN ID=footnotetext%(id)s>\n' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1447 '<P><A HREF="#footnoteref%(id)s">' + FN_ID_PATTERN \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1448 + '</A>\n%(text)s</P></FN>\n'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1449 FN_HEADER = '<DIV CLASS=footnotes>\n <HR NOSHADE WIDTH=200>\n' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1450 ' <STRONG><EM>Footnotes</EM></STRONG>\n <P>\n'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1451
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1452 Node = HTML3Node
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1453
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1454 def bgn_quotation(self, args): self.write('<BQ>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1455 def end_quotation(self): self.write('</BQ>\n')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1456
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1457 def bgn_example(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1458 # this use of <CODE> would not be legal in HTML 2.0,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1459 # but is in more recent DTDs.
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1460 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1461 self.write('<PRE CLASS=example><CODE>')
4507
18927abdc262 (texi2html.py): Minor improvement to HTML 3.0 output for code examples.
Fred Drake <fdrake@acm.org>
parents: 4405
diff changeset
1462 def end_example(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1463 self.write("</CODE></PRE>\n")
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1464 self.nofill = self.nofill - 1
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1465
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1466 def bgn_flushleft(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1467 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1468 self.write('<PRE CLASS=flushleft>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1469
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1470 def bgn_flushright(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1471 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1472 self.write('<DIV ALIGN=right CLASS=flushright><ADDRESS COMPACT>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1473 def end_flushright(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1474 self.write('</ADDRESS></DIV>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1475 self.nofill = self.nofill - 1
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1476
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1477 def bgn_menu(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1478 self.write('<UL PLAIN CLASS=menu>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1479 self.write(' <LH>Menu</LH>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1480 def end_menu(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1481 self.write('</UL>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1482
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1483
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1484 # Put @var{} around alphabetic substrings
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1485 def makevar(str):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1486 return '@var{'+str+'}'
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1487
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1488
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1489 # Split a string in "words" according to findwordend
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1490 def splitwords(str, minlength):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1491 words = []
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1492 i = 0
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1493 n = len(str)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1494 while i < n:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1495 while i < n and str[i] in ' \t\n': i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1496 if i >= n: break
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1497 start = i
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1498 i = findwordend(str, i, n)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1499 words.append(str[start:i])
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1500 while len(words) < minlength: words.append('')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1501 return words
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1502
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1503
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1504 # Find the end of a "word", matching braces and interpreting @@ @{ @}
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1505 fwprog = re.compile('[@{} ]')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1506 def findwordend(str, i, n):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1507 level = 0
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1508 while i < n:
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1509 mo = fwprog.search(str, i)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1510 if not mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1511 break
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1512 i = mo.start()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1513 c = str[i]; i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1514 if c == '@': i = i+1 # Next character is not special
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1515 elif c == '{': level = level+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1516 elif c == '}': level = level-1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1517 elif c == ' ' and level <= 0: return i-1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1518 return n
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1519
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1520
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1521 # Convert a node name into a file name
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1522 def makefile(nodename):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1523 return fixfunnychars(nodename) + '.html'
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1524
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1525
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1526 # Characters that are perfectly safe in filenames and hyperlinks
18781
01ae962df885 Use string.ascii_letters instead of string.letters (SF bug #226706).
Fred Drake <fdrake@acm.org>
parents: 15930
diff changeset
1527 goodchars = string.ascii_letters + string.digits + '!@-=+.'
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1528
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1529 # Replace characters that aren't perfectly safe by dashes
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1530 # Underscores are bad since Cern HTTPD treats them as delimiters for
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1531 # encoding times, so you get mismatches if you compress your files:
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1532 # a.html.gz will map to a_b.html.gz
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1533 def fixfunnychars(addr):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1534 i = 0
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1535 while i < len(addr):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1536 c = addr[i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1537 if c not in goodchars:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1538 c = '-'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1539 addr = addr[:i] + c + addr[i+1:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1540 i = i + len(c)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1541 return addr
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1542
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1543
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1544 # Increment a string used as an enumeration
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1545 def increment(s):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1546 if not s:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1547 return '1'
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1548 for sequence in string.digits, string.lowercase, string.uppercase:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1549 lastc = s[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1550 if lastc in sequence:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1551 i = string.index(sequence, lastc) + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1552 if i >= len(sequence):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1553 if len(s) == 1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1554 s = sequence[0]*2
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1555 if s == '00':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1556 s = '10'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1557 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1558 s = increment(s[:-1]) + sequence[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1559 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1560 s = s[:-1] + sequence[i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1561 return s
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1562 return s # Don't increment
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1563
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1564
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1565 def test():
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1566 import sys
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1567 debugging = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1568 print_headers = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1569 cont = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1570 html3 = 0
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 9309
diff changeset
1571
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1572 while sys.argv[1:2] == ['-d']:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1573 debugging = debugging + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1574 del sys.argv[1:2]
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1575 if sys.argv[1] == '-p':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1576 print_headers = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1577 del sys.argv[1]
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1578 if sys.argv[1] == '-c':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1579 cont = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1580 del sys.argv[1]
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1581 if sys.argv[1] == '-3':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1582 html3 = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1583 del sys.argv[1]
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1584 if len(sys.argv) <> 3:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1585 print 'usage: texi2html [-d [-d]] [-p] [-c] inputfile outputdirectory'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1586 sys.exit(2)
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1587
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1588 if html3:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1589 parser = TexinfoParserHTML3()
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1590 else:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1591 parser = TexinfoParser()
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1592 parser.cont = cont
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1593 parser.debugging = debugging
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1594 parser.print_headers = print_headers
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1595
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1596 file = sys.argv[1]
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1597 parser.setdirname(sys.argv[2])
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1598 if file == '-':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1599 fp = sys.stdin
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1600 else:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1601 parser.setincludedir(os.path.dirname(file))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1602 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1603 fp = open(file, 'r')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1604 except IOError, msg:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1605 print file, ':', msg
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1606 sys.exit(1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1607 parser.parse(fp)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1608 fp.close()
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1609 parser.report()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1610
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1611
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1612 if __name__ == "__main__":
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1613 test()