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