annotate Tools/scripts/texi2html.py @ 49955:878d40468c4e legacy-trunk

Issue #4384: Added logging integration with warnings module using captureWarnings(). This change includes a NullHandler which does nothing; it will be of use to library developers who want to avoid the "No handlers could be found for logger XXX" message which can appear if the library user doesn't configure logging.
author Vinay Sajip <vinay_sajip@yahoo.co.uk>
date Wed, 03 Dec 2008 23:22:58 +0000
parents b1d142d71482
children 74c0a78114ae 6b18a095c2e7
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
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
35 # More debugging output (customizable) and more flexible error handling
3016
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
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
38 # rpyron 2002-05-07
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
39 # Robert Pyron <rpyron@alum.mit.edu>
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
40 # 1. BUGFIX: In function makefile(), strip blanks from the nodename.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
41 # This is necesary to match the behavior of parser.makeref() and
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
42 # parser.do_node().
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
43 # 2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
44 # it go away, rather than fix it)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
45 # 3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
46 # 4. Support added for:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
47 # @uref URL reference
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
48 # @image image file reference (see note below)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
49 # @multitable output an HTML table
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
50 # @vtable
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
51 # 5. Partial support for accents, to match MAKEINFO output
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
52 # 6. I added a new command-line option, '-H basename', to specify
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
53 # HTML Help output. This will cause three files to be created
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
54 # in the current directory:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
55 # `basename`.hhp HTML Help Workshop project file
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
56 # `basename`.hhc Contents file for the project
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
57 # `basename`.hhk Index file for the project
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
58 # When fed into HTML Help Workshop, the resulting file will be
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
59 # named `basename`.chm.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
60 # 7. A new class, HTMLHelp, to accomplish item 6.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
61 # 8. Various calls to HTMLHelp functions.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
62 # A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
63 # running this program, all referenced images must already exist
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
64 # in outputdirectory.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
65
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 import os
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
67 import sys
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 import string
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
69 import re
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
70
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 MAGIC = '\\input texinfo'
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
72
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
73 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
74 blprog = re.compile('^[ \t]*$') # Blank line
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
75 kwprog = re.compile('@[a-z]+') # Keyword (embedded, usually
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
76 # with {} args)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
77 spprog = re.compile('[\n@{}&<>]') # Special characters in
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 9309
diff changeset
78 # running text
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
79 #
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
80 # menu item (Yuck!)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
81 miprog = re.compile('^\* ([^:]*):(:|[ \t]*([^\t,\n.]+)([^ \t\n]*))[ \t\n]*')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
82 # 0 1 1 2 3 34 42 0
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
83 # ----- ---------- ---------
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
84 # -|-----------------------------
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
85 # -----------------------------------------------------
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
86
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
87
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
88
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 9309
diff changeset
89
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
90 class HTMLNode:
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
91 """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
92
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
93 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
94 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
95 """
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
96
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
97 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
98
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
99 type = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
100 cont = ''
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
101 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
102
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
103 def __init__(self, dir, name, topname, title, next, prev, up):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
104 self.dirname = dir
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
105 self.name = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
106 if topname:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
107 self.topname = topname
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
108 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
109 self.topname = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
110 self.title = title
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
111 self.next = next
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
112 self.prev = prev
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
113 self.up = up
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
114 self.lines = []
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
115
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
116 def write(self, *lines):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
117 map(self.lines.append, lines)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
118
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
119 def flush(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
120 fp = open(self.dirname + '/' + makefile(self.name), 'w')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
121 fp.write(self.prologue)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
122 fp.write(self.text)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
123 fp.write(self.epilogue)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
124 fp.close()
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
125
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
126 def link(self, label, nodename, rel=None, rev=None):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
127 if nodename:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
128 if nodename.lower() == '(dir)':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
129 addr = '../dir.html'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
130 title = ''
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
131 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
132 addr = makefile(nodename)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
133 title = ' TITLE="%s"' % nodename
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
134 self.write(label, ': <A HREF="', addr, '"', \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
135 rel and (' REL=' + rel) or "", \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
136 rev and (' REV=' + rev) or "", \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
137 title, '>', nodename, '</A> \n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
138
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
139 def finalize(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
140 length = len(self.lines)
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
141 self.text = ''.join(self.lines)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
142 self.lines = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
143 self.open_links()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
144 self.output_links()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
145 self.close_links()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
146 links = ''.join(self.lines)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
147 self.lines = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
148 self.prologue = (
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
149 self.DOCTYPE +
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
150 '\n<HTML><HEAD>\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
151 ' <!-- Converted with texi2html and Python -->\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
152 ' <TITLE>' + self.title + '</TITLE>\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
153 ' <LINK REL=Next HREF="'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
154 + makefile(self.next) + '" TITLE="' + self.next + '">\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
155 ' <LINK REL=Previous HREF="'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
156 + makefile(self.prev) + '" TITLE="' + self.prev + '">\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
157 ' <LINK REL=Up HREF="'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
158 + makefile(self.up) + '" TITLE="' + self.up + '">\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
159 '</HEAD><BODY>\n' +
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
160 links)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
161 if length > 20:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
162 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
163
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
164 def open_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
165 self.write('<HR>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
166
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
167 def close_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
168 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
169
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
170 def output_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
171 if self.cont != self.next:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
172 self.link(' Cont', self.cont)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
173 self.link(' Next', self.next, rel='Next')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
174 self.link(' Prev', self.prev, rel='Previous')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
175 self.link(' Up', self.up, rel='Up')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
176 if self.name <> self.topname:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
177 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
178
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
179
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
180 class HTML3Node(HTMLNode):
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
181
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
182 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
183
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
184 def open_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
185 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
186
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
187 def close_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
188 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
189
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
190
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
191 class TexinfoParser:
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
192
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
193 COPYRIGHT_SYMBOL = "&copy;"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
194 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
195 FN_SOURCE_PATTERN = '<A NAME=footnoteref%(id)s' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
196 ' HREF="#footnotetext%(id)s">' \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
197 + 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
198 FN_TARGET_PATTERN = '<A NAME=footnotetext%(id)s' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
199 ' HREF="#footnoteref%(id)s">' \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
200 + 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
201 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
202 '<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
203
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
204
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
205 Node = HTMLNode
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
206
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
207 # Initialize an instance
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
208 def __init__(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
209 self.unknown = {} # statistics about unknown @-commands
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
210 self.filenames = {} # Check for identical filenames
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
211 self.debugging = 0 # larger values produce more output
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
212 self.print_headers = 0 # always print headers?
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
213 self.nodefp = None # open file we're writing to
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
214 self.nodelineno = 0 # Linenumber relative to node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
215 self.links = None # Links from current node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
216 self.savetext = None # If not None, save text head instead
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
217 self.savestack = [] # If not None, save text head instead
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
218 self.htmlhelp = None # html help data
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
219 self.dirname = 'tmp' # directory where files are created
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
220 self.includedir = '.' # directory to search @include files
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
221 self.nodename = '' # name of current node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
222 self.topname = '' # name of top node (first node seen)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
223 self.title = '' # title of this whole Texinfo tree
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
224 self.resetindex() # Reset all indices
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
225 self.contents = [] # Reset table of contents
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
226 self.numbering = [] # Reset section numbering counters
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
227 self.nofill = 0 # Normal operation: fill paragraphs
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
228 self.values={'html': 1} # Names that should be parsed in ifset
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
229 self.stackinfo={} # Keep track of state in the stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
230 # XXX The following should be reset per node?!
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
231 self.footnotes = [] # Reset list of footnotes
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
232 self.itemarg = None # Reset command used by @item
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
233 self.itemnumber = None # Reset number for @item in @enumerate
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
234 self.itemindex = None # Reset item index name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
235 self.node = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
236 self.nodestack = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
237 self.cont = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
238 self.includedepth = 0
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
239
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
240 # Set htmlhelp helper class
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
241 def sethtmlhelp(self, htmlhelp):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
242 self.htmlhelp = htmlhelp
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
243
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
244 # Set (output) directory name
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
245 def setdirname(self, dirname):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
246 self.dirname = dirname
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
247
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
248 # Set include directory name
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
249 def setincludedir(self, includedir):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
250 self.includedir = includedir
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
251
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
252 # 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
253 def parse(self, fp):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
254 line = fp.readline()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
255 lineno = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
256 while line and (line[0] == '%' or blprog.match(line)):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
257 line = fp.readline()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
258 lineno = lineno + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
259 if line[:len(MAGIC)] <> MAGIC:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
260 raise SyntaxError, 'file does not begin with %r' % (MAGIC,)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
261 self.parserest(fp, lineno)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
262
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
263 # 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
264 def parserest(self, fp, initial_lineno):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
265 lineno = initial_lineno
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
266 self.done = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
267 self.skip = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
268 self.stack = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
269 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
270 while not self.done:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
271 line = fp.readline()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
272 self.nodelineno = self.nodelineno + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
273 if not line:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
274 if accu:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
275 if not self.skip: self.process(accu)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
276 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
277 if initial_lineno > 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
278 print '*** EOF before @bye'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
279 break
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
280 lineno = lineno + 1
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
281 mo = cmprog.match(line)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
282 if mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
283 a, b = mo.span(1)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
284 cmd = line[a:b]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
285 if cmd in ('noindent', 'refill'):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
286 accu.append(line)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
287 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
288 if accu:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
289 if not self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
290 self.process(accu)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
291 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
292 self.command(line, mo)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
293 elif blprog.match(line) and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
294 'format' not in self.stack and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
295 'example' not in self.stack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
296 if accu:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
297 if not self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
298 self.process(accu)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
299 if self.nofill:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
300 self.write('\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
301 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
302 self.write('<P>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
303 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
304 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
305 # Append the line including trailing \n!
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
306 accu.append(line)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
307 #
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
308 if self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
309 print '*** Still skipping at the end'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
310 if self.stack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
311 print '*** Stack not empty at the end'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
312 print '***', self.stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
313 if self.includedepth == 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
314 while self.nodestack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
315 self.nodestack[-1].finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
316 self.nodestack[-1].flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
317 del self.nodestack[-1]
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
318
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
319 # 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
320 def startsaving(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
321 if self.savetext <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
322 self.savestack.append(self.savetext)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
323 # print '*** Recursively saving text, expect trouble'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
324 self.savetext = ''
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
325
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
326 # 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
327 def collectsavings(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
328 savetext = self.savetext
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
329 if len(self.savestack) > 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
330 self.savetext = self.savestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
331 del self.savestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
332 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
333 self.savetext = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
334 return savetext or ''
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
335
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
336 # 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
337 def write(self, *args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
338 try:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
339 text = ''.join(args)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
340 except:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
341 print args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
342 raise TypeError
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
343 if self.savetext <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
344 self.savetext = self.savetext + text
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
345 elif self.nodefp:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
346 self.nodefp.write(text)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
347 elif self.node:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
348 self.node.write(text)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
349
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
350 # 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
351 def endnode(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
352 if self.savetext <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
353 print '*** Still saving text at end of node'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
354 dummy = self.collectsavings()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
355 if self.footnotes:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
356 self.writefootnotes()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
357 if self.nodefp:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
358 if self.nodelineno > 20:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
359 self.write('<HR>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
360 [name, next, prev, up] = self.nodelinks[:4]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
361 self.link('Next', next)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
362 self.link('Prev', prev)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
363 self.link('Up', up)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
364 if self.nodename <> self.topname:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
365 self.link('Top', self.topname)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
366 self.write('<HR>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
367 self.write('</BODY>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
368 self.nodefp.close()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
369 self.nodefp = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
370 elif self.node:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
371 if not self.cont and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
372 (not self.node.type or \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
373 (self.node.next and self.node.prev and self.node.up)):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
374 self.node.finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
375 self.node.flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
376 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
377 self.nodestack.append(self.node)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
378 self.node = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
379 self.nodename = ''
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
380
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
381 # 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
382 # 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
383 def process(self, accu):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
384 if self.debugging > 1:
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
385 print '!'*self.debugging, 'process:', self.skip, self.stack,
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
386 if accu: print accu[0][:30],
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
387 if accu[0][30:] or accu[1:]: print '...',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
388 print
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
389 if self.inmenu():
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
390 # XXX should be done differently
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
391 for line in accu:
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
392 mo = miprog.match(line)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
393 if not mo:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
394 line = line.strip() + '\n'
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
395 self.expand(line)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
396 continue
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
397 bgn, end = mo.span(0)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
398 a, b = mo.span(1)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
399 c, d = mo.span(2)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
400 e, f = mo.span(3)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
401 g, h = mo.span(4)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
402 label = line[a:b]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
403 nodename = line[c:d]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
404 if nodename[0] == ':': nodename = label
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
405 else: nodename = line[e:f]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
406 punct = line[g:h]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
407 self.write(' <LI><A HREF="',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
408 makefile(nodename),
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
409 '">', nodename,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
410 '</A>', punct, '\n')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
411 self.htmlhelp.menuitem(nodename)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
412 self.expand(line[end:])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
413 else:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
414 text = ''.join(accu)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
415 self.expand(text)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
416
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
417 # find 'menu' (we might be inside 'ifset' or 'ifclear')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
418 def inmenu(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
419 #if 'menu' in self.stack:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
420 # print 'inmenu :', self.skip, self.stack, self.stackinfo
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
421 stack = self.stack
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
422 while stack and stack[-1] in ('ifset','ifclear'):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
423 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
424 if self.stackinfo[len(stack)]:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
425 return 0
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
426 except KeyError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
427 pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
428 stack = stack[:-1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
429 return (stack and stack[-1] == 'menu')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
430
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
431 # 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
432 def expand(self, text):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
433 stack = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
434 i = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
435 n = len(text)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
436 while i < n:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
437 start = i
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
438 mo = spprog.search(text, i)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
439 if mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
440 i = mo.start()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
441 else:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
442 self.write(text[start:])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
443 break
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
444 self.write(text[start:i])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
445 c = text[i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
446 i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
447 if c == '\n':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
448 self.write('\n')
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 if c == '<':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
451 self.write('&lt;')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
452 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
453 if c == '>':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
454 self.write('&gt;')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
455 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
456 if c == '&':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
457 self.write('&amp;')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
458 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
459 if c == '{':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
460 stack.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
461 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
462 if c == '}':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
463 if not stack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
464 print '*** Unmatched }'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
465 self.write('}')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
466 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
467 cmd = stack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
468 del stack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
469 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
470 method = getattr(self, 'close_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
471 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
472 self.unknown_close(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
473 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
474 method()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
475 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
476 if c <> '@':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
477 # Cannot happen unless spprog is changed
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
478 raise RuntimeError, 'unexpected funny %r' % c
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
479 start = i
18781
01ae962df885 Use string.ascii_letters instead of string.letters (SF bug #226706).
Fred Drake <fdrake@acm.org>
parents: 15930
diff changeset
480 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
481 if i == start:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
482 # @ plus non-letter: literal next character
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
483 i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
484 c = text[start:i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
485 if c == ':':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
486 # `@:' means no extra space after
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
487 # preceding `.', `?', `!' or `:'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
488 pass
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
489 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
490 # `@.' means a sentence-ending period;
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
491 # `@@', `@{', `@}' quote `@', `{', `}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
492 self.write(c)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
493 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
494 cmd = text[start:i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
495 if i < n and text[i] == '{':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
496 i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
497 stack.append(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
498 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
499 method = getattr(self, 'open_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
500 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
501 self.unknown_open(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
502 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
503 method()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
504 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
505 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
506 method = getattr(self, 'handle_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
507 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
508 self.unknown_handle(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
509 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
510 method()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
511 if stack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
512 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
513
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
514 # --- Handle unknown embedded @-commands ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
515
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
516 def unknown_open(self, cmd):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
517 print '*** No open func for @' + cmd + '{...}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
518 cmd = cmd + '{'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
519 self.write('@', cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
520 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
521 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
522 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
523 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
524
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
525 def unknown_close(self, cmd):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
526 print '*** No close func for @' + cmd + '{...}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
527 cmd = '}' + cmd
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
528 self.write('}')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
529 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
530 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
531 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
532 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
533
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
534 def unknown_handle(self, cmd):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
535 print '*** No handler for @' + cmd
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
536 self.write('@', cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
537 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
538 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
539 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
540 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
541
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
542 # 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
543
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
544 # --- Embedded @-commands without {} argument list --
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
545
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
546 def handle_noindent(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
547
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
548 def handle_refill(self): pass
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
549
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
550 # --- Include file handling ---
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 do_include(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
553 file = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
554 file = os.path.join(self.includedir, file)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
555 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
556 fp = open(file, 'r')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
557 except IOError, msg:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
558 print '*** Can\'t open include file', repr(file)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
559 return
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
560 print '!'*self.debugging, '--> file', repr(file)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
561 save_done = self.done
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
562 save_skip = self.skip
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
563 save_stack = self.stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
564 self.includedepth = self.includedepth + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
565 self.parserest(fp, 0)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
566 self.includedepth = self.includedepth - 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
567 fp.close()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
568 self.done = save_done
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
569 self.skip = save_skip
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
570 self.stack = save_stack
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
571 print '!'*self.debugging, '<-- file', repr(file)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
572
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
573 # --- Special Insertions ---
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
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_dmn(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
576 def close_dmn(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
577
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
578 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
579 def close_dots(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
580
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
581 def open_bullet(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
582 def close_bullet(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
583
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
584 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
585 def close_TeX(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
586
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
587 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
588 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
589 def close_copyright(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
590
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
591 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
592 def close_minus(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
593
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
594 # --- Accents ---
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
595
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
596 # rpyron 2002-05-07
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
597 # I would like to do at least as well as makeinfo when
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
598 # it is producing HTML output:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
599 #
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
600 # input output
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
601 # @"o @"o umlaut accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
602 # @'o 'o acute accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
603 # @,{c} @,{c} cedilla accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
604 # @=o @=o macron/overbar accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
605 # @^o @^o circumflex accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
606 # @`o `o grave accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
607 # @~o @~o tilde accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
608 # @dotaccent{o} @dotaccent{o} overdot accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
609 # @H{o} @H{o} long Hungarian umlaut
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
610 # @ringaccent{o} @ringaccent{o} ring accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
611 # @tieaccent{oo} @tieaccent{oo} tie-after accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
612 # @u{o} @u{o} breve accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
613 # @ubaraccent{o} @ubaraccent{o} underbar accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
614 # @udotaccent{o} @udotaccent{o} underdot accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
615 # @v{o} @v{o} hacek or check accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
616 # @exclamdown{} &#161; upside-down !
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
617 # @questiondown{} &#191; upside-down ?
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
618 # @aa{},@AA{} &#229;,&#197; a,A with circle
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
619 # @ae{},@AE{} &#230;,&#198; ae,AE ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
620 # @dotless{i} @dotless{i} dotless i
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
621 # @dotless{j} @dotless{j} dotless j
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
622 # @l{},@L{} l/,L/ suppressed-L,l
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
623 # @o{},@O{} &#248;,&#216; O,o with slash
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
624 # @oe{},@OE{} oe,OE oe,OE ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
625 # @ss{} &#223; es-zet or sharp S
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
626 #
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
627 # The following character codes and approximations have been
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
628 # copied from makeinfo's HTML output.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
629
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
630 def open_exclamdown(self): self.write('&#161;') # upside-down !
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
631 def close_exclamdown(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
632 def open_questiondown(self): self.write('&#191;') # upside-down ?
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
633 def close_questiondown(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
634 def open_aa(self): self.write('&#229;') # a with circle
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
635 def close_aa(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
636 def open_AA(self): self.write('&#197;') # A with circle
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
637 def close_AA(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
638 def open_ae(self): self.write('&#230;') # ae ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
639 def close_ae(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
640 def open_AE(self): self.write('&#198;') # AE ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
641 def close_AE(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
642 def open_o(self): self.write('&#248;') # o with slash
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
643 def close_o(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
644 def open_O(self): self.write('&#216;') # O with slash
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
645 def close_O(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
646 def open_ss(self): self.write('&#223;') # es-zet or sharp S
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
647 def close_ss(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
648 def open_oe(self): self.write('oe') # oe ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
649 def close_oe(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
650 def open_OE(self): self.write('OE') # OE ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
651 def close_OE(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
652 def open_l(self): self.write('l/') # suppressed-l
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
653 def close_l(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
654 def open_L(self): self.write('L/') # suppressed-L
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
655 def close_L(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
656
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
657 # --- Special Glyphs for Examples ---
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_result(self): self.write('=&gt;')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
660 def close_result(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
661
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
662 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
663 def close_expansion(self): pass
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_print(self): self.write('-|')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
666 def close_print(self): pass
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_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
669 def close_error(self): pass
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_equiv(self): self.write('==')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
672 def close_equiv(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
673
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
674 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
675 def close_point(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
676
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
677 # --- Cross References ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
678
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
679 def open_pxref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
680 self.write('see ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
681 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
682 def close_pxref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
683 self.makeref()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
684
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
685 def open_xref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
686 self.write('See ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
687 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
688 def close_xref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
689 self.makeref()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
690
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
691 def open_ref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
692 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
693 def close_ref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
694 self.makeref()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
695
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
696 def open_inforef(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
697 self.write('See info file ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
698 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
699 def close_inforef(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
700 text = self.collectsavings()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
701 args = [s.strip() for s in text.split(',')]
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
702 while len(args) < 3: args.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
703 node = args[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
704 file = args[2]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
705 self.write('`', file, '\', node `', node, '\'')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
706
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
707 def makeref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
708 text = self.collectsavings()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
709 args = [s.strip() for s in text.split(',')]
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
710 while len(args) < 5: args.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
711 nodename = label = args[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
712 if args[2]: label = args[2]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
713 file = args[3]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
714 title = args[4]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
715 href = makefile(nodename)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
716 if file:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
717 href = '../' + file + '/' + href
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
718 self.write('<A HREF="', href, '">', label, '</A>')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
719
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
720 # rpyron 2002-05-07 uref support
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
721 def open_uref(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
722 self.startsaving()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
723 def close_uref(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
724 text = self.collectsavings()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
725 args = [s.strip() for s in text.split(',')]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
726 while len(args) < 2: args.append('')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
727 href = args[0]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
728 label = args[1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
729 if not label: label = href
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
730 self.write('<A HREF="', href, '">', label, '</A>')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
731
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
732 # rpyron 2002-05-07 image support
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
733 # GNU makeinfo producing HTML output tries `filename.png'; if
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
734 # that does not exist, it tries `filename.jpg'. If that does
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
735 # not exist either, it complains. GNU makeinfo does not handle
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
736 # GIF files; however, I include GIF support here because
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
737 # MySQL documentation uses GIF files.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
738
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
739 def open_image(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
740 self.startsaving()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
741 def close_image(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
742 self.makeimage()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
743 def makeimage(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
744 text = self.collectsavings()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
745 args = [s.strip() for s in text.split(',')]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
746 while len(args) < 5: args.append('')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
747 filename = args[0]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
748 width = args[1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
749 height = args[2]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
750 alt = args[3]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
751 ext = args[4]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
752
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
753 # The HTML output will have a reference to the image
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
754 # that is relative to the HTML output directory,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
755 # which is what 'filename' gives us. However, we need
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
756 # to find it relative to our own current directory,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
757 # so we construct 'imagename'.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
758 imagelocation = self.dirname + '/' + filename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
759
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
760 if os.path.exists(imagelocation+'.png'):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
761 filename += '.png'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
762 elif os.path.exists(imagelocation+'.jpg'):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
763 filename += '.jpg'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
764 elif os.path.exists(imagelocation+'.gif'): # MySQL uses GIF files
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
765 filename += '.gif'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
766 else:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
767 print "*** Cannot find image " + imagelocation
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
768 #TODO: what is 'ext'?
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
769 self.write('<IMG SRC="', filename, '"', \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
770 width and (' WIDTH="' + width + '"') or "", \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
771 height and (' HEIGHT="' + height + '"') or "", \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
772 alt and (' ALT="' + alt + '"') or "", \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
773 '/>' )
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
774 self.htmlhelp.addimage(imagelocation)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
775
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
776
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
777 # --- Marking Words and Phrases ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
778
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
779 # --- Other @xxx{...} commands ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
780
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
781 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
782 def close_(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
783
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
784 open_asis = open_
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
785 close_asis = close_
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
786
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
787 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
788 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
789
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
790 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
791 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
792
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
793 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
794 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
795
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
796 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
797 def close_dfn(self): self.write('</DFN>')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
798
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
799 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
800 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
801
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
802 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
803 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
804
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
805 def open_footnote(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
806 # if self.savetext <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
807 # print '*** Recursive footnote -- expect weirdness'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
808 id = len(self.footnotes) + 1
32734
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
809 self.write(self.FN_SOURCE_PATTERN % {'id': repr(id)})
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
810 self.startsaving()
4307
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 close_footnote(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
813 id = len(self.footnotes) + 1
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
814 self.footnotes.append((id, self.collectsavings()))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
815
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
816 def writefootnotes(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
817 self.write(self.FN_HEADER)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
818 for id, text in self.footnotes:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
819 self.write(self.FN_TARGET_PATTERN
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
820 % {'id': repr(id), 'text': text})
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
821 self.footnotes = []
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
822
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
823 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
824 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
825
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
826 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
827 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
828
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
829 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
830 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
831
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
832 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
833 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
834
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
835 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
836 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
837
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
838 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
839 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
840
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
841 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
842 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
843
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
844 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
845 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
846
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
847 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
848 def close_var(self): self.write('</VAR>')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
849
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
850 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
851 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
852
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
853 def open_url(self): self.startsaving()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
854 def close_url(self):
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
855 text = self.collectsavings()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
856 self.write('<A HREF="', text, '">', text, '</A>')
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
857
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
858 def open_email(self): self.startsaving()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
859 def close_email(self):
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
860 text = self.collectsavings()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
861 self.write('<A HREF="mailto:', text, '">', text, '</A>')
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
862
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
863 open_titlefont = open_
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
864 close_titlefont = close_
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 def open_small(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
867 def close_small(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
868
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
869 def command(self, line, mo):
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
870 a, b = mo.span(1)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
871 cmd = line[a:b]
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
872 args = line[b:].strip()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
873 if self.debugging > 1:
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
874 print '!'*self.debugging, 'command:', self.skip, self.stack, \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
875 '@' + cmd, args
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
876 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
877 func = getattr(self, 'do_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
878 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
879 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
880 func = getattr(self, 'bgn_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
881 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
882 # don't complain if we are skipping anyway
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
883 if not self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
884 self.unknown_cmd(cmd, args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
885 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
886 self.stack.append(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
887 func(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
888 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
889 if not self.skip or cmd == 'end':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
890 func(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
891
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
892 def unknown_cmd(self, cmd, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
893 print '*** unknown', '@' + cmd, args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
894 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
895 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
896 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
897 self.unknown[cmd] = self.unknown[cmd] + 1
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
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 do_end(self, args):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
900 words = args.split()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
901 if not words:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
902 print '*** @end w/o args'
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 cmd = words[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
905 if not self.stack or self.stack[-1] <> cmd:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
906 print '*** @end', cmd, 'unexpected'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
907 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
908 del self.stack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
909 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
910 func = getattr(self, 'end_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
911 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
912 self.unknown_end(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
913 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
914 func()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
915
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
916 def unknown_end(self, cmd):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
917 cmd = 'end ' + cmd
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
918 print '*** unknown', '@' + cmd
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
919 if not self.unknown.has_key(cmd):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
920 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
921 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
922 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
923
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
924 # --- Comments ---
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
925
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
926 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
927 do_c = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
928
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
929 # --- Conditional processing ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
930
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
931 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
932 def end_ifinfo(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
933
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
934 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
935 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
936
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
937 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
938 def end_ignore(self): self.skip = self.skip - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
939
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
940 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
941 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
942
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
943 def do_set(self, args):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
944 fields = args.split(' ')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
945 key = fields[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
946 if len(fields) == 1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
947 value = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
948 else:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
949 value = ' '.join(fields[1:])
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
950 self.values[key] = value
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
951
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
952 def do_clear(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
953 self.values[args] = None
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
954
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
955 def bgn_ifset(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
956 if args not in self.values.keys() \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
957 or self.values[args] is None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
958 self.skip = self.skip + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
959 self.stackinfo[len(self.stack)] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
960 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
961 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
962 def end_ifset(self):
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
963 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
964 if self.stackinfo[len(self.stack) + 1]:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
965 self.skip = self.skip - 1
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
966 del self.stackinfo[len(self.stack) + 1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
967 except KeyError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
968 print '*** end_ifset: KeyError :', len(self.stack) + 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
969
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
970 def bgn_ifclear(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
971 if args in self.values.keys() \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
972 and self.values[args] is not None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
973 self.skip = self.skip + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
974 self.stackinfo[len(self.stack)] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
975 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
976 self.stackinfo[len(self.stack)] = 0
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
977 def end_ifclear(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
978 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
979 if self.stackinfo[len(self.stack) + 1]:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
980 self.skip = self.skip - 1
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
981 del self.stackinfo[len(self.stack) + 1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
982 except KeyError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
983 print '*** end_ifclear: KeyError :', len(self.stack) + 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
984
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
985 def open_value(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
986 self.startsaving()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
987
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
988 def close_value(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
989 key = self.collectsavings()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
990 if key in self.values.keys():
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
991 self.write(self.values[key])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
992 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
993 print '*** Undefined value: ', key
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
994
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
995 # --- Beginning a file ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
996
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
997 do_finalout = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
998 do_setchapternewpage = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
999 do_setfilename = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1000
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1001 def do_settitle(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1002 self.startsaving()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1003 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1004 self.title = self.collectsavings()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1005 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
1006
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1007 # --- Ending a file ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1008
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1009 def do_bye(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1010 self.endnode()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1011 self.done = 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1012
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1013 # --- Title page ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1014
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1015 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
1016 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
1017 def do_shorttitlepage(self, args): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1018
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1019 def do_center(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1020 # Actually not used outside title page...
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1021 self.write('<H1>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1022 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1023 self.write('</H1>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1024 do_title = do_center
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1025 do_subtitle = do_center
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1026 do_author = do_center
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1027
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1028 do_vskip = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1029 do_vfill = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1030 do_smallbook = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1031
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1032 do_paragraphindent = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1033 do_setchapternewpage = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1034 do_headings = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1035 do_footnotestyle = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1036
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1037 do_evenheading = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1038 do_evenfooting = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1039 do_oddheading = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1040 do_oddfooting = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1041 do_everyheading = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1042 do_everyfooting = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1043
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1044 # --- Nodes ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1045
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1046 def do_node(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1047 self.endnode()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1048 self.nodelineno = 0
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1049 parts = [s.strip() for s in args.split(',')]
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1050 while len(parts) < 4: parts.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1051 self.nodelinks = parts
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1052 [name, next, prev, up] = parts[:4]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1053 file = self.dirname + '/' + makefile(name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1054 if self.filenames.has_key(file):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1055 print '*** Filename already in use: ', file
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1056 else:
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1057 if self.debugging: print '!'*self.debugging, '--- writing', file
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1058 self.filenames[file] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1059 # self.nodefp = open(file, 'w')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1060 self.nodename = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1061 if self.cont and self.nodestack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1062 self.nodestack[-1].cont = self.nodename
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1063 if not self.topname: self.topname = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1064 title = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1065 if self.title: title = title + ' -- ' + self.title
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1066 self.node = self.Node(self.dirname, self.nodename, self.topname,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1067 title, next, prev, up)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1068 self.htmlhelp.addnode(self.nodename,next,prev,up,file)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1069
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1070 def link(self, label, nodename):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1071 if nodename:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1072 if nodename.lower() == '(dir)':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1073 addr = '../dir.html'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1074 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1075 addr = makefile(nodename)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1076 self.write(label, ': <A HREF="', addr, '" TYPE="',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1077 label, '">', nodename, '</A> \n')
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 # --- Sectioning commands ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1080
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1081 def popstack(self, type):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1082 if (self.node):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1083 self.node.type = type
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1084 while self.nodestack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1085 if self.nodestack[-1].type > type:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1086 self.nodestack[-1].finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1087 self.nodestack[-1].flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1088 del self.nodestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1089 elif self.nodestack[-1].type == type:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1090 if not self.nodestack[-1].next:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1091 self.nodestack[-1].next = self.node.name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1092 if not self.node.prev:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1093 self.node.prev = self.nodestack[-1].name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1094 self.nodestack[-1].finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1095 self.nodestack[-1].flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1096 del self.nodestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1097 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1098 if type > 1 and not self.node.up:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1099 self.node.up = self.nodestack[-1].name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1100 break
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1101
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1102 def do_chapter(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1103 self.heading('H1', args, 0)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1104 self.popstack(1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1105
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1106 def do_unnumbered(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1107 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1108 self.popstack(1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1109 def do_appendix(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1110 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1111 self.popstack(1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1112 def do_top(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1113 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
1114 def do_chapheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1115 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
1116 def do_majorheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1117 self.heading('H1', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1118
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1119 def do_section(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1120 self.heading('H1', args, 1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1121 self.popstack(2)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1122
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1123 def do_unnumberedsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1124 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1125 self.popstack(2)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1126 def do_appendixsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1127 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1128 self.popstack(2)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1129 do_appendixsection = do_appendixsec
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1130 def do_heading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1131 self.heading('H1', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1132
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1133 def do_subsection(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1134 self.heading('H2', args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1135 self.popstack(3)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1136 def do_unnumberedsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1137 self.heading('H2', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1138 self.popstack(3)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1139 def do_appendixsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1140 self.heading('H2', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1141 self.popstack(3)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1142 def do_subheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1143 self.heading('H2', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1144
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1145 def do_subsubsection(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1146 self.heading('H3', args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1147 self.popstack(4)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1148 def do_unnumberedsubsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1149 self.heading('H3', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1150 self.popstack(4)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1151 def do_appendixsubsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1152 self.heading('H3', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1153 self.popstack(4)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1154 def do_subsubheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1155 self.heading('H3', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1156
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1157 def heading(self, type, args, level):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1158 if level >= 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1159 while len(self.numbering) <= level:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1160 self.numbering.append(0)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1161 del self.numbering[level+1:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1162 self.numbering[level] = self.numbering[level] + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1163 x = ''
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1164 for i in self.numbering:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
1165 x = x + repr(i) + '.'
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1166 args = x + ' ' + args
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
1167 self.contents.append((level, args, self.nodename))
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1168 self.write('<', type, '>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1169 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1170 self.write('</', type, '>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1171 if self.debugging or self.print_headers:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1172 print '---', args
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1173
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1174 def do_contents(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1175 # pass
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1176 self.listcontents('Table of Contents', 999)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1177
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1178 def do_shortcontents(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1179 pass
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1180 # 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
1181 do_summarycontents = do_shortcontents
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 listcontents(self, title, maxlevel):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1184 self.write('<H1>', title, '</H1>\n<UL COMPACT PLAIN>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1185 prevlevels = [0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1186 for level, title, node in self.contents:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1187 if level > maxlevel:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1188 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1189 if level > prevlevels[-1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1190 # can only advance one level at a time
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1191 self.write(' '*prevlevels[-1], '<UL PLAIN>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1192 prevlevels.append(level)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1193 elif level < prevlevels[-1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1194 # might drop back multiple levels
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1195 while level < prevlevels[-1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1196 del prevlevels[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1197 self.write(' '*prevlevels[-1],
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1198 '</UL>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1199 self.write(' '*level, '<LI> <A HREF="',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1200 makefile(node), '">')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1201 self.expand(title)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1202 self.write('</A>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1203 self.write('</UL>\n' * len(prevlevels))
2705
9ed45dbf2765 mods by Gregor Schmid -- very nice!
Guido van Rossum <guido@python.org>
parents: 2551
diff changeset
1204
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1205 # --- Page lay-out ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1206
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1207 # 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
1208
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1209 def do_page(self, args): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1210
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1211 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
1212
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1213 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
1214 def end_group(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1215
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1216 # --- Line lay-out ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1217
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1218 def do_sp(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1219 if self.nofill:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1220 self.write('\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1221 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1222 self.write('<P>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1223
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1224 def do_hline(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1225 self.write('<HR>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1226
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1227 # --- Function and variable definitions ---
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1228
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1229 def bgn_deffn(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1230 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1231 self.do_deffnx(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1232
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1233 def end_deffn(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1234 self.write('</DL>\n')
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1235
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1236 def do_deffnx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1237 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1238 words = splitwords(args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1239 [category, name], rest = words[:2], words[2:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1240 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1241 for word in rest: self.expand(' ' + makevar(word))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1242 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1243 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1244 self.index('fn', name)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1245
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1246 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
1247 end_defun = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1248 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
1249
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1250 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
1251 end_defmac = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1252 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
1253
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1254 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
1255 end_defspec = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1256 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
1257
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1258 def bgn_defvr(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1259 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1260 self.do_defvrx(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1261
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1262 end_defvr = end_deffn
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1263
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1264 def do_defvrx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1265 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1266 words = splitwords(args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1267 [category, name], rest = words[:2], words[2:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1268 self.expand('@code{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1269 # If there are too many arguments, show them
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1270 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1271 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1272 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1273 self.index('vr', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1274
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1275 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
1276 end_defvar = end_defvr
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1277 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
1278
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1279 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
1280 end_defopt = end_defvr
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1281 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
1282
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1283 # --- Ditto for typed languages ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1284
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1285 def bgn_deftypefn(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1286 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1287 self.do_deftypefnx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1288
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1289 end_deftypefn = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1290
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1291 def do_deftypefnx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1292 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1293 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1294 [category, datatype, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1295 self.expand('@code{%s} @b{%s}' % (datatype, name))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1296 for word in rest: self.expand(' ' + makevar(word))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1297 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1298 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1299 self.index('fn', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1300
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1301
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1302 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
1303 end_deftypefun = end_deftypefn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1304 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
1305
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1306 def bgn_deftypevr(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1307 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1308 self.do_deftypevrx(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1309
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1310 end_deftypevr = end_deftypefn
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
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 do_deftypevrx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1313 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1314 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1315 [category, datatype, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1316 self.expand('@code{%s} @b{%s}' % (datatype, name))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1317 # If there are too many arguments, show them
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1318 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1319 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1320 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1321 self.index('fn', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1322
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1323 def bgn_deftypevar(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1324 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
1325 end_deftypevar = end_deftypevr
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1326 def do_deftypevarx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1327 self.do_deftypevrx('Variable ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1328
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1329 # --- Ditto for object-oriented languages ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1330
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1331 def bgn_defcv(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1332 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1333 self.do_defcvx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1334
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1335 end_defcv = end_deftypevr
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
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 do_defcvx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1338 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1339 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1340 [category, classname, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1341 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1342 # If there are too many arguments, show them
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1343 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1344 #self.expand(' -- %s of @code{%s}' % (category, classname))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1345 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1346 self.index('vr', '%s @r{on %s}' % (name, classname))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1347
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1348 def bgn_defivar(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1349 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
1350 end_defivar = end_defcv
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1351 def do_defivarx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1352 self.do_defcvx('{Instance Variable} ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1353
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1354 def bgn_defop(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1355 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1356 self.do_defopx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1357
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1358 end_defop = end_defcv
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1359
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1360 def do_defopx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1361 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1362 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1363 [category, classname, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1364 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1365 for word in rest: self.expand(' ' + makevar(word))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1366 #self.expand(' -- %s of @code{%s}' % (category, classname))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1367 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1368 self.index('fn', '%s @r{on %s}' % (name, classname))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1369
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1370 def bgn_defmethod(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1371 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
1372 end_defmethod = end_defop
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1373 def do_defmethodx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1374 self.do_defopx('Method ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1375
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1376 # --- Ditto for data types ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1377
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1378 def bgn_deftp(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1379 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1380 self.do_deftpx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1381
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1382 end_deftp = end_defcv
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
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_deftpx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1385 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1386 words = splitwords(args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1387 [category, name], rest = words[:2], words[2:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1388 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1389 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1390 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1391 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1392 self.index('tp', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1393
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1394 # --- Making Lists and Tables
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1395
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1396 def bgn_enumerate(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1397 if not args:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1398 self.write('<OL>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1399 self.stackinfo[len(self.stack)] = '</OL>\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1400 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1401 self.itemnumber = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1402 self.write('<UL>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1403 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
1404 def end_enumerate(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1405 self.itemnumber = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1406 self.write(self.stackinfo[len(self.stack) + 1])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1407 del self.stackinfo[len(self.stack) + 1]
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1408
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1409 def bgn_itemize(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1410 self.itemarg = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1411 self.write('<UL>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1412 def end_itemize(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1413 self.itemarg = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1414 self.write('</UL>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1415
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1416 def bgn_table(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1417 self.itemarg = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1418 self.write('<DL>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1419 def end_table(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1420 self.itemarg = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1421 self.write('</DL>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1422
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1423 def bgn_ftable(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1424 self.itemindex = 'fn'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1425 self.bgn_table(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1426 def end_ftable(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1427 self.itemindex = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1428 self.end_table()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1429
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1430 def bgn_vtable(self, args):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1431 self.itemindex = 'vr'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1432 self.bgn_table(args)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1433 def end_vtable(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1434 self.itemindex = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1435 self.end_table()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1436
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1437 def do_item(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1438 if self.itemindex: self.index(self.itemindex, args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1439 if self.itemarg:
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1440 if self.itemarg[0] == '@' and self.itemarg[1] and \
18781
01ae962df885 Use string.ascii_letters instead of string.letters (SF bug #226706).
Fred Drake <fdrake@acm.org>
parents: 15930
diff changeset
1441 self.itemarg[1] in string.ascii_letters:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1442 args = self.itemarg + '{' + args + '}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1443 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1444 # some other character, e.g. '-'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1445 args = self.itemarg + ' ' + args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1446 if self.itemnumber <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1447 args = self.itemnumber + '. ' + args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1448 self.itemnumber = increment(self.itemnumber)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1449 if self.stack and self.stack[-1] == 'table':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1450 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1451 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1452 self.write('\n<DD>')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1453 elif self.stack and self.stack[-1] == 'multitable':
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1454 self.write('<TR><TD>')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1455 self.expand(args)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1456 self.write('</TD>\n</TR>\n')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1457 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1458 self.write('<LI>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1459 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1460 self.write(' ')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1461 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
1462
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1463 # rpyron 2002-05-07 multitable support
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1464 def bgn_multitable(self, args):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1465 self.itemarg = None # should be handled by columnfractions
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1466 self.write('<TABLE BORDER="">\n')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1467 def end_multitable(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1468 self.itemarg = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1469 self.write('</TABLE>\n<BR>\n')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1470 def handle_columnfractions(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1471 # It would be better to handle this, but for now it's in the way...
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1472 self.itemarg = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1473 def handle_tab(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1474 self.write('</TD>\n <TD>')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1475
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1476 # --- Enumerations, displays, quotations ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1477 # XXX Most of these should increase the indentation somehow
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1478
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1479 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
1480 def end_quotation(self): self.write('</BLOCKQUOTE>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1481
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1482 def bgn_example(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1483 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1484 self.write('<PRE>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1485 def end_example(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1486 self.write('</PRE>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1487 self.nofill = self.nofill - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1488
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1489 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
1490 end_lisp = end_example
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1491
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1492 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
1493 end_smallexample = end_example
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1494
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1495 bgn_smalllisp = bgn_lisp # Ditto
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1496 end_smalllisp = end_lisp
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1497
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1498 bgn_display = bgn_example
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1499 end_display = end_example
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1500
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1501 bgn_format = bgn_display
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1502 end_format = end_display
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1503
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1504 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
1505 # XXX Should really mess with indentation
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1506
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1507 def bgn_flushleft(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1508 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1509 self.write('<PRE>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1510 def end_flushleft(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1511 self.write('</PRE>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1512 self.nofill = self.nofill - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1513
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1514 def bgn_flushright(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1515 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1516 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
1517 def end_flushright(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1518 self.write('</ADDRESS>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1519 self.nofill = self.nofill - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1520
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1521 def bgn_menu(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1522 self.write('<DIR>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1523 self.write(' <STRONG><EM>Menu</EM></STRONG><P>\n')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1524 self.htmlhelp.beginmenu()
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1525 def end_menu(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1526 self.write('</DIR>\n')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1527 self.htmlhelp.endmenu()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1528
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1529 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
1530 def end_cartouche(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1531
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1532 # --- Indices ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1533
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1534 def resetindex(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1535 self.noncodeindices = ['cp']
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1536 self.indextitle = {}
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1537 self.indextitle['cp'] = 'Concept'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1538 self.indextitle['fn'] = 'Function'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1539 self.indextitle['ky'] = 'Keyword'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1540 self.indextitle['pg'] = 'Program'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1541 self.indextitle['tp'] = 'Type'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1542 self.indextitle['vr'] = 'Variable'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1543 #
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1544 self.whichindex = {}
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1545 for name in self.indextitle.keys():
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1546 self.whichindex[name] = []
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1547
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1548 def user_index(self, name, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1549 if self.whichindex.has_key(name):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1550 self.index(name, args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1551 else:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
1552 print '*** No index named', repr(name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1553
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1554 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
1555 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
1556 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
1557 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
1558 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
1559 def do_vindex(self, args): self.index('vr', args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1560
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1561 def index(self, name, args):
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
1562 self.whichindex[name].append((args, self.nodename))
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1563 self.htmlhelp.index(args, self.nodename)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1564
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1565 def do_synindex(self, args):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1566 words = args.split()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1567 if len(words) <> 2:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1568 print '*** bad @synindex', args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1569 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1570 [old, new] = words
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1571 if not self.whichindex.has_key(old) or \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1572 not self.whichindex.has_key(new):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1573 print '*** bad key(s) in @synindex', args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1574 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1575 if old <> new and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1576 self.whichindex[old] is not self.whichindex[new]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1577 inew = self.whichindex[new]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1578 inew[len(inew):] = self.whichindex[old]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1579 self.whichindex[old] = inew
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1580 do_syncodeindex = do_synindex # XXX Should use code font
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1581
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1582 def do_printindex(self, args):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1583 words = args.split()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1584 for name in words:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1585 if self.whichindex.has_key(name):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1586 self.prindex(name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1587 else:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
1588 print '*** No index named', repr(name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1589
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1590 def prindex(self, name):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1591 iscodeindex = (name not in self.noncodeindices)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1592 index = self.whichindex[name]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1593 if not index: return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1594 if self.debugging:
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1595 print '!'*self.debugging, '--- Generating', \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1596 self.indextitle[name], 'index'
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1597 # The node already provides a title
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1598 index1 = []
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1599 junkprog = re.compile('^(@[a-z]+)?{')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1600 for key, node in index:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1601 sortkey = key.lower()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1602 # Remove leading `@cmd{' from sort key
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1603 # -- don't bother about the matching `}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1604 oldsortkey = sortkey
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1605 while 1:
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1606 mo = junkprog.match(sortkey)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1607 if not mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1608 break
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1609 i = mo.end()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1610 sortkey = sortkey[i:]
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
1611 index1.append((sortkey, key, node))
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1612 del index[:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1613 index1.sort()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1614 self.write('<DL COMPACT>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1615 prevkey = prevnode = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1616 for sortkey, key, node in index1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1617 if (key, node) == (prevkey, prevnode):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1618 continue
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1619 if self.debugging > 1: print '!'*self.debugging, key, ':', node
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1620 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1621 if iscodeindex: key = '@code{' + key + '}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1622 if key != prevkey:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1623 self.expand(key)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1624 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
1625 prevkey, prevnode = key, node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1626 self.write('</DL>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1627
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1628 # --- Final error reports ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1629
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1630 def report(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1631 if self.unknown:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1632 print '--- Unrecognized commands ---'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1633 cmds = self.unknown.keys()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1634 cmds.sort()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1635 for cmd in cmds:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1636 print cmd.ljust(20), self.unknown[cmd]
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1637
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1638
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1639 class TexinfoParserHTML3(TexinfoParser):
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1640
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1641 COPYRIGHT_SYMBOL = "&copy;"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1642 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
1643 FN_SOURCE_PATTERN = '<A ID=footnoteref%(id)s ' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1644 '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
1645 FN_TARGET_PATTERN = '<FN ID=footnotetext%(id)s>\n' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1646 '<P><A HREF="#footnoteref%(id)s">' + FN_ID_PATTERN \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1647 + '</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
1648 FN_HEADER = '<DIV CLASS=footnotes>\n <HR NOSHADE WIDTH=200>\n' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1649 ' <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
1650
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1651 Node = HTML3Node
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1652
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1653 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
1654 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
1655
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1656 def bgn_example(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1657 # this use of <CODE> would not be legal in HTML 2.0,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1658 # but is in more recent DTDs.
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1659 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1660 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
1661 def end_example(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1662 self.write("</CODE></PRE>\n")
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1663 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
1664
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1665 def bgn_flushleft(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1666 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1667 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
1668
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1669 def bgn_flushright(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1670 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1671 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
1672 def end_flushright(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1673 self.write('</ADDRESS></DIV>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1674 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
1675
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1676 def bgn_menu(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1677 self.write('<UL PLAIN CLASS=menu>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1678 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
1679 def end_menu(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1680 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
1681
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1682
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1683 # rpyron 2002-05-07
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1684 class HTMLHelp:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1685 """
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1686 This class encapsulates support for HTML Help. Node names,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1687 file names, menu items, index items, and image file names are
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1688 accumulated until a call to finalize(). At that time, three
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1689 output files are created in the current directory:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1690
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1691 `helpbase`.hhp is a HTML Help Workshop project file.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1692 It contains various information, some of
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1693 which I do not understand; I just copied
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1694 the default project info from a fresh
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1695 installation.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1696 `helpbase`.hhc is the Contents file for the project.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1697 `helpbase`.hhk is the Index file for the project.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1698
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1699 When these files are used as input to HTML Help Workshop,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1700 the resulting file will be named:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1701
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1702 `helpbase`.chm
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1703
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1704 If none of the defaults in `helpbase`.hhp are changed,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1705 the .CHM file will have Contents, Index, Search, and
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1706 Favorites tabs.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1707 """
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1708
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1709 codeprog = re.compile('@code{(.*?)}')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1710
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1711 def __init__(self,helpbase,dirname):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1712 self.helpbase = helpbase
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1713 self.dirname = dirname
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1714 self.projectfile = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1715 self.contentfile = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1716 self.indexfile = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1717 self.nodelist = []
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1718 self.nodenames = {} # nodename : index
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1719 self.nodeindex = {}
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1720 self.filenames = {} # filename : filename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1721 self.indexlist = [] # (args,nodename) == (key,location)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1722 self.current = ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1723 self.menudict = {}
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1724 self.dumped = {}
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1725
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1726
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1727 def addnode(self,name,next,prev,up,filename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1728 node = (name,next,prev,up,filename)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1729 # add this file to dict
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1730 # retrieve list with self.filenames.values()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1731 self.filenames[filename] = filename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1732 # add this node to nodelist
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1733 self.nodeindex[name] = len(self.nodelist)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1734 self.nodelist.append(node)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1735 # set 'current' for menu items
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1736 self.current = name
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1737 self.menudict[self.current] = []
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1738
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1739 def menuitem(self,nodename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1740 menu = self.menudict[self.current]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1741 menu.append(nodename)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1742
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1743
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1744 def addimage(self,imagename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1745 self.filenames[imagename] = imagename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1746
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1747 def index(self, args, nodename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1748 self.indexlist.append((args,nodename))
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1749
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1750 def beginmenu(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1751 pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1752
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1753 def endmenu(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1754 pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1755
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1756 def finalize(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1757 if not self.helpbase:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1758 return
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1759
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1760 # generate interesting filenames
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1761 resultfile = self.helpbase + '.chm'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1762 projectfile = self.helpbase + '.hhp'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1763 contentfile = self.helpbase + '.hhc'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1764 indexfile = self.helpbase + '.hhk'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1765
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1766 # generate a reasonable title
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1767 title = self.helpbase
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1768
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1769 # get the default topic file
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1770 (topname,topnext,topprev,topup,topfile) = self.nodelist[0]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1771 defaulttopic = topfile
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1772
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1773 # PROJECT FILE
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1774 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1775 fp = open(projectfile,'w')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1776 print>>fp, '[OPTIONS]'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1777 print>>fp, 'Auto Index=Yes'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1778 print>>fp, 'Binary TOC=No'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1779 print>>fp, 'Binary Index=Yes'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1780 print>>fp, 'Compatibility=1.1'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1781 print>>fp, 'Compiled file=' + resultfile + ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1782 print>>fp, 'Contents file=' + contentfile + ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1783 print>>fp, 'Default topic=' + defaulttopic + ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1784 print>>fp, 'Error log file=ErrorLog.log'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1785 print>>fp, 'Index file=' + indexfile + ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1786 print>>fp, 'Title=' + title + ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1787 print>>fp, 'Display compile progress=Yes'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1788 print>>fp, 'Full-text search=Yes'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1789 print>>fp, 'Default window=main'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1790 print>>fp, ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1791 print>>fp, '[WINDOWS]'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1792 print>>fp, ('main=,"' + contentfile + '","' + indexfile
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1793 + '","","",,,,,0x23520,222,0x1046,[10,10,780,560],'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1794 '0xB0000,,,,,,0')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1795 print>>fp, ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1796 print>>fp, '[FILES]'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1797 print>>fp, ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1798 self.dumpfiles(fp)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1799 fp.close()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1800 except IOError, msg:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1801 print projectfile, ':', msg
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1802 sys.exit(1)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1803
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1804 # CONTENT FILE
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1805 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1806 fp = open(contentfile,'w')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1807 print>>fp, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1808 print>>fp, '<!-- This file defines the table of contents -->'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1809 print>>fp, '<HTML>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1810 print>>fp, '<HEAD>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1811 print>>fp, ('<meta name="GENERATOR"'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1812 'content="Microsoft&reg; HTML Help Workshop 4.1">')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1813 print>>fp, '<!-- Sitemap 1.0 -->'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1814 print>>fp, '</HEAD>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1815 print>>fp, '<BODY>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1816 print>>fp, ' <OBJECT type="text/site properties">'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1817 print>>fp, ' <param name="Window Styles" value="0x800025">'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1818 print>>fp, ' <param name="comment" value="title:">'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1819 print>>fp, ' <param name="comment" value="base:">'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1820 print>>fp, ' </OBJECT>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1821 self.dumpnodes(fp)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1822 print>>fp, '</BODY>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1823 print>>fp, '</HTML>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1824 fp.close()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1825 except IOError, msg:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1826 print contentfile, ':', msg
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1827 sys.exit(1)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1828
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1829 # INDEX FILE
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1830 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1831 fp = open(indexfile ,'w')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1832 print>>fp, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1833 print>>fp, '<!-- This file defines the index -->'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1834 print>>fp, '<HTML>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1835 print>>fp, '<HEAD>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1836 print>>fp, ('<meta name="GENERATOR"'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1837 'content="Microsoft&reg; HTML Help Workshop 4.1">')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1838 print>>fp, '<!-- Sitemap 1.0 -->'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1839 print>>fp, '</HEAD>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1840 print>>fp, '<BODY>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1841 print>>fp, '<OBJECT type="text/site properties">'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1842 print>>fp, '</OBJECT>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1843 self.dumpindex(fp)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1844 print>>fp, '</BODY>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1845 print>>fp, '</HTML>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1846 fp.close()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1847 except IOError, msg:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1848 print indexfile , ':', msg
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1849 sys.exit(1)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1850
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1851 def dumpfiles(self, outfile=sys.stdout):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1852 filelist = self.filenames.values()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1853 filelist.sort()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1854 for filename in filelist:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1855 print>>outfile, filename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1856
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1857 def dumpnodes(self, outfile=sys.stdout):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1858 self.dumped = {}
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1859 if self.nodelist:
32734
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
1860 nodename, dummy, dummy, dummy, dummy = self.nodelist[0]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1861 self.topnode = nodename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1862
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1863 print>>outfile, '<UL>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1864 for node in self.nodelist:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1865 self.dumpnode(node,0,outfile)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1866 print>>outfile, '</UL>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1867
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1868 def dumpnode(self, node, indent=0, outfile=sys.stdout):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1869 if node:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1870 # Retrieve info for this node
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1871 (nodename,next,prev,up,filename) = node
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1872 self.current = nodename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1873
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1874 # Have we been dumped already?
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1875 if self.dumped.has_key(nodename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1876 return
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1877 self.dumped[nodename] = 1
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1878
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1879 # Print info for this node
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1880 print>>outfile, ' '*indent,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1881 print>>outfile, '<LI><OBJECT type="text/sitemap">',
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1882 print>>outfile, '<param name="Name" value="' + nodename +'">',
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1883 print>>outfile, '<param name="Local" value="'+ filename +'">',
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1884 print>>outfile, '</OBJECT>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1885
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1886 # Does this node have menu items?
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1887 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1888 menu = self.menudict[nodename]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1889 self.dumpmenu(menu,indent+2,outfile)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1890 except KeyError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1891 pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1892
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1893 def dumpmenu(self, menu, indent=0, outfile=sys.stdout):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1894 if menu:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1895 currentnode = self.current
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1896 if currentnode != self.topnode: # XXX this is a hack
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1897 print>>outfile, ' '*indent + '<UL>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1898 indent += 2
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1899 for item in menu:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1900 menunode = self.getnode(item)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1901 self.dumpnode(menunode,indent,outfile)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1902 if currentnode != self.topnode: # XXX this is a hack
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1903 print>>outfile, ' '*indent + '</UL>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1904 indent -= 2
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1905
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1906 def getnode(self, nodename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1907 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1908 index = self.nodeindex[nodename]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1909 return self.nodelist[index]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1910 except KeyError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1911 return None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1912 except IndexError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1913 return None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1914
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1915 # (args,nodename) == (key,location)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1916 def dumpindex(self, outfile=sys.stdout):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1917 print>>outfile, '<UL>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1918 for (key,location) in self.indexlist:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1919 key = self.codeexpand(key)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1920 location = makefile(location)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1921 location = self.dirname + '/' + location
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1922 print>>outfile, '<LI><OBJECT type="text/sitemap">',
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1923 print>>outfile, '<param name="Name" value="' + key + '">',
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1924 print>>outfile, '<param name="Local" value="' + location + '">',
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1925 print>>outfile, '</OBJECT>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1926 print>>outfile, '</UL>'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1927
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1928 def codeexpand(self, line):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1929 co = self.codeprog.match(line)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1930 if not co:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1931 return line
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1932 bgn, end = co.span(0)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1933 a, b = co.span(1)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1934 line = line[:bgn] + line[a:b] + line[end:]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1935 return line
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1936
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1937
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1938 # Put @var{} around alphabetic substrings
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1939 def makevar(str):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1940 return '@var{'+str+'}'
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1941
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1942
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1943 # Split a string in "words" according to findwordend
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1944 def splitwords(str, minlength):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1945 words = []
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1946 i = 0
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1947 n = len(str)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1948 while i < n:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1949 while i < n and str[i] in ' \t\n': i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1950 if i >= n: break
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1951 start = i
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1952 i = findwordend(str, i, n)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1953 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
1954 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
1955 return words
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1956
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1957
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1958 # 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
1959 fwprog = re.compile('[@{} ]')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1960 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
1961 level = 0
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1962 while i < n:
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1963 mo = fwprog.search(str, i)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1964 if not mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1965 break
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1966 i = mo.start()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1967 c = str[i]; i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1968 if c == '@': i = i+1 # Next character is not special
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1969 elif c == '{': level = level+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1970 elif c == '}': level = level-1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1971 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
1972 return n
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1973
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1974
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1975 # Convert a node name into a file name
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1976 def makefile(nodename):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1977 nodename = nodename.strip()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1978 return fixfunnychars(nodename) + '.html'
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1979
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1980
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1981 # 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
1982 goodchars = string.ascii_letters + string.digits + '!@-=+.'
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1983
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1984 # 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
1985 # 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
1986 # 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
1987 # 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
1988 def fixfunnychars(addr):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1989 i = 0
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1990 while i < len(addr):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1991 c = addr[i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1992 if c not in goodchars:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1993 c = '-'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1994 addr = addr[:i] + c + addr[i+1:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1995 i = i + len(c)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1996 return addr
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1997
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1998
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1999 # Increment a string used as an enumeration
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2000 def increment(s):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2001 if not s:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2002 return '1'
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2003 for sequence in string.digits, string.lowercase, string.uppercase:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2004 lastc = s[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2005 if lastc in sequence:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
2006 i = sequence.index(lastc) + 1
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2007 if i >= len(sequence):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2008 if len(s) == 1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2009 s = sequence[0]*2
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2010 if s == '00':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2011 s = '10'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2012 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2013 s = increment(s[:-1]) + sequence[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2014 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2015 s = s[:-1] + sequence[i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2016 return s
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2017 return s # Don't increment
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2018
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2019
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2020 def test():
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2021 import sys
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2022 debugging = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2023 print_headers = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2024 cont = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2025 html3 = 0
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2026 htmlhelp = ''
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 9309
diff changeset
2027
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2028 while sys.argv[1] == ['-d']:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2029 debugging = debugging + 1
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2030 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
2031 if sys.argv[1] == '-p':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2032 print_headers = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2033 del sys.argv[1]
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2034 if sys.argv[1] == '-c':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2035 cont = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2036 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
2037 if sys.argv[1] == '-3':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2038 html3 = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2039 del sys.argv[1]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2040 if sys.argv[1] == '-H':
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2041 helpbase = sys.argv[2]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2042 del sys.argv[1:3]
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2043 if len(sys.argv) <> 3:
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2044 print 'usage: texi2hh [-d [-d]] [-p] [-c] [-3] [-H htmlhelp]', \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2045 'inputfile outputdirectory'
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2046 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
2047
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2048 if html3:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2049 parser = TexinfoParserHTML3()
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2050 else:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2051 parser = TexinfoParser()
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2052 parser.cont = cont
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2053 parser.debugging = debugging
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2054 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
2055
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2056 file = sys.argv[1]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2057 dirname = sys.argv[2]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2058 parser.setdirname(dirname)
32734
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2059 parser.setincludedir(os.path.dirname(file))
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2060
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2061 htmlhelp = HTMLHelp(helpbase, dirname)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2062 parser.sethtmlhelp(htmlhelp)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2063
32734
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2064 try:
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2065 fp = open(file, 'r')
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2066 except IOError, msg:
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2067 print file, ':', msg
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2068 sys.exit(1)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2069
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2070 parser.parse(fp)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2071 fp.close()
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2072 parser.report()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2073
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2074 htmlhelp.finalize()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2075
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2076
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2077 if __name__ == "__main__":
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2078 test()