• Home
  • Raw
  • Download

Lines Matching +full:- +full:print +full:- +full:file +full:- +full:name

3 # Convert GNU texinfo files into HTML, one file per node.
5 # Usage: texi2html [-d] [-d] [-c] inputfile outputdirectory
6 # The input file must be a complete texinfo file, e.g. emacs.texi.
8 # overwriting existing files of the same name. All files created have
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?)
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
38 # rpyron 2002-05-07
48 # @image image file reference (see note below)
52 # 6. I added a new command-line option, '-H basename', to specify
55 # `basename`.hhp HTML Help Workshop project file
56 # `basename`.hhc Contents file for the project
57 # `basename`.hhk Index file for the project
58 # When fed into HTML Help Workshop, the resulting file will be
73 cmprog = re.compile('^@([a-z]+)([ \t]|$)') # Command (line-oriented)
75 kwprog = re.compile('@[a-z]+') # Keyword (embedded, usually
83 # ----- ---------- ---------
84 # -|-----------------------------
85 # -----------------------------------------------------
97 DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'
103 def __init__(self, dir, name, topname, title, next, prev, up): argument
105 self.name = name
109 self.topname = name
121 with open(self.dirname + '/' + makefile(self.name), 'w') as fp:
151 ' <!-- Converted with texi2html and Python -->\n'
176 if self.name != self.topname:
182 DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 3//EN//3.0">'
195 FN_SOURCE_PATTERN = '<A NAME=footnoteref%(id)s' \
198 FN_TARGET_PATTERN = '<A NAME=footnotetext%(id)s' \
209 self.unknown = {} # statistics about unknown @-commands
212 self.print_headers = 0 # always print headers?
213 self.nodefp = None # open file we're writing to
221 self.nodename = '' # name of current node
222 self.topname = '' # name of top node (first node seen)
234 self.itemindex = None # Reset item index name
244 # Set (output) directory name
248 # Set include directory name
252 # Parse the contents of an entire file
260 raise SyntaxError('file does not begin with %r' % (MAGIC,))
263 # Parse the contents of a file, not expecting a MAGIC header
278 print('*** EOF before @bye')
309 print('*** Still skipping at the end')
311 print('*** Stack not empty at the end')
312 print('***', self.stack)
315 self.nodestack[-1].finalize()
316 self.nodestack[-1].flush()
317 del self.nodestack[-1]
319 # Start saving text in a buffer instead of writing it to a file
323 # print '*** Recursively saving text, expect trouble'
326 # Return the text saved so far and start writing to file again
330 self.savetext = self.savestack[-1]
331 del self.savestack[-1]
336 # Write text to file, or save it in a buffer, or ignore it
341 print(args)
350 # Complete the current node -- write footnotes and close file
353 print('*** Still saving text at end of node')
360 [name, next, prev, up] = self.nodelinks[:4]
381 # Process a list of lines, expanding embedded @-commands
385 print('!'*self.debugging, 'process:', self.skip, self.stack, end=' ')
386 if accu: print(accu[0][:30], end=' ')
387 if accu[0][30:] or accu[1:]: print('...', end=' ')
388 print()
420 # print 'inmenu :', self.skip, self.stack, self.stackinfo
422 while stack and stack[-1] in ('ifset','ifclear'):
428 stack = stack[:-1]
429 return (stack and stack[-1] == 'menu')
431 # Write a string, expanding embedded @-commands
464 print('*** Unmatched }')
467 cmd = stack[-1]
468 del stack[-1]
482 # @ plus non-letter: literal next character
490 # `@.' means a sentence-ending period;
512 print('*** Stack not empty at para:', stack)
514 # --- Handle unknown embedded @-commands ---
517 print('*** No open func for @' + cmd + '{...}')
526 print('*** No close func for @' + cmd + '{...}')
535 print('*** No handler for @' + cmd)
544 # --- Embedded @-commands without {} argument list --
550 # --- Include file handling ---
553 file = args
554 file = os.path.join(self.includedir, file)
556 fp = open(file, 'r')
558 print('*** Can\'t open include file', repr(file))
561 print('!'*self.debugging, '--> file', repr(file))
567 self.includedepth = self.includedepth - 1
571 print('!'*self.debugging, '<-- file', repr(file))
573 # --- Special Insertions ---
591 def open_minus(self): self.write('-')
594 # --- Accents ---
596 # rpyron 2002-05-07
611 # @tieaccent{oo} @tieaccent{oo} tie-after accent
616 # @exclamdown{} &#161; upside-down !
617 # @questiondown{} &#191; upside-down ?
622 # @l{},@L{} l/,L/ suppressed-L,l
625 # @ss{} &#223; es-zet or sharp S
630 def open_exclamdown(self): self.write('&#161;') # upside-down !
632 def open_questiondown(self): self.write('&#191;') # upside-down ?
646 def open_ss(self): self.write('&#223;') # es-zet or sharp S
652 def open_l(self): self.write('l/') # suppressed-l
654 def open_L(self): self.write('L/') # suppressed-L
657 # --- Special Glyphs for Examples ---
665 def open_print(self): self.write('-|')
668 def open_error(self): self.write('error--&gt;')
674 def open_point(self): self.write('-!-')
677 # --- Cross References ---
697 self.write('See info file ')
704 file = args[2]
705 self.write('`', file, '\', node `', node, '\'')
713 file = args[3]
716 if file:
717 href = '../' + file + '/' + href
720 # rpyron 2002-05-07 uref support
732 # rpyron 2002-05-07 image support
767 print("*** Cannot find image " + imagelocation)
777 # --- Marking Words and Phrases ---
779 # --- Other @xxx{...} commands ---
807 # print '*** Recursive footnote -- expect weirdness'
874 print('!'*self.debugging, 'command:', self.skip, self.stack, \
893 print('*** unknown', '@' + cmd, args)
902 print('*** @end w/o args')
905 if not self.stack or self.stack[-1] != cmd:
906 print('*** @end', cmd, 'unexpected')
908 del self.stack[-1]
918 print('*** unknown', '@' + cmd)
924 # --- Comments ---
929 # --- Conditional processing ---
935 def end_iftex(self): self.skip = self.skip - 1
938 def end_ignore(self): self.skip = self.skip - 1
941 def end_tex(self): self.skip = self.skip - 1
964 self.skip = self.skip - 1
967 print('*** end_ifset: KeyError :', len(self.stack) + 1)
978 self.skip = self.skip - 1
981 print('*** end_ifclear: KeyError :', len(self.stack) + 1)
991 print('*** Undefined value: ', key)
993 # --- Beginning a file ---
1005 # --- Ending a file ---
1011 # --- Title page ---
1014 def end_titlepage(self): self.skip = self.skip - 1
1042 # --- Nodes ---
1050 [name, next, prev, up] = parts[:4]
1051 file = self.dirname + '/' + makefile(name)
1052 if file in self.filenames:
1053 print('*** Filename already in use: ', file)
1055 if self.debugging: print('!'*self.debugging, '--- writing', file)
1056 self.filenames[file] = 1
1057 # self.nodefp = open(file, 'w')
1058 self.nodename = name
1060 self.nodestack[-1].cont = self.nodename
1061 if not self.topname: self.topname = name
1062 title = name
1063 if self.title: title = title + ' -- ' + self.title
1066 self.htmlhelp.addnode(self.nodename,next,prev,up,file)
1077 # --- Sectioning commands ---
1083 if self.nodestack[-1].type > type:
1084 self.nodestack[-1].finalize()
1085 self.nodestack[-1].flush()
1086 del self.nodestack[-1]
1087 elif self.nodestack[-1].type == type:
1088 if not self.nodestack[-1].next:
1089 self.nodestack[-1].next = self.node.name
1091 self.node.prev = self.nodestack[-1].name
1092 self.nodestack[-1].finalize()
1093 self.nodestack[-1].flush()
1094 del self.nodestack[-1]
1097 self.node.up = self.nodestack[-1].name
1105 self.heading('H1', args, -1)
1108 self.heading('H1', args, -1)
1111 self.heading('H1', args, -1)
1113 self.heading('H1', args, -1)
1115 self.heading('H1', args, -1)
1122 self.heading('H1', args, -1)
1125 self.heading('H1', args, -1)
1129 self.heading('H1', args, -1)
1135 self.heading('H2', args, -1)
1138 self.heading('H2', args, -1)
1141 self.heading('H2', args, -1)
1147 self.heading('H3', args, -1)
1150 self.heading('H3', args, -1)
1153 self.heading('H3', args, -1)
1170 print('---', args)
1187 if level > prevlevels[-1]:
1189 self.write(' '*prevlevels[-1], '<UL PLAIN>\n')
1191 elif level < prevlevels[-1]:
1193 while level < prevlevels[-1]:
1194 del prevlevels[-1]
1195 self.write(' '*prevlevels[-1],
1203 # --- Page lay-out ---
1214 # --- Line lay-out ---
1225 # --- Function and variable definitions ---
1237 [category, name], rest = words[:2], words[2:]
1238 self.expand('@b{%s}' % name)
1240 #self.expand(' -- ' + category)
1242 self.index('fn', name)
1265 [category, name], rest = words[:2], words[2:]
1266 self.expand('@code{%s}' % name)
1269 #self.expand(' -- ' + category)
1271 self.index('vr', name)
1281 # --- Ditto for typed languages ---
1292 [category, datatype, name], rest = words[:3], words[3:]
1293 self.expand('@code{%s} @b{%s}' % (datatype, name))
1295 #self.expand(' -- ' + category)
1297 self.index('fn', name)
1313 [category, datatype, name], rest = words[:3], words[3:]
1314 self.expand('@code{%s} @b{%s}' % (datatype, name))
1317 #self.expand(' -- ' + category)
1319 self.index('fn', name)
1327 # --- Ditto for object-oriented languages ---
1338 [category, classname, name], rest = words[:3], words[3:]
1339 self.expand('@b{%s}' % name)
1342 #self.expand(' -- %s of @code{%s}' % (category, classname))
1344 self.index('vr', '%s @r{on %s}' % (name, classname))
1361 [category, classname, name], rest = words[:3], words[3:]
1362 self.expand('@b{%s}' % name)
1364 #self.expand(' -- %s of @code{%s}' % (category, classname))
1366 self.index('fn', '%s @r{on %s}' % (name, classname))
1374 # --- Ditto for data types ---
1385 [category, name], rest = words[:2], words[2:]
1386 self.expand('@b{%s}' % name)
1388 #self.expand(' -- ' + category)
1390 self.index('tp', name)
1392 # --- Making Lists and Tables
1442 # some other character, e.g. '-'
1447 if self.stack and self.stack[-1] == 'table':
1451 elif self.stack and self.stack[-1] == 'multitable':
1461 # rpyron 2002-05-07 multitable support
1474 # --- Enumerations, displays, quotations ---
1485 self.nofill = self.nofill - 1
1510 self.nofill = self.nofill - 1
1517 self.nofill = self.nofill - 1
1530 # --- Indices ---
1543 for name in self.indextitle:
1544 self.whichindex[name] = []
1546 def user_index(self, name, args): argument
1547 if name in self.whichindex:
1548 self.index(name, args)
1550 print('*** No index named', repr(name))
1559 def index(self, name, args): argument
1560 self.whichindex[name].append((args, self.nodename))
1566 print('*** bad @synindex', args)
1571 print('*** bad key(s) in @synindex', args)
1582 for name in words:
1583 if name in self.whichindex:
1584 self.prindex(name)
1586 print('*** No index named', repr(name))
1588 def prindex(self, name): argument
1589 iscodeindex = (name not in self.noncodeindices)
1590 index = self.whichindex[name]
1593 print('!'*self.debugging, '--- Generating', \
1594 self.indextitle[name], 'index')
1597 junkprog = re.compile('^(@[a-z]+)?{')
1601 # -- don't bother about the matching `}'
1617 if self.debugging > 1: print('!'*self.debugging, key, ':', node)
1626 # --- Final error reports ---
1630 print('--- Unrecognized commands ---')
1633 print(cmd.ljust(20), self.unknown[cmd])
1660 self.nofill = self.nofill - 1
1671 self.nofill = self.nofill - 1
1680 # rpyron 2002-05-07
1684 file names, menu items, index items, and image file names are
1688 `helpbase`.hhp is a HTML Help Workshop project file.
1693 `helpbase`.hhc is the Contents file for the project.
1694 `helpbase`.hhk is the Index file for the project.
1697 the resulting file will be named:
1702 the .CHM file will have Contents, Index, Search, and
1724 def addnode(self,name,next,prev,up,filename): argument
1725 node = (name,next,prev,up,filename)
1726 # add this file to dict
1730 self.nodeindex[name] = len(self.nodelist)
1733 self.current = name
1766 # get the default topic file
1770 # PROJECT FILE
1773 print('[OPTIONS]', file=fp)
1774 print('Auto Index=Yes', file=fp)
1775 print('Binary TOC=No', file=fp)
1776 print('Binary Index=Yes', file=fp)
1777 print('Compatibility=1.1', file=fp)
1778 print('Compiled file=' + resultfile + '', file=fp)
1779 print('Contents file=' + contentfile + '', file=fp)
1780 print('Default topic=' + defaulttopic + '', file=fp)
1781 print('Error log file=ErrorLog.log', file=fp)
1782 print('Index file=' + indexfile + '', file=fp)
1783 print('Title=' + title + '', file=fp)
1784 print('Display compile progress=Yes', file=fp)
1785 print('Full-text search=Yes', file=fp)
1786 print('Default window=main', file=fp)
1787 print('', file=fp)
1788 print('[WINDOWS]', file=fp)
1789 print('main=,"' + contentfile + '","' + indexfile
1791 '0xB0000,,,,,,0', file=fp)
1792 print('', file=fp)
1793 print('[FILES]', file=fp)
1794 print('', file=fp)
1797 print(projectfile, ':', msg)
1800 # CONTENT FILE
1803 print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
1804 print('<!-- This file defines the table of contents -->', file=fp)
1805 print('<HTML>', file=fp)
1806 print('<HEAD>', file=fp)
1807 print('<meta name="GENERATOR" '
1808 'content="Microsoft&reg; HTML Help Workshop 4.1">', file=fp)
1809 print('<!-- Sitemap 1.0 -->', file=fp)
1810 print('</HEAD>', file=fp)
1811 print('<BODY>', file=fp)
1812 print(' <OBJECT type="text/site properties">', file=fp)
1813 print(' <param name="Window Styles" value="0x800025">', file=fp)
1814 print(' <param name="comment" value="title:">', file=fp)
1815 print(' <param name="comment" value="base:">', file=fp)
1816 print(' </OBJECT>', file=fp)
1818 print('</BODY>', file=fp)
1819 print('</HTML>', file=fp)
1821 print(contentfile, ':', msg)
1824 # INDEX FILE
1827 print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
1828 print('<!-- This file defines the index -->', file=fp)
1829 print('<HTML>', file=fp)
1830 print('<HEAD>', file=fp)
1831 print('<meta name="GENERATOR" '
1832 'content="Microsoft&reg; HTML Help Workshop 4.1">', file=fp)
1833 print('<!-- Sitemap 1.0 -->', file=fp)
1834 print('</HEAD>', file=fp)
1835 print('<BODY>', file=fp)
1836 print('<OBJECT type="text/site properties">', file=fp)
1837 print('</OBJECT>', file=fp)
1839 print('</BODY>', file=fp)
1840 print('</HTML>', file=fp)
1842 print(indexfile , ':', msg)
1848 print(filename, file=outfile)
1856 print('<UL>', file=outfile)
1859 print('</UL>', file=outfile)
1872 # Print info for this node
1873 print(' '*indent, end=' ', file=outfile)
1874 print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
1875 print('<param name="Name" value="' + nodename +'">', end=' ', file=outfile)
1876 print('<param name="Local" value="'+ filename +'">', end=' ', file=outfile)
1877 print('</OBJECT>', file=outfile)
1890 print(' '*indent + '<UL>', file=outfile)
1896 print(' '*indent + '</UL>', file=outfile)
1897 indent -= 2
1910 print('<UL>', file=outfile)
1915 print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
1916 print('<param name="Name" value="' + key + '">', end=' ', file=outfile)
1917 print('<param name="Local" value="' + location + '">', end=' ', file=outfile)
1918 print('</OBJECT>', file=outfile)
1919 print('</UL>', file=outfile)
1963 elif c == '}': level = level-1
1964 elif c == ' ' and level <= 0: return i-1
1968 # Convert a node name into a file name
1975 goodchars = string.ascii_letters + string.digits + '!@-=+.'
1986 c = '-'
1997 lastc = s[-1]
2006 s = increment(s[:-1]) + sequence[0]
2008 s = s[:-1] + sequence[i]
2021 while sys.argv[1] == ['-d']:
2024 if sys.argv[1] == '-p':
2027 if sys.argv[1] == '-c':
2030 if sys.argv[1] == '-3':
2033 if sys.argv[1] == '-H':
2037 print('usage: texi2hh [-d [-d]] [-p] [-c] [-3] [-H htmlhelp]', \
2049 file = sys.argv[1]
2052 parser.setincludedir(os.path.dirname(file))
2058 fp = open(file, 'r')
2060 print(file, ':', msg)