1998-04-23 19:59:33 -03:00
|
|
|
#! /usr/bin/env python
|
1995-03-15 07:26:05 -04:00
|
|
|
|
|
|
|
# Convert GNU texinfo files into HTML, one file per node.
|
|
|
|
# Based on Texinfo 2.14.
|
1995-08-28 00:01:00 -03:00
|
|
|
# Usage: texi2html [-d] [-d] [-c] inputfile outputdirectory
|
1995-03-15 07:26:05 -04:00
|
|
|
# The input file must be a complete texinfo file, e.g. emacs.texi.
|
|
|
|
# This creates many files (one per info node) in the output directory,
|
|
|
|
# overwriting existing files of the same name. All files created have
|
|
|
|
# ".html" as their extension.
|
|
|
|
|
|
|
|
|
|
|
|
# XXX To do:
|
|
|
|
# - handle @comment*** correctly
|
|
|
|
# - handle @xref {some words} correctly
|
|
|
|
# - handle @ftable correctly (items aren't indexed?)
|
|
|
|
# - handle @itemx properly
|
|
|
|
# - handle @exdent properly
|
|
|
|
# - add links directly to the proper line from indices
|
|
|
|
# - check against the definitive list of @-cmds; we still miss (among others):
|
|
|
|
# - @defindex (hard)
|
|
|
|
# - @c(omment) in the middle of a line (rarely used)
|
|
|
|
# - @this* (not really needed, only used in headers anyway)
|
|
|
|
# - @today{} (ever used outside title page?)
|
|
|
|
|
1995-08-28 00:01:00 -03:00
|
|
|
# More consistent handling of chapters/sections/etc.
|
|
|
|
# Lots of documentation
|
|
|
|
# Many more options:
|
1998-09-14 13:03:02 -03:00
|
|
|
# -top designate top node
|
|
|
|
# -links customize which types of links are included
|
|
|
|
# -split split at chapters or sections instead of nodes
|
|
|
|
# -name Allow different types of filename handling. Non unix systems
|
|
|
|
# will have problems with long node names
|
|
|
|
# ...
|
1995-08-28 00:01:00 -03:00
|
|
|
# Support the most recent texinfo version and take a good look at HTML 3.0
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
# More debugging output (customizable) and more flexible error handling
|
1995-08-28 00:01:00 -03:00
|
|
|
# How about icons ?
|
1995-03-15 07:26:05 -04:00
|
|
|
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
# rpyron 2002-05-07
|
|
|
|
# Robert Pyron <rpyron@alum.mit.edu>
|
|
|
|
# 1. BUGFIX: In function makefile(), strip blanks from the nodename.
|
|
|
|
# This is necesary to match the behavior of parser.makeref() and
|
|
|
|
# parser.do_node().
|
|
|
|
# 2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
|
|
|
|
# it go away, rather than fix it)
|
|
|
|
# 3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
|
|
|
|
# 4. Support added for:
|
|
|
|
# @uref URL reference
|
|
|
|
# @image image file reference (see note below)
|
|
|
|
# @multitable output an HTML table
|
|
|
|
# @vtable
|
|
|
|
# 5. Partial support for accents, to match MAKEINFO output
|
|
|
|
# 6. I added a new command-line option, '-H basename', to specify
|
|
|
|
# HTML Help output. This will cause three files to be created
|
|
|
|
# in the current directory:
|
|
|
|
# `basename`.hhp HTML Help Workshop project file
|
|
|
|
# `basename`.hhc Contents file for the project
|
|
|
|
# `basename`.hhk Index file for the project
|
|
|
|
# When fed into HTML Help Workshop, the resulting file will be
|
|
|
|
# named `basename`.chm.
|
|
|
|
# 7. A new class, HTMLHelp, to accomplish item 6.
|
|
|
|
# 8. Various calls to HTMLHelp functions.
|
|
|
|
# A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
|
|
|
|
# running this program, all referenced images must already exist
|
|
|
|
# in outputdirectory.
|
|
|
|
|
1995-03-15 07:26:05 -04:00
|
|
|
import os
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
import sys
|
1995-03-15 07:26:05 -04:00
|
|
|
import string
|
1998-04-23 19:59:33 -03:00
|
|
|
import re
|
1995-03-15 07:26:05 -04:00
|
|
|
|
|
|
|
MAGIC = '\\input texinfo'
|
|
|
|
|
1998-04-23 19:59:33 -03:00
|
|
|
cmprog = re.compile('^@([a-z]+)([ \t]|$)') # Command (line-oriented)
|
|
|
|
blprog = re.compile('^[ \t]*$') # Blank line
|
|
|
|
kwprog = re.compile('@[a-z]+') # Keyword (embedded, usually
|
|
|
|
# with {} args)
|
|
|
|
spprog = re.compile('[\n@{}&<>]') # Special characters in
|
2001-01-17 04:48:39 -04:00
|
|
|
# running text
|
1998-04-23 19:59:33 -03:00
|
|
|
#
|
|
|
|
# menu item (Yuck!)
|
|
|
|
miprog = re.compile('^\* ([^:]*):(:|[ \t]*([^\t,\n.]+)([^ \t\n]*))[ \t\n]*')
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
# 0 1 1 2 3 34 42 0
|
|
|
|
# ----- ---------- ---------
|
|
|
|
# -|-----------------------------
|
|
|
|
# -----------------------------------------------------
|
|
|
|
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1995-08-28 00:01:00 -03:00
|
|
|
|
2001-01-17 04:48:39 -04:00
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
class HTMLNode:
|
|
|
|
"""Some of the parser's functionality is separated into this class.
|
1995-08-28 00:01:00 -03:00
|
|
|
|
|
|
|
A Node accumulates its contents, takes care of links to other Nodes
|
1996-10-09 16:05:12 -03:00
|
|
|
and saves itself when it is finished and all links are resolved.
|
|
|
|
"""
|
1996-09-13 11:44:34 -03:00
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'
|
|
|
|
|
|
|
|
type = 0
|
|
|
|
cont = ''
|
|
|
|
epilogue = '</BODY></HTML>\n'
|
|
|
|
|
|
|
|
def __init__(self, dir, name, topname, title, next, prev, up):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.dirname = dir
|
|
|
|
self.name = name
|
|
|
|
if topname:
|
|
|
|
self.topname = topname
|
|
|
|
else:
|
|
|
|
self.topname = name
|
|
|
|
self.title = title
|
|
|
|
self.next = next
|
|
|
|
self.prev = prev
|
|
|
|
self.up = up
|
|
|
|
self.lines = []
|
1996-09-13 11:44:34 -03:00
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
def write(self, *lines):
|
1998-09-14 13:03:02 -03:00
|
|
|
map(self.lines.append, lines)
|
1995-08-28 00:01:00 -03:00
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
def flush(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
fp = open(self.dirname + '/' + makefile(self.name), 'w')
|
|
|
|
fp.write(self.prologue)
|
|
|
|
fp.write(self.text)
|
|
|
|
fp.write(self.epilogue)
|
|
|
|
fp.close()
|
1996-09-13 11:44:34 -03:00
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
def link(self, label, nodename, rel=None, rev=None):
|
1998-09-14 13:03:02 -03:00
|
|
|
if nodename:
|
2002-06-18 12:37:05 -03:00
|
|
|
if nodename.lower() == '(dir)':
|
1998-09-14 13:03:02 -03:00
|
|
|
addr = '../dir.html'
|
|
|
|
title = ''
|
|
|
|
else:
|
|
|
|
addr = makefile(nodename)
|
|
|
|
title = ' TITLE="%s"' % nodename
|
|
|
|
self.write(label, ': <A HREF="', addr, '"', \
|
|
|
|
rel and (' REL=' + rel) or "", \
|
|
|
|
rev and (' REV=' + rev) or "", \
|
|
|
|
title, '>', nodename, '</A> \n')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
1995-08-28 00:01:00 -03:00
|
|
|
def finalize(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
length = len(self.lines)
|
2002-06-18 12:37:05 -03:00
|
|
|
self.text = ''.join(self.lines)
|
1998-09-14 13:03:02 -03:00
|
|
|
self.lines = []
|
|
|
|
self.open_links()
|
|
|
|
self.output_links()
|
|
|
|
self.close_links()
|
2002-06-18 12:37:05 -03:00
|
|
|
links = ''.join(self.lines)
|
1998-09-14 13:03:02 -03:00
|
|
|
self.lines = []
|
|
|
|
self.prologue = (
|
|
|
|
self.DOCTYPE +
|
|
|
|
'\n<HTML><HEAD>\n'
|
|
|
|
' <!-- Converted with texi2html and Python -->\n'
|
|
|
|
' <TITLE>' + self.title + '</TITLE>\n'
|
|
|
|
' <LINK REL=Next HREF="'
|
|
|
|
+ makefile(self.next) + '" TITLE="' + self.next + '">\n'
|
|
|
|
' <LINK REL=Previous HREF="'
|
|
|
|
+ makefile(self.prev) + '" TITLE="' + self.prev + '">\n'
|
|
|
|
' <LINK REL=Up HREF="'
|
|
|
|
+ makefile(self.up) + '" TITLE="' + self.up + '">\n'
|
|
|
|
'</HEAD><BODY>\n' +
|
|
|
|
links)
|
|
|
|
if length > 20:
|
|
|
|
self.epilogue = '<P>\n%s</BODY></HTML>\n' % links
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
def open_links(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<HR>\n')
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
def close_links(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<HR>\n')
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
def output_links(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.cont != self.next:
|
|
|
|
self.link(' Cont', self.cont)
|
|
|
|
self.link(' Next', self.next, rel='Next')
|
|
|
|
self.link(' Prev', self.prev, rel='Previous')
|
|
|
|
self.link(' Up', self.up, rel='Up')
|
|
|
|
if self.name <> self.topname:
|
|
|
|
self.link(' Top', self.topname)
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
|
|
|
|
class HTML3Node(HTMLNode):
|
|
|
|
|
|
|
|
DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 3//EN//3.0">'
|
|
|
|
|
|
|
|
def open_links(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DIV CLASS=Navigation>\n <HR>\n')
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
def close_links(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write(' <HR>\n</DIV>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
1995-08-28 00:01:00 -03:00
|
|
|
|
1995-03-15 07:26:05 -04:00
|
|
|
class TexinfoParser:
|
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
COPYRIGHT_SYMBOL = "©"
|
|
|
|
FN_ID_PATTERN = "(%(id)s)"
|
|
|
|
FN_SOURCE_PATTERN = '<A NAME=footnoteref%(id)s' \
|
1998-09-14 13:03:02 -03:00
|
|
|
' HREF="#footnotetext%(id)s">' \
|
|
|
|
+ FN_ID_PATTERN + '</A>'
|
1996-10-09 16:05:12 -03:00
|
|
|
FN_TARGET_PATTERN = '<A NAME=footnotetext%(id)s' \
|
1998-09-14 13:03:02 -03:00
|
|
|
' HREF="#footnoteref%(id)s">' \
|
|
|
|
+ FN_ID_PATTERN + '</A>\n%(text)s<P>\n'
|
1996-10-11 13:54:00 -03:00
|
|
|
FN_HEADER = '\n<P>\n<HR NOSHADE SIZE=1 WIDTH=200>\n' \
|
1998-09-14 13:03:02 -03:00
|
|
|
'<STRONG><EM>Footnotes</EM></STRONG>\n<P>'
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
|
|
|
|
Node = HTMLNode
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
# Initialize an instance
|
|
|
|
def __init__(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.unknown = {} # statistics about unknown @-commands
|
|
|
|
self.filenames = {} # Check for identical filenames
|
|
|
|
self.debugging = 0 # larger values produce more output
|
|
|
|
self.print_headers = 0 # always print headers?
|
|
|
|
self.nodefp = None # open file we're writing to
|
|
|
|
self.nodelineno = 0 # Linenumber relative to node
|
|
|
|
self.links = None # Links from current node
|
|
|
|
self.savetext = None # If not None, save text head instead
|
|
|
|
self.savestack = [] # If not None, save text head instead
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.htmlhelp = None # html help data
|
1998-09-14 13:03:02 -03:00
|
|
|
self.dirname = 'tmp' # directory where files are created
|
|
|
|
self.includedir = '.' # directory to search @include files
|
|
|
|
self.nodename = '' # name of current node
|
|
|
|
self.topname = '' # name of top node (first node seen)
|
|
|
|
self.title = '' # title of this whole Texinfo tree
|
|
|
|
self.resetindex() # Reset all indices
|
|
|
|
self.contents = [] # Reset table of contents
|
|
|
|
self.numbering = [] # Reset section numbering counters
|
|
|
|
self.nofill = 0 # Normal operation: fill paragraphs
|
|
|
|
self.values={'html': 1} # Names that should be parsed in ifset
|
|
|
|
self.stackinfo={} # Keep track of state in the stack
|
|
|
|
# XXX The following should be reset per node?!
|
|
|
|
self.footnotes = [] # Reset list of footnotes
|
|
|
|
self.itemarg = None # Reset command used by @item
|
|
|
|
self.itemnumber = None # Reset number for @item in @enumerate
|
|
|
|
self.itemindex = None # Reset item index name
|
|
|
|
self.node = None
|
|
|
|
self.nodestack = []
|
|
|
|
self.cont = 0
|
|
|
|
self.includedepth = 0
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
|
|
|
|
# Set htmlhelp helper class
|
|
|
|
def sethtmlhelp(self, htmlhelp):
|
|
|
|
self.htmlhelp = htmlhelp
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
# Set (output) directory name
|
|
|
|
def setdirname(self, dirname):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.dirname = dirname
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# Set include directory name
|
|
|
|
def setincludedir(self, includedir):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.includedir = includedir
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# Parse the contents of an entire file
|
|
|
|
def parse(self, fp):
|
1998-09-14 13:03:02 -03:00
|
|
|
line = fp.readline()
|
|
|
|
lineno = 1
|
|
|
|
while line and (line[0] == '%' or blprog.match(line)):
|
|
|
|
line = fp.readline()
|
|
|
|
lineno = lineno + 1
|
|
|
|
if line[:len(MAGIC)] <> MAGIC:
|
2004-02-12 13:35:32 -04:00
|
|
|
raise SyntaxError, 'file does not begin with %r' % (MAGIC,)
|
1998-09-14 13:03:02 -03:00
|
|
|
self.parserest(fp, lineno)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# Parse the contents of a file, not expecting a MAGIC header
|
|
|
|
def parserest(self, fp, initial_lineno):
|
1998-09-14 13:03:02 -03:00
|
|
|
lineno = initial_lineno
|
|
|
|
self.done = 0
|
|
|
|
self.skip = 0
|
|
|
|
self.stack = []
|
|
|
|
accu = []
|
|
|
|
while not self.done:
|
|
|
|
line = fp.readline()
|
|
|
|
self.nodelineno = self.nodelineno + 1
|
|
|
|
if not line:
|
|
|
|
if accu:
|
|
|
|
if not self.skip: self.process(accu)
|
|
|
|
accu = []
|
|
|
|
if initial_lineno > 0:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** EOF before @bye')
|
1998-09-14 13:03:02 -03:00
|
|
|
break
|
|
|
|
lineno = lineno + 1
|
1998-04-23 19:59:33 -03:00
|
|
|
mo = cmprog.match(line)
|
|
|
|
if mo:
|
|
|
|
a, b = mo.span(1)
|
1998-09-14 13:03:02 -03:00
|
|
|
cmd = line[a:b]
|
|
|
|
if cmd in ('noindent', 'refill'):
|
|
|
|
accu.append(line)
|
|
|
|
else:
|
|
|
|
if accu:
|
|
|
|
if not self.skip:
|
|
|
|
self.process(accu)
|
|
|
|
accu = []
|
|
|
|
self.command(line, mo)
|
|
|
|
elif blprog.match(line) and \
|
|
|
|
'format' not in self.stack and \
|
|
|
|
'example' not in self.stack:
|
|
|
|
if accu:
|
|
|
|
if not self.skip:
|
|
|
|
self.process(accu)
|
|
|
|
if self.nofill:
|
|
|
|
self.write('\n')
|
|
|
|
else:
|
|
|
|
self.write('<P>\n')
|
|
|
|
accu = []
|
|
|
|
else:
|
|
|
|
# Append the line including trailing \n!
|
|
|
|
accu.append(line)
|
|
|
|
#
|
|
|
|
if self.skip:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** Still skipping at the end')
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.stack:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** Stack not empty at the end')
|
|
|
|
print('***', self.stack)
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.includedepth == 0:
|
|
|
|
while self.nodestack:
|
|
|
|
self.nodestack[-1].finalize()
|
|
|
|
self.nodestack[-1].flush()
|
|
|
|
del self.nodestack[-1]
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# Start saving text in a buffer instead of writing it to a file
|
|
|
|
def startsaving(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.savetext <> None:
|
|
|
|
self.savestack.append(self.savetext)
|
|
|
|
# print '*** Recursively saving text, expect trouble'
|
|
|
|
self.savetext = ''
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# Return the text saved so far and start writing to file again
|
|
|
|
def collectsavings(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
savetext = self.savetext
|
|
|
|
if len(self.savestack) > 0:
|
|
|
|
self.savetext = self.savestack[-1]
|
|
|
|
del self.savestack[-1]
|
|
|
|
else:
|
|
|
|
self.savetext = None
|
|
|
|
return savetext or ''
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# Write text to file, or save it in a buffer, or ignore it
|
|
|
|
def write(self, *args):
|
1998-09-14 13:03:02 -03:00
|
|
|
try:
|
2002-06-18 12:37:05 -03:00
|
|
|
text = ''.join(args)
|
1998-09-14 13:03:02 -03:00
|
|
|
except:
|
2007-08-03 14:06:41 -03:00
|
|
|
print(args)
|
1998-09-14 13:03:02 -03:00
|
|
|
raise TypeError
|
|
|
|
if self.savetext <> None:
|
|
|
|
self.savetext = self.savetext + text
|
|
|
|
elif self.nodefp:
|
|
|
|
self.nodefp.write(text)
|
|
|
|
elif self.node:
|
|
|
|
self.node.write(text)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
# Complete the current node -- write footnotes and close file
|
|
|
|
def endnode(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.savetext <> None:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** Still saving text at end of node')
|
1998-09-14 13:03:02 -03:00
|
|
|
dummy = self.collectsavings()
|
|
|
|
if self.footnotes:
|
|
|
|
self.writefootnotes()
|
|
|
|
if self.nodefp:
|
|
|
|
if self.nodelineno > 20:
|
|
|
|
self.write('<HR>\n')
|
|
|
|
[name, next, prev, up] = self.nodelinks[:4]
|
|
|
|
self.link('Next', next)
|
|
|
|
self.link('Prev', prev)
|
|
|
|
self.link('Up', up)
|
|
|
|
if self.nodename <> self.topname:
|
|
|
|
self.link('Top', self.topname)
|
|
|
|
self.write('<HR>\n')
|
|
|
|
self.write('</BODY>\n')
|
|
|
|
self.nodefp.close()
|
|
|
|
self.nodefp = None
|
|
|
|
elif self.node:
|
|
|
|
if not self.cont and \
|
|
|
|
(not self.node.type or \
|
|
|
|
(self.node.next and self.node.prev and self.node.up)):
|
|
|
|
self.node.finalize()
|
|
|
|
self.node.flush()
|
|
|
|
else:
|
|
|
|
self.nodestack.append(self.node)
|
|
|
|
self.node = None
|
|
|
|
self.nodename = ''
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# Process a list of lines, expanding embedded @-commands
|
|
|
|
# This mostly distinguishes between menus and normal text
|
|
|
|
def process(self, accu):
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.debugging > 1:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('!'*self.debugging, 'process:', self.skip, self.stack, end=' ')
|
|
|
|
if accu: print(accu[0][:30], end=' ')
|
|
|
|
if accu[0][30:] or accu[1:]: print('...', end=' ')
|
|
|
|
print()
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
if self.inmenu():
|
1998-09-14 13:03:02 -03:00
|
|
|
# XXX should be done differently
|
|
|
|
for line in accu:
|
1998-04-23 19:59:33 -03:00
|
|
|
mo = miprog.match(line)
|
|
|
|
if not mo:
|
2002-06-18 12:37:05 -03:00
|
|
|
line = line.strip() + '\n'
|
1998-09-14 13:03:02 -03:00
|
|
|
self.expand(line)
|
|
|
|
continue
|
1998-04-23 19:59:33 -03:00
|
|
|
bgn, end = mo.span(0)
|
|
|
|
a, b = mo.span(1)
|
|
|
|
c, d = mo.span(2)
|
|
|
|
e, f = mo.span(3)
|
|
|
|
g, h = mo.span(4)
|
1998-09-14 13:03:02 -03:00
|
|
|
label = line[a:b]
|
|
|
|
nodename = line[c:d]
|
|
|
|
if nodename[0] == ':': nodename = label
|
|
|
|
else: nodename = line[e:f]
|
|
|
|
punct = line[g:h]
|
|
|
|
self.write(' <LI><A HREF="',
|
|
|
|
makefile(nodename),
|
|
|
|
'">', nodename,
|
|
|
|
'</A>', punct, '\n')
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.htmlhelp.menuitem(nodename)
|
1998-09-14 13:03:02 -03:00
|
|
|
self.expand(line[end:])
|
|
|
|
else:
|
2002-06-18 12:37:05 -03:00
|
|
|
text = ''.join(accu)
|
1998-09-14 13:03:02 -03:00
|
|
|
self.expand(text)
|
1995-03-15 07:26:05 -04:00
|
|
|
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
# find 'menu' (we might be inside 'ifset' or 'ifclear')
|
|
|
|
def inmenu(self):
|
|
|
|
#if 'menu' in self.stack:
|
|
|
|
# print 'inmenu :', self.skip, self.stack, self.stackinfo
|
|
|
|
stack = self.stack
|
|
|
|
while stack and stack[-1] in ('ifset','ifclear'):
|
|
|
|
try:
|
|
|
|
if self.stackinfo[len(stack)]:
|
|
|
|
return 0
|
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
stack = stack[:-1]
|
|
|
|
return (stack and stack[-1] == 'menu')
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
# Write a string, expanding embedded @-commands
|
|
|
|
def expand(self, text):
|
1998-09-14 13:03:02 -03:00
|
|
|
stack = []
|
|
|
|
i = 0
|
|
|
|
n = len(text)
|
|
|
|
while i < n:
|
|
|
|
start = i
|
1998-04-23 19:59:33 -03:00
|
|
|
mo = spprog.search(text, i)
|
|
|
|
if mo:
|
|
|
|
i = mo.start()
|
|
|
|
else:
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write(text[start:])
|
|
|
|
break
|
|
|
|
self.write(text[start:i])
|
|
|
|
c = text[i]
|
|
|
|
i = i+1
|
|
|
|
if c == '\n':
|
|
|
|
self.write('\n')
|
|
|
|
continue
|
|
|
|
if c == '<':
|
|
|
|
self.write('<')
|
|
|
|
continue
|
|
|
|
if c == '>':
|
|
|
|
self.write('>')
|
|
|
|
continue
|
|
|
|
if c == '&':
|
|
|
|
self.write('&')
|
|
|
|
continue
|
|
|
|
if c == '{':
|
|
|
|
stack.append('')
|
|
|
|
continue
|
|
|
|
if c == '}':
|
|
|
|
if not stack:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** Unmatched }')
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('}')
|
|
|
|
continue
|
|
|
|
cmd = stack[-1]
|
|
|
|
del stack[-1]
|
|
|
|
try:
|
|
|
|
method = getattr(self, 'close_' + cmd)
|
|
|
|
except AttributeError:
|
|
|
|
self.unknown_close(cmd)
|
|
|
|
continue
|
|
|
|
method()
|
|
|
|
continue
|
|
|
|
if c <> '@':
|
|
|
|
# Cannot happen unless spprog is changed
|
2004-02-12 13:35:32 -04:00
|
|
|
raise RuntimeError, 'unexpected funny %r' % c
|
1998-09-14 13:03:02 -03:00
|
|
|
start = i
|
2001-07-20 16:05:50 -03:00
|
|
|
while i < n and text[i] in string.ascii_letters: i = i+1
|
1998-09-14 13:03:02 -03:00
|
|
|
if i == start:
|
|
|
|
# @ plus non-letter: literal next character
|
|
|
|
i = i+1
|
|
|
|
c = text[start:i]
|
|
|
|
if c == ':':
|
|
|
|
# `@:' means no extra space after
|
|
|
|
# preceding `.', `?', `!' or `:'
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
# `@.' means a sentence-ending period;
|
|
|
|
# `@@', `@{', `@}' quote `@', `{', `}'
|
|
|
|
self.write(c)
|
|
|
|
continue
|
|
|
|
cmd = text[start:i]
|
|
|
|
if i < n and text[i] == '{':
|
|
|
|
i = i+1
|
|
|
|
stack.append(cmd)
|
|
|
|
try:
|
|
|
|
method = getattr(self, 'open_' + cmd)
|
|
|
|
except AttributeError:
|
|
|
|
self.unknown_open(cmd)
|
|
|
|
continue
|
|
|
|
method()
|
|
|
|
continue
|
|
|
|
try:
|
|
|
|
method = getattr(self, 'handle_' + cmd)
|
|
|
|
except AttributeError:
|
|
|
|
self.unknown_handle(cmd)
|
|
|
|
continue
|
|
|
|
method()
|
|
|
|
if stack:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** Stack not empty at para:', stack)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Handle unknown embedded @-commands ---
|
|
|
|
|
|
|
|
def unknown_open(self, cmd):
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** No open func for @' + cmd + '{...}')
|
1998-09-14 13:03:02 -03:00
|
|
|
cmd = cmd + '{'
|
|
|
|
self.write('@', cmd)
|
|
|
|
if not self.unknown.has_key(cmd):
|
|
|
|
self.unknown[cmd] = 1
|
|
|
|
else:
|
|
|
|
self.unknown[cmd] = self.unknown[cmd] + 1
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def unknown_close(self, cmd):
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** No close func for @' + cmd + '{...}')
|
1998-09-14 13:03:02 -03:00
|
|
|
cmd = '}' + cmd
|
|
|
|
self.write('}')
|
|
|
|
if not self.unknown.has_key(cmd):
|
|
|
|
self.unknown[cmd] = 1
|
|
|
|
else:
|
|
|
|
self.unknown[cmd] = self.unknown[cmd] + 1
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def unknown_handle(self, cmd):
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** No handler for @' + cmd)
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('@', cmd)
|
|
|
|
if not self.unknown.has_key(cmd):
|
|
|
|
self.unknown[cmd] = 1
|
|
|
|
else:
|
|
|
|
self.unknown[cmd] = self.unknown[cmd] + 1
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# XXX The following sections should be ordered as the texinfo docs
|
|
|
|
|
|
|
|
# --- Embedded @-commands without {} argument list --
|
|
|
|
|
|
|
|
def handle_noindent(self): pass
|
|
|
|
|
|
|
|
def handle_refill(self): pass
|
|
|
|
|
|
|
|
# --- Include file handling ---
|
|
|
|
|
|
|
|
def do_include(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
file = args
|
|
|
|
file = os.path.join(self.includedir, file)
|
|
|
|
try:
|
|
|
|
fp = open(file, 'r')
|
2007-01-10 12:19:56 -04:00
|
|
|
except IOError as msg:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** Can\'t open include file', repr(file))
|
1998-09-14 13:03:02 -03:00
|
|
|
return
|
2007-08-03 14:06:41 -03:00
|
|
|
print('!'*self.debugging, '--> file', repr(file))
|
1998-09-14 13:03:02 -03:00
|
|
|
save_done = self.done
|
|
|
|
save_skip = self.skip
|
|
|
|
save_stack = self.stack
|
|
|
|
self.includedepth = self.includedepth + 1
|
|
|
|
self.parserest(fp, 0)
|
|
|
|
self.includedepth = self.includedepth - 1
|
|
|
|
fp.close()
|
|
|
|
self.done = save_done
|
|
|
|
self.skip = save_skip
|
|
|
|
self.stack = save_stack
|
2007-08-03 14:06:41 -03:00
|
|
|
print('!'*self.debugging, '<-- file', repr(file))
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Special Insertions ---
|
|
|
|
|
|
|
|
def open_dmn(self): pass
|
|
|
|
def close_dmn(self): pass
|
|
|
|
|
|
|
|
def open_dots(self): self.write('...')
|
|
|
|
def close_dots(self): pass
|
|
|
|
|
|
|
|
def open_bullet(self): pass
|
|
|
|
def close_bullet(self): pass
|
|
|
|
|
|
|
|
def open_TeX(self): self.write('TeX')
|
|
|
|
def close_TeX(self): pass
|
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
def handle_copyright(self): self.write(self.COPYRIGHT_SYMBOL)
|
|
|
|
def open_copyright(self): self.write(self.COPYRIGHT_SYMBOL)
|
1996-09-13 11:44:34 -03:00
|
|
|
def close_copyright(self): pass
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def open_minus(self): self.write('-')
|
|
|
|
def close_minus(self): pass
|
1995-03-15 07:26:05 -04:00
|
|
|
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
# --- Accents ---
|
|
|
|
|
|
|
|
# rpyron 2002-05-07
|
|
|
|
# I would like to do at least as well as makeinfo when
|
|
|
|
# it is producing HTML output:
|
|
|
|
#
|
|
|
|
# input output
|
|
|
|
# @"o @"o umlaut accent
|
|
|
|
# @'o 'o acute accent
|
|
|
|
# @,{c} @,{c} cedilla accent
|
|
|
|
# @=o @=o macron/overbar accent
|
|
|
|
# @^o @^o circumflex accent
|
|
|
|
# @`o `o grave accent
|
|
|
|
# @~o @~o tilde accent
|
|
|
|
# @dotaccent{o} @dotaccent{o} overdot accent
|
|
|
|
# @H{o} @H{o} long Hungarian umlaut
|
|
|
|
# @ringaccent{o} @ringaccent{o} ring accent
|
|
|
|
# @tieaccent{oo} @tieaccent{oo} tie-after accent
|
|
|
|
# @u{o} @u{o} breve accent
|
|
|
|
# @ubaraccent{o} @ubaraccent{o} underbar accent
|
|
|
|
# @udotaccent{o} @udotaccent{o} underdot accent
|
|
|
|
# @v{o} @v{o} hacek or check accent
|
|
|
|
# @exclamdown{} ¡ upside-down !
|
|
|
|
# @questiondown{} ¿ upside-down ?
|
|
|
|
# @aa{},@AA{} å,Å a,A with circle
|
|
|
|
# @ae{},@AE{} æ,Æ ae,AE ligatures
|
|
|
|
# @dotless{i} @dotless{i} dotless i
|
|
|
|
# @dotless{j} @dotless{j} dotless j
|
|
|
|
# @l{},@L{} l/,L/ suppressed-L,l
|
|
|
|
# @o{},@O{} ø,Ø O,o with slash
|
|
|
|
# @oe{},@OE{} oe,OE oe,OE ligatures
|
|
|
|
# @ss{} ß es-zet or sharp S
|
|
|
|
#
|
|
|
|
# The following character codes and approximations have been
|
|
|
|
# copied from makeinfo's HTML output.
|
|
|
|
|
|
|
|
def open_exclamdown(self): self.write('¡') # upside-down !
|
|
|
|
def close_exclamdown(self): pass
|
|
|
|
def open_questiondown(self): self.write('¿') # upside-down ?
|
|
|
|
def close_questiondown(self): pass
|
|
|
|
def open_aa(self): self.write('å') # a with circle
|
|
|
|
def close_aa(self): pass
|
|
|
|
def open_AA(self): self.write('Å') # A with circle
|
|
|
|
def close_AA(self): pass
|
|
|
|
def open_ae(self): self.write('æ') # ae ligatures
|
|
|
|
def close_ae(self): pass
|
|
|
|
def open_AE(self): self.write('Æ') # AE ligatures
|
|
|
|
def close_AE(self): pass
|
|
|
|
def open_o(self): self.write('ø') # o with slash
|
|
|
|
def close_o(self): pass
|
|
|
|
def open_O(self): self.write('Ø') # O with slash
|
|
|
|
def close_O(self): pass
|
|
|
|
def open_ss(self): self.write('ß') # es-zet or sharp S
|
|
|
|
def close_ss(self): pass
|
|
|
|
def open_oe(self): self.write('oe') # oe ligatures
|
|
|
|
def close_oe(self): pass
|
|
|
|
def open_OE(self): self.write('OE') # OE ligatures
|
|
|
|
def close_OE(self): pass
|
|
|
|
def open_l(self): self.write('l/') # suppressed-l
|
|
|
|
def close_l(self): pass
|
|
|
|
def open_L(self): self.write('L/') # suppressed-L
|
|
|
|
def close_L(self): pass
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
# --- Special Glyphs for Examples ---
|
|
|
|
|
|
|
|
def open_result(self): self.write('=>')
|
|
|
|
def close_result(self): pass
|
|
|
|
|
|
|
|
def open_expansion(self): self.write('==>')
|
|
|
|
def close_expansion(self): pass
|
|
|
|
|
|
|
|
def open_print(self): self.write('-|')
|
|
|
|
def close_print(self): pass
|
|
|
|
|
|
|
|
def open_error(self): self.write('error-->')
|
|
|
|
def close_error(self): pass
|
|
|
|
|
|
|
|
def open_equiv(self): self.write('==')
|
|
|
|
def close_equiv(self): pass
|
|
|
|
|
|
|
|
def open_point(self): self.write('-!-')
|
|
|
|
def close_point(self): pass
|
|
|
|
|
|
|
|
# --- Cross References ---
|
|
|
|
|
|
|
|
def open_pxref(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('see ')
|
|
|
|
self.startsaving()
|
1996-09-13 11:44:34 -03:00
|
|
|
def close_pxref(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.makeref()
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def open_xref(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('See ')
|
|
|
|
self.startsaving()
|
1996-09-13 11:44:34 -03:00
|
|
|
def close_xref(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.makeref()
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def open_ref(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.startsaving()
|
1996-09-13 11:44:34 -03:00
|
|
|
def close_ref(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.makeref()
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def open_inforef(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('See info file ')
|
|
|
|
self.startsaving()
|
1996-09-13 11:44:34 -03:00
|
|
|
def close_inforef(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
text = self.collectsavings()
|
2002-06-18 12:37:05 -03:00
|
|
|
args = [s.strip() for s in text.split(',')]
|
1998-09-14 13:03:02 -03:00
|
|
|
while len(args) < 3: args.append('')
|
|
|
|
node = args[0]
|
|
|
|
file = args[2]
|
|
|
|
self.write('`', file, '\', node `', node, '\'')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def makeref(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
text = self.collectsavings()
|
2002-06-18 12:37:05 -03:00
|
|
|
args = [s.strip() for s in text.split(',')]
|
1998-09-14 13:03:02 -03:00
|
|
|
while len(args) < 5: args.append('')
|
|
|
|
nodename = label = args[0]
|
|
|
|
if args[2]: label = args[2]
|
|
|
|
file = args[3]
|
|
|
|
title = args[4]
|
|
|
|
href = makefile(nodename)
|
|
|
|
if file:
|
|
|
|
href = '../' + file + '/' + href
|
|
|
|
self.write('<A HREF="', href, '">', label, '</A>')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
# rpyron 2002-05-07 uref support
|
|
|
|
def open_uref(self):
|
|
|
|
self.startsaving()
|
|
|
|
def close_uref(self):
|
|
|
|
text = self.collectsavings()
|
2002-06-18 12:37:05 -03:00
|
|
|
args = [s.strip() for s in text.split(',')]
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
while len(args) < 2: args.append('')
|
|
|
|
href = args[0]
|
|
|
|
label = args[1]
|
|
|
|
if not label: label = href
|
|
|
|
self.write('<A HREF="', href, '">', label, '</A>')
|
|
|
|
|
|
|
|
# rpyron 2002-05-07 image support
|
|
|
|
# GNU makeinfo producing HTML output tries `filename.png'; if
|
|
|
|
# that does not exist, it tries `filename.jpg'. If that does
|
|
|
|
# not exist either, it complains. GNU makeinfo does not handle
|
|
|
|
# GIF files; however, I include GIF support here because
|
|
|
|
# MySQL documentation uses GIF files.
|
|
|
|
|
|
|
|
def open_image(self):
|
|
|
|
self.startsaving()
|
|
|
|
def close_image(self):
|
|
|
|
self.makeimage()
|
|
|
|
def makeimage(self):
|
|
|
|
text = self.collectsavings()
|
2002-06-18 12:37:05 -03:00
|
|
|
args = [s.strip() for s in text.split(',')]
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
while len(args) < 5: args.append('')
|
|
|
|
filename = args[0]
|
|
|
|
width = args[1]
|
|
|
|
height = args[2]
|
|
|
|
alt = args[3]
|
|
|
|
ext = args[4]
|
|
|
|
|
|
|
|
# The HTML output will have a reference to the image
|
|
|
|
# that is relative to the HTML output directory,
|
|
|
|
# which is what 'filename' gives us. However, we need
|
|
|
|
# to find it relative to our own current directory,
|
|
|
|
# so we construct 'imagename'.
|
|
|
|
imagelocation = self.dirname + '/' + filename
|
|
|
|
|
|
|
|
if os.path.exists(imagelocation+'.png'):
|
|
|
|
filename += '.png'
|
|
|
|
elif os.path.exists(imagelocation+'.jpg'):
|
|
|
|
filename += '.jpg'
|
|
|
|
elif os.path.exists(imagelocation+'.gif'): # MySQL uses GIF files
|
|
|
|
filename += '.gif'
|
|
|
|
else:
|
2007-08-03 14:06:41 -03:00
|
|
|
print("*** Cannot find image " + imagelocation)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
#TODO: what is 'ext'?
|
|
|
|
self.write('<IMG SRC="', filename, '"', \
|
|
|
|
width and (' WIDTH="' + width + '"') or "", \
|
|
|
|
height and (' HEIGHT="' + height + '"') or "", \
|
|
|
|
alt and (' ALT="' + alt + '"') or "", \
|
|
|
|
'/>' )
|
|
|
|
self.htmlhelp.addimage(imagelocation)
|
|
|
|
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
# --- Marking Words and Phrases ---
|
|
|
|
|
|
|
|
# --- Other @xxx{...} commands ---
|
|
|
|
|
|
|
|
def open_(self): pass # Used by {text enclosed in braces}
|
|
|
|
def close_(self): pass
|
|
|
|
|
|
|
|
open_asis = open_
|
|
|
|
close_asis = close_
|
|
|
|
|
|
|
|
def open_cite(self): self.write('<CITE>')
|
|
|
|
def close_cite(self): self.write('</CITE>')
|
|
|
|
|
|
|
|
def open_code(self): self.write('<CODE>')
|
|
|
|
def close_code(self): self.write('</CODE>')
|
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
def open_t(self): self.write('<TT>')
|
|
|
|
def close_t(self): self.write('</TT>')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def open_dfn(self): self.write('<DFN>')
|
|
|
|
def close_dfn(self): self.write('</DFN>')
|
|
|
|
|
|
|
|
def open_emph(self): self.write('<EM>')
|
|
|
|
def close_emph(self): self.write('</EM>')
|
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
def open_i(self): self.write('<I>')
|
|
|
|
def close_i(self): self.write('</I>')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def open_footnote(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
# if self.savetext <> None:
|
|
|
|
# print '*** Recursive footnote -- expect weirdness'
|
|
|
|
id = len(self.footnotes) + 1
|
2004-07-18 02:31:31 -03:00
|
|
|
self.write(self.FN_SOURCE_PATTERN % {'id': repr(id)})
|
1998-09-14 13:03:02 -03:00
|
|
|
self.startsaving()
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def close_footnote(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
id = len(self.footnotes) + 1
|
1998-10-08 12:24:48 -03:00
|
|
|
self.footnotes.append((id, self.collectsavings()))
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def writefootnotes(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write(self.FN_HEADER)
|
|
|
|
for id, text in self.footnotes:
|
|
|
|
self.write(self.FN_TARGET_PATTERN
|
2004-02-12 13:35:32 -04:00
|
|
|
% {'id': repr(id), 'text': text})
|
1998-09-14 13:03:02 -03:00
|
|
|
self.footnotes = []
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def open_file(self): self.write('<CODE>')
|
|
|
|
def close_file(self): self.write('</CODE>')
|
|
|
|
|
|
|
|
def open_kbd(self): self.write('<KBD>')
|
|
|
|
def close_kbd(self): self.write('</KBD>')
|
|
|
|
|
|
|
|
def open_key(self): self.write('<KEY>')
|
|
|
|
def close_key(self): self.write('</KEY>')
|
|
|
|
|
|
|
|
def open_r(self): self.write('<R>')
|
|
|
|
def close_r(self): self.write('</R>')
|
|
|
|
|
|
|
|
def open_samp(self): self.write('`<SAMP>')
|
|
|
|
def close_samp(self): self.write('</SAMP>\'')
|
|
|
|
|
|
|
|
def open_sc(self): self.write('<SMALLCAPS>')
|
|
|
|
def close_sc(self): self.write('</SMALLCAPS>')
|
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
def open_strong(self): self.write('<STRONG>')
|
|
|
|
def close_strong(self): self.write('</STRONG>')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
def open_b(self): self.write('<B>')
|
|
|
|
def close_b(self): self.write('</B>')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def open_var(self): self.write('<VAR>')
|
|
|
|
def close_var(self): self.write('</VAR>')
|
|
|
|
|
|
|
|
def open_w(self): self.write('<NOBREAK>')
|
|
|
|
def close_w(self): self.write('</NOBREAK>')
|
|
|
|
|
1998-04-23 19:59:33 -03:00
|
|
|
def open_url(self): self.startsaving()
|
|
|
|
def close_url(self):
|
|
|
|
text = self.collectsavings()
|
|
|
|
self.write('<A HREF="', text, '">', text, '</A>')
|
|
|
|
|
|
|
|
def open_email(self): self.startsaving()
|
|
|
|
def close_email(self):
|
|
|
|
text = self.collectsavings()
|
|
|
|
self.write('<A HREF="mailto:', text, '">', text, '</A>')
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
open_titlefont = open_
|
|
|
|
close_titlefont = close_
|
|
|
|
|
|
|
|
def open_small(self): pass
|
|
|
|
def close_small(self): pass
|
|
|
|
|
1998-04-23 19:59:33 -03:00
|
|
|
def command(self, line, mo):
|
|
|
|
a, b = mo.span(1)
|
1998-09-14 13:03:02 -03:00
|
|
|
cmd = line[a:b]
|
2002-06-18 12:37:05 -03:00
|
|
|
args = line[b:].strip()
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.debugging > 1:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('!'*self.debugging, 'command:', self.skip, self.stack, \
|
|
|
|
'@' + cmd, args)
|
1998-09-14 13:03:02 -03:00
|
|
|
try:
|
|
|
|
func = getattr(self, 'do_' + cmd)
|
|
|
|
except AttributeError:
|
|
|
|
try:
|
|
|
|
func = getattr(self, 'bgn_' + cmd)
|
|
|
|
except AttributeError:
|
|
|
|
# don't complain if we are skipping anyway
|
|
|
|
if not self.skip:
|
|
|
|
self.unknown_cmd(cmd, args)
|
|
|
|
return
|
|
|
|
self.stack.append(cmd)
|
|
|
|
func(args)
|
|
|
|
return
|
|
|
|
if not self.skip or cmd == 'end':
|
|
|
|
func(args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def unknown_cmd(self, cmd, args):
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** unknown', '@' + cmd, args)
|
1998-09-14 13:03:02 -03:00
|
|
|
if not self.unknown.has_key(cmd):
|
|
|
|
self.unknown[cmd] = 1
|
|
|
|
else:
|
|
|
|
self.unknown[cmd] = self.unknown[cmd] + 1
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_end(self, args):
|
2002-06-18 12:37:05 -03:00
|
|
|
words = args.split()
|
1998-09-14 13:03:02 -03:00
|
|
|
if not words:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** @end w/o args')
|
1998-09-14 13:03:02 -03:00
|
|
|
else:
|
|
|
|
cmd = words[0]
|
|
|
|
if not self.stack or self.stack[-1] <> cmd:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** @end', cmd, 'unexpected')
|
1998-09-14 13:03:02 -03:00
|
|
|
else:
|
|
|
|
del self.stack[-1]
|
|
|
|
try:
|
|
|
|
func = getattr(self, 'end_' + cmd)
|
|
|
|
except AttributeError:
|
|
|
|
self.unknown_end(cmd)
|
|
|
|
return
|
|
|
|
func()
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def unknown_end(self, cmd):
|
1998-09-14 13:03:02 -03:00
|
|
|
cmd = 'end ' + cmd
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** unknown', '@' + cmd)
|
1998-09-14 13:03:02 -03:00
|
|
|
if not self.unknown.has_key(cmd):
|
|
|
|
self.unknown[cmd] = 1
|
|
|
|
else:
|
|
|
|
self.unknown[cmd] = self.unknown[cmd] + 1
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
# --- Comments ---
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_comment(self, args): pass
|
|
|
|
do_c = do_comment
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
# --- Conditional processing ---
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def bgn_ifinfo(self, args): pass
|
|
|
|
def end_ifinfo(self): pass
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def bgn_iftex(self, args): self.skip = self.skip + 1
|
|
|
|
def end_iftex(self): self.skip = self.skip - 1
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def bgn_ignore(self, args): self.skip = self.skip + 1
|
|
|
|
def end_ignore(self): self.skip = self.skip - 1
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def bgn_tex(self, args): self.skip = self.skip + 1
|
|
|
|
def end_tex(self): self.skip = self.skip - 1
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_set(self, args):
|
2002-06-18 12:37:05 -03:00
|
|
|
fields = args.split(' ')
|
1998-09-14 13:03:02 -03:00
|
|
|
key = fields[0]
|
|
|
|
if len(fields) == 1:
|
|
|
|
value = 1
|
|
|
|
else:
|
2002-06-18 12:37:05 -03:00
|
|
|
value = ' '.join(fields[1:])
|
1998-09-14 13:03:02 -03:00
|
|
|
self.values[key] = value
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_clear(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.values[args] = None
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_ifset(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
if args not in self.values.keys() \
|
|
|
|
or self.values[args] is None:
|
|
|
|
self.skip = self.skip + 1
|
|
|
|
self.stackinfo[len(self.stack)] = 1
|
|
|
|
else:
|
|
|
|
self.stackinfo[len(self.stack)] = 0
|
1996-09-13 11:44:34 -03:00
|
|
|
def end_ifset(self):
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
try:
|
|
|
|
if self.stackinfo[len(self.stack) + 1]:
|
|
|
|
self.skip = self.skip - 1
|
|
|
|
del self.stackinfo[len(self.stack) + 1]
|
|
|
|
except KeyError:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** end_ifset: KeyError :', len(self.stack) + 1)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_ifclear(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
if args in self.values.keys() \
|
|
|
|
and self.values[args] is not None:
|
|
|
|
self.skip = self.skip + 1
|
|
|
|
self.stackinfo[len(self.stack)] = 1
|
|
|
|
else:
|
|
|
|
self.stackinfo[len(self.stack)] = 0
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
def end_ifclear(self):
|
|
|
|
try:
|
|
|
|
if self.stackinfo[len(self.stack) + 1]:
|
|
|
|
self.skip = self.skip - 1
|
|
|
|
del self.stackinfo[len(self.stack) + 1]
|
|
|
|
except KeyError:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** end_ifclear: KeyError :', len(self.stack) + 1)
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def open_value(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.startsaving()
|
1995-08-28 00:01:00 -03:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def close_value(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
key = self.collectsavings()
|
|
|
|
if key in self.values.keys():
|
|
|
|
self.write(self.values[key])
|
|
|
|
else:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** Undefined value: ', key)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Beginning a file ---
|
|
|
|
|
|
|
|
do_finalout = do_comment
|
|
|
|
do_setchapternewpage = do_comment
|
|
|
|
do_setfilename = do_comment
|
|
|
|
|
|
|
|
def do_settitle(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.startsaving()
|
|
|
|
self.expand(args)
|
|
|
|
self.title = self.collectsavings()
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_parskip(self, args): pass
|
|
|
|
|
|
|
|
# --- Ending a file ---
|
|
|
|
|
|
|
|
def do_bye(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.endnode()
|
|
|
|
self.done = 1
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Title page ---
|
|
|
|
|
|
|
|
def bgn_titlepage(self, args): self.skip = self.skip + 1
|
|
|
|
def end_titlepage(self): self.skip = self.skip - 1
|
|
|
|
def do_shorttitlepage(self, args): pass
|
|
|
|
|
|
|
|
def do_center(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
# Actually not used outside title page...
|
|
|
|
self.write('<H1>')
|
|
|
|
self.expand(args)
|
|
|
|
self.write('</H1>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
do_title = do_center
|
|
|
|
do_subtitle = do_center
|
|
|
|
do_author = do_center
|
|
|
|
|
|
|
|
do_vskip = do_comment
|
|
|
|
do_vfill = do_comment
|
|
|
|
do_smallbook = do_comment
|
|
|
|
|
|
|
|
do_paragraphindent = do_comment
|
|
|
|
do_setchapternewpage = do_comment
|
|
|
|
do_headings = do_comment
|
|
|
|
do_footnotestyle = do_comment
|
|
|
|
|
|
|
|
do_evenheading = do_comment
|
|
|
|
do_evenfooting = do_comment
|
|
|
|
do_oddheading = do_comment
|
|
|
|
do_oddfooting = do_comment
|
|
|
|
do_everyheading = do_comment
|
|
|
|
do_everyfooting = do_comment
|
|
|
|
|
|
|
|
# --- Nodes ---
|
|
|
|
|
|
|
|
def do_node(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.endnode()
|
|
|
|
self.nodelineno = 0
|
2002-06-18 12:37:05 -03:00
|
|
|
parts = [s.strip() for s in args.split(',')]
|
1998-09-14 13:03:02 -03:00
|
|
|
while len(parts) < 4: parts.append('')
|
|
|
|
self.nodelinks = parts
|
|
|
|
[name, next, prev, up] = parts[:4]
|
|
|
|
file = self.dirname + '/' + makefile(name)
|
|
|
|
if self.filenames.has_key(file):
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** Filename already in use: ', file)
|
1998-09-14 13:03:02 -03:00
|
|
|
else:
|
2007-08-03 14:06:41 -03:00
|
|
|
if self.debugging: print('!'*self.debugging, '--- writing', file)
|
1998-09-14 13:03:02 -03:00
|
|
|
self.filenames[file] = 1
|
|
|
|
# self.nodefp = open(file, 'w')
|
|
|
|
self.nodename = name
|
|
|
|
if self.cont and self.nodestack:
|
|
|
|
self.nodestack[-1].cont = self.nodename
|
|
|
|
if not self.topname: self.topname = name
|
|
|
|
title = name
|
|
|
|
if self.title: title = title + ' -- ' + self.title
|
|
|
|
self.node = self.Node(self.dirname, self.nodename, self.topname,
|
|
|
|
title, next, prev, up)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.htmlhelp.addnode(self.nodename,next,prev,up,file)
|
1995-08-28 00:01:00 -03:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def link(self, label, nodename):
|
1998-09-14 13:03:02 -03:00
|
|
|
if nodename:
|
2002-06-18 12:37:05 -03:00
|
|
|
if nodename.lower() == '(dir)':
|
1998-09-14 13:03:02 -03:00
|
|
|
addr = '../dir.html'
|
|
|
|
else:
|
|
|
|
addr = makefile(nodename)
|
|
|
|
self.write(label, ': <A HREF="', addr, '" TYPE="',
|
|
|
|
label, '">', nodename, '</A> \n')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Sectioning commands ---
|
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
def popstack(self, type):
|
1998-09-14 13:03:02 -03:00
|
|
|
if (self.node):
|
|
|
|
self.node.type = type
|
|
|
|
while self.nodestack:
|
|
|
|
if self.nodestack[-1].type > type:
|
|
|
|
self.nodestack[-1].finalize()
|
|
|
|
self.nodestack[-1].flush()
|
|
|
|
del self.nodestack[-1]
|
|
|
|
elif self.nodestack[-1].type == type:
|
|
|
|
if not self.nodestack[-1].next:
|
|
|
|
self.nodestack[-1].next = self.node.name
|
|
|
|
if not self.node.prev:
|
|
|
|
self.node.prev = self.nodestack[-1].name
|
|
|
|
self.nodestack[-1].finalize()
|
|
|
|
self.nodestack[-1].flush()
|
|
|
|
del self.nodestack[-1]
|
|
|
|
else:
|
|
|
|
if type > 1 and not self.node.up:
|
|
|
|
self.node.up = self.nodestack[-1].name
|
|
|
|
break
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_chapter(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, 0)
|
|
|
|
self.popstack(1)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_unnumbered(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, -1)
|
|
|
|
self.popstack(1)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_appendix(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, -1)
|
|
|
|
self.popstack(1)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_top(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, -1)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_chapheading(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, -1)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_majorheading(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, -1)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_section(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, 1)
|
|
|
|
self.popstack(2)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_unnumberedsec(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, -1)
|
|
|
|
self.popstack(2)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_appendixsec(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, -1)
|
|
|
|
self.popstack(2)
|
1996-09-13 11:44:34 -03:00
|
|
|
do_appendixsection = do_appendixsec
|
|
|
|
def do_heading(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H1', args, -1)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_subsection(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H2', args, 2)
|
|
|
|
self.popstack(3)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_unnumberedsubsec(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H2', args, -1)
|
|
|
|
self.popstack(3)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_appendixsubsec(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H2', args, -1)
|
|
|
|
self.popstack(3)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_subheading(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H2', args, -1)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_subsubsection(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H3', args, 3)
|
|
|
|
self.popstack(4)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_unnumberedsubsubsec(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H3', args, -1)
|
|
|
|
self.popstack(4)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_appendixsubsubsec(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H3', args, -1)
|
|
|
|
self.popstack(4)
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_subsubheading(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.heading('H3', args, -1)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def heading(self, type, args, level):
|
1998-09-14 13:03:02 -03:00
|
|
|
if level >= 0:
|
|
|
|
while len(self.numbering) <= level:
|
|
|
|
self.numbering.append(0)
|
|
|
|
del self.numbering[level+1:]
|
|
|
|
self.numbering[level] = self.numbering[level] + 1
|
|
|
|
x = ''
|
|
|
|
for i in self.numbering:
|
2004-02-12 13:35:32 -04:00
|
|
|
x = x + repr(i) + '.'
|
1998-09-14 13:03:02 -03:00
|
|
|
args = x + ' ' + args
|
1998-10-08 12:24:48 -03:00
|
|
|
self.contents.append((level, args, self.nodename))
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<', type, '>')
|
|
|
|
self.expand(args)
|
|
|
|
self.write('</', type, '>\n')
|
|
|
|
if self.debugging or self.print_headers:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('---', args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_contents(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
# pass
|
|
|
|
self.listcontents('Table of Contents', 999)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_shortcontents(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
pass
|
|
|
|
# self.listcontents('Short Contents', 0)
|
1996-09-13 11:44:34 -03:00
|
|
|
do_summarycontents = do_shortcontents
|
|
|
|
|
|
|
|
def listcontents(self, title, maxlevel):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<H1>', title, '</H1>\n<UL COMPACT PLAIN>\n')
|
|
|
|
prevlevels = [0]
|
|
|
|
for level, title, node in self.contents:
|
|
|
|
if level > maxlevel:
|
|
|
|
continue
|
|
|
|
if level > prevlevels[-1]:
|
|
|
|
# can only advance one level at a time
|
|
|
|
self.write(' '*prevlevels[-1], '<UL PLAIN>\n')
|
|
|
|
prevlevels.append(level)
|
|
|
|
elif level < prevlevels[-1]:
|
|
|
|
# might drop back multiple levels
|
|
|
|
while level < prevlevels[-1]:
|
|
|
|
del prevlevels[-1]
|
|
|
|
self.write(' '*prevlevels[-1],
|
|
|
|
'</UL>\n')
|
|
|
|
self.write(' '*level, '<LI> <A HREF="',
|
|
|
|
makefile(node), '">')
|
|
|
|
self.expand(title)
|
|
|
|
self.write('</A>\n')
|
|
|
|
self.write('</UL>\n' * len(prevlevels))
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Page lay-out ---
|
|
|
|
|
|
|
|
# These commands are only meaningful in printed text
|
|
|
|
|
|
|
|
def do_page(self, args): pass
|
|
|
|
|
|
|
|
def do_need(self, args): pass
|
|
|
|
|
|
|
|
def bgn_group(self, args): pass
|
|
|
|
def end_group(self): pass
|
|
|
|
|
|
|
|
# --- Line lay-out ---
|
|
|
|
|
|
|
|
def do_sp(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.nofill:
|
|
|
|
self.write('\n')
|
|
|
|
else:
|
|
|
|
self.write('<P>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_hline(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<HR>')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Function and variable definitions ---
|
|
|
|
|
|
|
|
def bgn_deffn(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DL>')
|
|
|
|
self.do_deffnx(args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def end_deffn(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('</DL>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_deffnx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DT>')
|
|
|
|
words = splitwords(args, 2)
|
|
|
|
[category, name], rest = words[:2], words[2:]
|
|
|
|
self.expand('@b{%s}' % name)
|
|
|
|
for word in rest: self.expand(' ' + makevar(word))
|
|
|
|
#self.expand(' -- ' + category)
|
|
|
|
self.write('\n<DD>')
|
|
|
|
self.index('fn', name)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_defun(self, args): self.bgn_deffn('Function ' + args)
|
|
|
|
end_defun = end_deffn
|
|
|
|
def do_defunx(self, args): self.do_deffnx('Function ' + args)
|
|
|
|
|
|
|
|
def bgn_defmac(self, args): self.bgn_deffn('Macro ' + args)
|
|
|
|
end_defmac = end_deffn
|
|
|
|
def do_defmacx(self, args): self.do_deffnx('Macro ' + args)
|
|
|
|
|
|
|
|
def bgn_defspec(self, args): self.bgn_deffn('{Special Form} ' + args)
|
|
|
|
end_defspec = end_deffn
|
|
|
|
def do_defspecx(self, args): self.do_deffnx('{Special Form} ' + args)
|
|
|
|
|
|
|
|
def bgn_defvr(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DL>')
|
|
|
|
self.do_defvrx(args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
end_defvr = end_deffn
|
|
|
|
|
|
|
|
def do_defvrx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DT>')
|
|
|
|
words = splitwords(args, 2)
|
|
|
|
[category, name], rest = words[:2], words[2:]
|
|
|
|
self.expand('@code{%s}' % name)
|
|
|
|
# If there are too many arguments, show them
|
|
|
|
for word in rest: self.expand(' ' + word)
|
|
|
|
#self.expand(' -- ' + category)
|
|
|
|
self.write('\n<DD>')
|
|
|
|
self.index('vr', name)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_defvar(self, args): self.bgn_defvr('Variable ' + args)
|
|
|
|
end_defvar = end_defvr
|
|
|
|
def do_defvarx(self, args): self.do_defvrx('Variable ' + args)
|
|
|
|
|
|
|
|
def bgn_defopt(self, args): self.bgn_defvr('{User Option} ' + args)
|
|
|
|
end_defopt = end_defvr
|
|
|
|
def do_defoptx(self, args): self.do_defvrx('{User Option} ' + args)
|
|
|
|
|
|
|
|
# --- Ditto for typed languages ---
|
|
|
|
|
|
|
|
def bgn_deftypefn(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DL>')
|
|
|
|
self.do_deftypefnx(args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
end_deftypefn = end_deffn
|
|
|
|
|
|
|
|
def do_deftypefnx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DT>')
|
|
|
|
words = splitwords(args, 3)
|
|
|
|
[category, datatype, name], rest = words[:3], words[3:]
|
|
|
|
self.expand('@code{%s} @b{%s}' % (datatype, name))
|
|
|
|
for word in rest: self.expand(' ' + makevar(word))
|
|
|
|
#self.expand(' -- ' + category)
|
|
|
|
self.write('\n<DD>')
|
|
|
|
self.index('fn', name)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
|
|
|
|
def bgn_deftypefun(self, args): self.bgn_deftypefn('Function ' + args)
|
|
|
|
end_deftypefun = end_deftypefn
|
|
|
|
def do_deftypefunx(self, args): self.do_deftypefnx('Function ' + args)
|
|
|
|
|
|
|
|
def bgn_deftypevr(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DL>')
|
|
|
|
self.do_deftypevrx(args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
end_deftypevr = end_deftypefn
|
|
|
|
|
|
|
|
def do_deftypevrx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DT>')
|
|
|
|
words = splitwords(args, 3)
|
|
|
|
[category, datatype, name], rest = words[:3], words[3:]
|
|
|
|
self.expand('@code{%s} @b{%s}' % (datatype, name))
|
|
|
|
# If there are too many arguments, show them
|
|
|
|
for word in rest: self.expand(' ' + word)
|
|
|
|
#self.expand(' -- ' + category)
|
|
|
|
self.write('\n<DD>')
|
|
|
|
self.index('fn', name)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_deftypevar(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.bgn_deftypevr('Variable ' + args)
|
1996-09-13 11:44:34 -03:00
|
|
|
end_deftypevar = end_deftypevr
|
|
|
|
def do_deftypevarx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.do_deftypevrx('Variable ' + args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Ditto for object-oriented languages ---
|
|
|
|
|
|
|
|
def bgn_defcv(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DL>')
|
|
|
|
self.do_defcvx(args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
end_defcv = end_deftypevr
|
|
|
|
|
|
|
|
def do_defcvx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DT>')
|
|
|
|
words = splitwords(args, 3)
|
|
|
|
[category, classname, name], rest = words[:3], words[3:]
|
|
|
|
self.expand('@b{%s}' % name)
|
|
|
|
# If there are too many arguments, show them
|
|
|
|
for word in rest: self.expand(' ' + word)
|
|
|
|
#self.expand(' -- %s of @code{%s}' % (category, classname))
|
|
|
|
self.write('\n<DD>')
|
|
|
|
self.index('vr', '%s @r{on %s}' % (name, classname))
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_defivar(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.bgn_defcv('{Instance Variable} ' + args)
|
1996-09-13 11:44:34 -03:00
|
|
|
end_defivar = end_defcv
|
|
|
|
def do_defivarx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.do_defcvx('{Instance Variable} ' + args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_defop(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DL>')
|
|
|
|
self.do_defopx(args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
end_defop = end_defcv
|
|
|
|
|
|
|
|
def do_defopx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DT>')
|
|
|
|
words = splitwords(args, 3)
|
|
|
|
[category, classname, name], rest = words[:3], words[3:]
|
|
|
|
self.expand('@b{%s}' % name)
|
|
|
|
for word in rest: self.expand(' ' + makevar(word))
|
|
|
|
#self.expand(' -- %s of @code{%s}' % (category, classname))
|
|
|
|
self.write('\n<DD>')
|
|
|
|
self.index('fn', '%s @r{on %s}' % (name, classname))
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_defmethod(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.bgn_defop('Method ' + args)
|
1996-09-13 11:44:34 -03:00
|
|
|
end_defmethod = end_defop
|
|
|
|
def do_defmethodx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.do_defopx('Method ' + args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Ditto for data types ---
|
|
|
|
|
|
|
|
def bgn_deftp(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DL>')
|
|
|
|
self.do_deftpx(args)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
end_deftp = end_defcv
|
|
|
|
|
|
|
|
def do_deftpx(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DT>')
|
|
|
|
words = splitwords(args, 2)
|
|
|
|
[category, name], rest = words[:2], words[2:]
|
|
|
|
self.expand('@b{%s}' % name)
|
|
|
|
for word in rest: self.expand(' ' + word)
|
|
|
|
#self.expand(' -- ' + category)
|
|
|
|
self.write('\n<DD>')
|
|
|
|
self.index('tp', name)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Making Lists and Tables
|
|
|
|
|
|
|
|
def bgn_enumerate(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
if not args:
|
|
|
|
self.write('<OL>\n')
|
|
|
|
self.stackinfo[len(self.stack)] = '</OL>\n'
|
|
|
|
else:
|
|
|
|
self.itemnumber = args
|
|
|
|
self.write('<UL>\n')
|
|
|
|
self.stackinfo[len(self.stack)] = '</UL>\n'
|
1996-09-13 11:44:34 -03:00
|
|
|
def end_enumerate(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.itemnumber = None
|
|
|
|
self.write(self.stackinfo[len(self.stack) + 1])
|
|
|
|
del self.stackinfo[len(self.stack) + 1]
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_itemize(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.itemarg = args
|
|
|
|
self.write('<UL>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
def end_itemize(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.itemarg = None
|
|
|
|
self.write('</UL>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_table(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.itemarg = args
|
|
|
|
self.write('<DL>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
def end_table(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.itemarg = None
|
|
|
|
self.write('</DL>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_ftable(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.itemindex = 'fn'
|
|
|
|
self.bgn_table(args)
|
1996-09-13 11:44:34 -03:00
|
|
|
def end_ftable(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.itemindex = None
|
|
|
|
self.end_table()
|
1996-09-13 11:44:34 -03:00
|
|
|
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
def bgn_vtable(self, args):
|
|
|
|
self.itemindex = 'vr'
|
|
|
|
self.bgn_table(args)
|
|
|
|
def end_vtable(self):
|
|
|
|
self.itemindex = None
|
|
|
|
self.end_table()
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
def do_item(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.itemindex: self.index(self.itemindex, args)
|
|
|
|
if self.itemarg:
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
if self.itemarg[0] == '@' and self.itemarg[1] and \
|
2001-07-20 16:05:50 -03:00
|
|
|
self.itemarg[1] in string.ascii_letters:
|
1998-09-14 13:03:02 -03:00
|
|
|
args = self.itemarg + '{' + args + '}'
|
|
|
|
else:
|
|
|
|
# some other character, e.g. '-'
|
|
|
|
args = self.itemarg + ' ' + args
|
|
|
|
if self.itemnumber <> None:
|
|
|
|
args = self.itemnumber + '. ' + args
|
|
|
|
self.itemnumber = increment(self.itemnumber)
|
|
|
|
if self.stack and self.stack[-1] == 'table':
|
|
|
|
self.write('<DT>')
|
|
|
|
self.expand(args)
|
|
|
|
self.write('\n<DD>')
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
elif self.stack and self.stack[-1] == 'multitable':
|
|
|
|
self.write('<TR><TD>')
|
|
|
|
self.expand(args)
|
|
|
|
self.write('</TD>\n</TR>\n')
|
1998-09-14 13:03:02 -03:00
|
|
|
else:
|
|
|
|
self.write('<LI>')
|
|
|
|
self.expand(args)
|
|
|
|
self.write(' ')
|
1996-09-13 11:44:34 -03:00
|
|
|
do_itemx = do_item # XXX Should suppress leading blank line
|
|
|
|
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
# rpyron 2002-05-07 multitable support
|
|
|
|
def bgn_multitable(self, args):
|
|
|
|
self.itemarg = None # should be handled by columnfractions
|
|
|
|
self.write('<TABLE BORDER="">\n')
|
|
|
|
def end_multitable(self):
|
|
|
|
self.itemarg = None
|
|
|
|
self.write('</TABLE>\n<BR>\n')
|
|
|
|
def handle_columnfractions(self):
|
|
|
|
# It would be better to handle this, but for now it's in the way...
|
|
|
|
self.itemarg = None
|
|
|
|
def handle_tab(self):
|
|
|
|
self.write('</TD>\n <TD>')
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
# --- Enumerations, displays, quotations ---
|
|
|
|
# XXX Most of these should increase the indentation somehow
|
|
|
|
|
|
|
|
def bgn_quotation(self, args): self.write('<BLOCKQUOTE>')
|
|
|
|
def end_quotation(self): self.write('</BLOCKQUOTE>\n')
|
|
|
|
|
|
|
|
def bgn_example(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.nofill = self.nofill + 1
|
|
|
|
self.write('<PRE>')
|
1996-09-13 11:44:34 -03:00
|
|
|
def end_example(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('</PRE>\n')
|
|
|
|
self.nofill = self.nofill - 1
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
bgn_lisp = bgn_example # Synonym when contents are executable lisp code
|
|
|
|
end_lisp = end_example
|
|
|
|
|
|
|
|
bgn_smallexample = bgn_example # XXX Should use smaller font
|
|
|
|
end_smallexample = end_example
|
|
|
|
|
|
|
|
bgn_smalllisp = bgn_lisp # Ditto
|
|
|
|
end_smalllisp = end_lisp
|
|
|
|
|
|
|
|
bgn_display = bgn_example
|
|
|
|
end_display = end_example
|
|
|
|
|
|
|
|
bgn_format = bgn_display
|
|
|
|
end_format = end_display
|
|
|
|
|
|
|
|
def do_exdent(self, args): self.expand(args + '\n')
|
|
|
|
# XXX Should really mess with indentation
|
|
|
|
|
|
|
|
def bgn_flushleft(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.nofill = self.nofill + 1
|
|
|
|
self.write('<PRE>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
def end_flushleft(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('</PRE>\n')
|
|
|
|
self.nofill = self.nofill - 1
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_flushright(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.nofill = self.nofill + 1
|
|
|
|
self.write('<ADDRESS COMPACT>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
def end_flushright(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('</ADDRESS>\n')
|
|
|
|
self.nofill = self.nofill - 1
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_menu(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DIR>\n')
|
|
|
|
self.write(' <STRONG><EM>Menu</EM></STRONG><P>\n')
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.htmlhelp.beginmenu()
|
1996-10-09 16:05:12 -03:00
|
|
|
def end_menu(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('</DIR>\n')
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.htmlhelp.endmenu()
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def bgn_cartouche(self, args): pass
|
|
|
|
def end_cartouche(self): pass
|
|
|
|
|
|
|
|
# --- Indices ---
|
|
|
|
|
|
|
|
def resetindex(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.noncodeindices = ['cp']
|
|
|
|
self.indextitle = {}
|
|
|
|
self.indextitle['cp'] = 'Concept'
|
|
|
|
self.indextitle['fn'] = 'Function'
|
|
|
|
self.indextitle['ky'] = 'Keyword'
|
|
|
|
self.indextitle['pg'] = 'Program'
|
|
|
|
self.indextitle['tp'] = 'Type'
|
|
|
|
self.indextitle['vr'] = 'Variable'
|
|
|
|
#
|
|
|
|
self.whichindex = {}
|
|
|
|
for name in self.indextitle.keys():
|
|
|
|
self.whichindex[name] = []
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def user_index(self, name, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.whichindex.has_key(name):
|
|
|
|
self.index(name, args)
|
|
|
|
else:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** No index named', repr(name))
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_cindex(self, args): self.index('cp', args)
|
|
|
|
def do_findex(self, args): self.index('fn', args)
|
|
|
|
def do_kindex(self, args): self.index('ky', args)
|
|
|
|
def do_pindex(self, args): self.index('pg', args)
|
|
|
|
def do_tindex(self, args): self.index('tp', args)
|
|
|
|
def do_vindex(self, args): self.index('vr', args)
|
|
|
|
|
|
|
|
def index(self, name, args):
|
1998-10-08 12:24:48 -03:00
|
|
|
self.whichindex[name].append((args, self.nodename))
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.htmlhelp.index(args, self.nodename)
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def do_synindex(self, args):
|
2002-06-18 12:37:05 -03:00
|
|
|
words = args.split()
|
1998-09-14 13:03:02 -03:00
|
|
|
if len(words) <> 2:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** bad @synindex', args)
|
1998-09-14 13:03:02 -03:00
|
|
|
return
|
|
|
|
[old, new] = words
|
|
|
|
if not self.whichindex.has_key(old) or \
|
|
|
|
not self.whichindex.has_key(new):
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** bad key(s) in @synindex', args)
|
1998-09-14 13:03:02 -03:00
|
|
|
return
|
|
|
|
if old <> new and \
|
|
|
|
self.whichindex[old] is not self.whichindex[new]:
|
|
|
|
inew = self.whichindex[new]
|
|
|
|
inew[len(inew):] = self.whichindex[old]
|
|
|
|
self.whichindex[old] = inew
|
1996-09-13 11:44:34 -03:00
|
|
|
do_syncodeindex = do_synindex # XXX Should use code font
|
|
|
|
|
|
|
|
def do_printindex(self, args):
|
2002-06-18 12:37:05 -03:00
|
|
|
words = args.split()
|
1998-09-14 13:03:02 -03:00
|
|
|
for name in words:
|
|
|
|
if self.whichindex.has_key(name):
|
|
|
|
self.prindex(name)
|
|
|
|
else:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('*** No index named', repr(name))
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
def prindex(self, name):
|
1998-09-14 13:03:02 -03:00
|
|
|
iscodeindex = (name not in self.noncodeindices)
|
|
|
|
index = self.whichindex[name]
|
|
|
|
if not index: return
|
|
|
|
if self.debugging:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('!'*self.debugging, '--- Generating', \
|
|
|
|
self.indextitle[name], 'index')
|
1998-09-14 13:03:02 -03:00
|
|
|
# The node already provides a title
|
|
|
|
index1 = []
|
1998-04-23 19:59:33 -03:00
|
|
|
junkprog = re.compile('^(@[a-z]+)?{')
|
1998-09-14 13:03:02 -03:00
|
|
|
for key, node in index:
|
2002-06-18 12:37:05 -03:00
|
|
|
sortkey = key.lower()
|
1998-09-14 13:03:02 -03:00
|
|
|
# Remove leading `@cmd{' from sort key
|
|
|
|
# -- don't bother about the matching `}'
|
|
|
|
oldsortkey = sortkey
|
|
|
|
while 1:
|
1998-04-23 19:59:33 -03:00
|
|
|
mo = junkprog.match(sortkey)
|
|
|
|
if not mo:
|
|
|
|
break
|
|
|
|
i = mo.end()
|
1998-09-14 13:03:02 -03:00
|
|
|
sortkey = sortkey[i:]
|
1998-10-08 12:24:48 -03:00
|
|
|
index1.append((sortkey, key, node))
|
1998-09-14 13:03:02 -03:00
|
|
|
del index[:]
|
|
|
|
index1.sort()
|
|
|
|
self.write('<DL COMPACT>\n')
|
|
|
|
prevkey = prevnode = None
|
|
|
|
for sortkey, key, node in index1:
|
|
|
|
if (key, node) == (prevkey, prevnode):
|
|
|
|
continue
|
2007-08-03 14:06:41 -03:00
|
|
|
if self.debugging > 1: print('!'*self.debugging, key, ':', node)
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<DT>')
|
|
|
|
if iscodeindex: key = '@code{' + key + '}'
|
|
|
|
if key != prevkey:
|
|
|
|
self.expand(key)
|
|
|
|
self.write('\n<DD><A HREF="%s">%s</A>\n' % (makefile(node), node))
|
|
|
|
prevkey, prevnode = key, node
|
|
|
|
self.write('</DL>\n')
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
# --- Final error reports ---
|
|
|
|
|
|
|
|
def report(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
if self.unknown:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('--- Unrecognized commands ---')
|
1998-09-14 13:03:02 -03:00
|
|
|
cmds = self.unknown.keys()
|
|
|
|
cmds.sort()
|
|
|
|
for cmd in cmds:
|
2007-08-03 14:06:41 -03:00
|
|
|
print(cmd.ljust(20), self.unknown[cmd])
|
1995-03-15 07:26:05 -04:00
|
|
|
|
|
|
|
|
1996-10-09 16:05:12 -03:00
|
|
|
class TexinfoParserHTML3(TexinfoParser):
|
|
|
|
|
|
|
|
COPYRIGHT_SYMBOL = "©"
|
|
|
|
FN_ID_PATTERN = "[%(id)s]"
|
|
|
|
FN_SOURCE_PATTERN = '<A ID=footnoteref%(id)s ' \
|
1998-09-14 13:03:02 -03:00
|
|
|
'HREF="#footnotetext%(id)s">' + FN_ID_PATTERN + '</A>'
|
1996-10-09 16:05:12 -03:00
|
|
|
FN_TARGET_PATTERN = '<FN ID=footnotetext%(id)s>\n' \
|
1998-09-14 13:03:02 -03:00
|
|
|
'<P><A HREF="#footnoteref%(id)s">' + FN_ID_PATTERN \
|
|
|
|
+ '</A>\n%(text)s</P></FN>\n'
|
1996-10-09 16:05:12 -03:00
|
|
|
FN_HEADER = '<DIV CLASS=footnotes>\n <HR NOSHADE WIDTH=200>\n' \
|
1998-09-14 13:03:02 -03:00
|
|
|
' <STRONG><EM>Footnotes</EM></STRONG>\n <P>\n'
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
Node = HTML3Node
|
|
|
|
|
|
|
|
def bgn_quotation(self, args): self.write('<BQ>')
|
|
|
|
def end_quotation(self): self.write('</BQ>\n')
|
|
|
|
|
|
|
|
def bgn_example(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
# this use of <CODE> would not be legal in HTML 2.0,
|
|
|
|
# but is in more recent DTDs.
|
|
|
|
self.nofill = self.nofill + 1
|
|
|
|
self.write('<PRE CLASS=example><CODE>')
|
1996-10-25 19:13:59 -03:00
|
|
|
def end_example(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write("</CODE></PRE>\n")
|
|
|
|
self.nofill = self.nofill - 1
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
def bgn_flushleft(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.nofill = self.nofill + 1
|
|
|
|
self.write('<PRE CLASS=flushleft>\n')
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
def bgn_flushright(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.nofill = self.nofill + 1
|
|
|
|
self.write('<DIV ALIGN=right CLASS=flushright><ADDRESS COMPACT>\n')
|
1996-10-09 16:05:12 -03:00
|
|
|
def end_flushright(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('</ADDRESS></DIV>\n')
|
|
|
|
self.nofill = self.nofill - 1
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
def bgn_menu(self, args):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('<UL PLAIN CLASS=menu>\n')
|
|
|
|
self.write(' <LH>Menu</LH>\n')
|
1996-10-09 16:05:12 -03:00
|
|
|
def end_menu(self):
|
1998-09-14 13:03:02 -03:00
|
|
|
self.write('</UL>\n')
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
# rpyron 2002-05-07
|
|
|
|
class HTMLHelp:
|
|
|
|
"""
|
|
|
|
This class encapsulates support for HTML Help. Node names,
|
|
|
|
file names, menu items, index items, and image file names are
|
|
|
|
accumulated until a call to finalize(). At that time, three
|
|
|
|
output files are created in the current directory:
|
|
|
|
|
|
|
|
`helpbase`.hhp is a HTML Help Workshop project file.
|
|
|
|
It contains various information, some of
|
|
|
|
which I do not understand; I just copied
|
|
|
|
the default project info from a fresh
|
|
|
|
installation.
|
|
|
|
`helpbase`.hhc is the Contents file for the project.
|
|
|
|
`helpbase`.hhk is the Index file for the project.
|
|
|
|
|
|
|
|
When these files are used as input to HTML Help Workshop,
|
|
|
|
the resulting file will be named:
|
|
|
|
|
|
|
|
`helpbase`.chm
|
|
|
|
|
|
|
|
If none of the defaults in `helpbase`.hhp are changed,
|
|
|
|
the .CHM file will have Contents, Index, Search, and
|
|
|
|
Favorites tabs.
|
|
|
|
"""
|
|
|
|
|
|
|
|
codeprog = re.compile('@code{(.*?)}')
|
|
|
|
|
|
|
|
def __init__(self,helpbase,dirname):
|
|
|
|
self.helpbase = helpbase
|
|
|
|
self.dirname = dirname
|
|
|
|
self.projectfile = None
|
|
|
|
self.contentfile = None
|
|
|
|
self.indexfile = None
|
|
|
|
self.nodelist = []
|
|
|
|
self.nodenames = {} # nodename : index
|
|
|
|
self.nodeindex = {}
|
|
|
|
self.filenames = {} # filename : filename
|
|
|
|
self.indexlist = [] # (args,nodename) == (key,location)
|
|
|
|
self.current = ''
|
|
|
|
self.menudict = {}
|
|
|
|
self.dumped = {}
|
|
|
|
|
|
|
|
|
|
|
|
def addnode(self,name,next,prev,up,filename):
|
|
|
|
node = (name,next,prev,up,filename)
|
|
|
|
# add this file to dict
|
|
|
|
# retrieve list with self.filenames.values()
|
|
|
|
self.filenames[filename] = filename
|
|
|
|
# add this node to nodelist
|
|
|
|
self.nodeindex[name] = len(self.nodelist)
|
|
|
|
self.nodelist.append(node)
|
|
|
|
# set 'current' for menu items
|
|
|
|
self.current = name
|
|
|
|
self.menudict[self.current] = []
|
|
|
|
|
|
|
|
def menuitem(self,nodename):
|
|
|
|
menu = self.menudict[self.current]
|
|
|
|
menu.append(nodename)
|
|
|
|
|
|
|
|
|
|
|
|
def addimage(self,imagename):
|
|
|
|
self.filenames[imagename] = imagename
|
|
|
|
|
|
|
|
def index(self, args, nodename):
|
|
|
|
self.indexlist.append((args,nodename))
|
|
|
|
|
|
|
|
def beginmenu(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def endmenu(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize(self):
|
|
|
|
if not self.helpbase:
|
|
|
|
return
|
|
|
|
|
|
|
|
# generate interesting filenames
|
|
|
|
resultfile = self.helpbase + '.chm'
|
|
|
|
projectfile = self.helpbase + '.hhp'
|
|
|
|
contentfile = self.helpbase + '.hhc'
|
|
|
|
indexfile = self.helpbase + '.hhk'
|
|
|
|
|
|
|
|
# generate a reasonable title
|
|
|
|
title = self.helpbase
|
|
|
|
|
|
|
|
# get the default topic file
|
|
|
|
(topname,topnext,topprev,topup,topfile) = self.nodelist[0]
|
|
|
|
defaulttopic = topfile
|
|
|
|
|
|
|
|
# PROJECT FILE
|
|
|
|
try:
|
|
|
|
fp = open(projectfile,'w')
|
2007-08-03 14:06:41 -03:00
|
|
|
print('[OPTIONS]', file=fp)
|
|
|
|
print('Auto Index=Yes', file=fp)
|
|
|
|
print('Binary TOC=No', file=fp)
|
|
|
|
print('Binary Index=Yes', file=fp)
|
|
|
|
print('Compatibility=1.1', file=fp)
|
|
|
|
print('Compiled file=' + resultfile + '', file=fp)
|
|
|
|
print('Contents file=' + contentfile + '', file=fp)
|
|
|
|
print('Default topic=' + defaulttopic + '', file=fp)
|
|
|
|
print('Error log file=ErrorLog.log', file=fp)
|
|
|
|
print('Index file=' + indexfile + '', file=fp)
|
|
|
|
print('Title=' + title + '', file=fp)
|
|
|
|
print('Display compile progress=Yes', file=fp)
|
|
|
|
print('Full-text search=Yes', file=fp)
|
|
|
|
print('Default window=main', file=fp)
|
|
|
|
print('', file=fp)
|
|
|
|
print('[WINDOWS]', file=fp)
|
|
|
|
print('main=,"' + contentfile + '","' + indexfile
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
+ '","","",,,,,0x23520,222,0x1046,[10,10,780,560],'
|
2007-08-03 14:06:41 -03:00
|
|
|
'0xB0000,,,,,,0', file=fp)
|
|
|
|
print('', file=fp)
|
|
|
|
print('[FILES]', file=fp)
|
|
|
|
print('', file=fp)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.dumpfiles(fp)
|
|
|
|
fp.close()
|
2007-01-10 12:19:56 -04:00
|
|
|
except IOError as msg:
|
2007-08-03 14:06:41 -03:00
|
|
|
print(projectfile, ':', msg)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# CONTENT FILE
|
|
|
|
try:
|
|
|
|
fp = open(contentfile,'w')
|
2007-08-03 14:06:41 -03:00
|
|
|
print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
|
|
|
|
print('<!-- This file defines the table of contents -->', file=fp)
|
|
|
|
print('<HTML>', file=fp)
|
|
|
|
print('<HEAD>', file=fp)
|
|
|
|
print('<meta name="GENERATOR"'
|
|
|
|
'content="Microsoft® HTML Help Workshop 4.1">', file=fp)
|
|
|
|
print('<!-- Sitemap 1.0 -->', file=fp)
|
|
|
|
print('</HEAD>', file=fp)
|
|
|
|
print('<BODY>', file=fp)
|
|
|
|
print(' <OBJECT type="text/site properties">', file=fp)
|
|
|
|
print(' <param name="Window Styles" value="0x800025">', file=fp)
|
|
|
|
print(' <param name="comment" value="title:">', file=fp)
|
|
|
|
print(' <param name="comment" value="base:">', file=fp)
|
|
|
|
print(' </OBJECT>', file=fp)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.dumpnodes(fp)
|
2007-08-03 14:06:41 -03:00
|
|
|
print('</BODY>', file=fp)
|
|
|
|
print('</HTML>', file=fp)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
fp.close()
|
2007-01-10 12:19:56 -04:00
|
|
|
except IOError as msg:
|
2007-08-03 14:06:41 -03:00
|
|
|
print(contentfile, ':', msg)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# INDEX FILE
|
|
|
|
try:
|
|
|
|
fp = open(indexfile ,'w')
|
2007-08-03 14:06:41 -03:00
|
|
|
print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
|
|
|
|
print('<!-- This file defines the index -->', file=fp)
|
|
|
|
print('<HTML>', file=fp)
|
|
|
|
print('<HEAD>', file=fp)
|
|
|
|
print('<meta name="GENERATOR"'
|
|
|
|
'content="Microsoft® HTML Help Workshop 4.1">', file=fp)
|
|
|
|
print('<!-- Sitemap 1.0 -->', file=fp)
|
|
|
|
print('</HEAD>', file=fp)
|
|
|
|
print('<BODY>', file=fp)
|
|
|
|
print('<OBJECT type="text/site properties">', file=fp)
|
|
|
|
print('</OBJECT>', file=fp)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.dumpindex(fp)
|
2007-08-03 14:06:41 -03:00
|
|
|
print('</BODY>', file=fp)
|
|
|
|
print('</HTML>', file=fp)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
fp.close()
|
2007-01-10 12:19:56 -04:00
|
|
|
except IOError as msg:
|
2007-08-03 14:06:41 -03:00
|
|
|
print(indexfile , ':', msg)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
def dumpfiles(self, outfile=sys.stdout):
|
|
|
|
filelist = self.filenames.values()
|
|
|
|
filelist.sort()
|
|
|
|
for filename in filelist:
|
2007-08-03 14:06:41 -03:00
|
|
|
print(filename, file=outfile)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
|
|
|
|
def dumpnodes(self, outfile=sys.stdout):
|
|
|
|
self.dumped = {}
|
|
|
|
if self.nodelist:
|
2004-07-18 02:31:31 -03:00
|
|
|
nodename, dummy, dummy, dummy, dummy = self.nodelist[0]
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
self.topnode = nodename
|
|
|
|
|
2007-08-03 14:06:41 -03:00
|
|
|
print('<UL>', file=outfile)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
for node in self.nodelist:
|
|
|
|
self.dumpnode(node,0,outfile)
|
2007-08-03 14:06:41 -03:00
|
|
|
print('</UL>', file=outfile)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
|
|
|
|
def dumpnode(self, node, indent=0, outfile=sys.stdout):
|
|
|
|
if node:
|
|
|
|
# Retrieve info for this node
|
|
|
|
(nodename,next,prev,up,filename) = node
|
|
|
|
self.current = nodename
|
|
|
|
|
|
|
|
# Have we been dumped already?
|
|
|
|
if self.dumped.has_key(nodename):
|
|
|
|
return
|
|
|
|
self.dumped[nodename] = 1
|
|
|
|
|
|
|
|
# Print info for this node
|
2007-08-03 14:06:41 -03:00
|
|
|
print(' '*indent, end=' ', file=outfile)
|
|
|
|
print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
|
|
|
|
print('<param name="Name" value="' + nodename +'">', end=' ', file=outfile)
|
|
|
|
print('<param name="Local" value="'+ filename +'">', end=' ', file=outfile)
|
|
|
|
print('</OBJECT>', file=outfile)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
|
|
|
|
# Does this node have menu items?
|
|
|
|
try:
|
|
|
|
menu = self.menudict[nodename]
|
|
|
|
self.dumpmenu(menu,indent+2,outfile)
|
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def dumpmenu(self, menu, indent=0, outfile=sys.stdout):
|
|
|
|
if menu:
|
|
|
|
currentnode = self.current
|
|
|
|
if currentnode != self.topnode: # XXX this is a hack
|
2007-08-03 14:06:41 -03:00
|
|
|
print(' '*indent + '<UL>', file=outfile)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
indent += 2
|
|
|
|
for item in menu:
|
|
|
|
menunode = self.getnode(item)
|
|
|
|
self.dumpnode(menunode,indent,outfile)
|
|
|
|
if currentnode != self.topnode: # XXX this is a hack
|
2007-08-03 14:06:41 -03:00
|
|
|
print(' '*indent + '</UL>', file=outfile)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
indent -= 2
|
|
|
|
|
|
|
|
def getnode(self, nodename):
|
|
|
|
try:
|
|
|
|
index = self.nodeindex[nodename]
|
|
|
|
return self.nodelist[index]
|
|
|
|
except KeyError:
|
|
|
|
return None
|
|
|
|
except IndexError:
|
|
|
|
return None
|
|
|
|
|
|
|
|
# (args,nodename) == (key,location)
|
|
|
|
def dumpindex(self, outfile=sys.stdout):
|
2007-08-03 14:06:41 -03:00
|
|
|
print('<UL>', file=outfile)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
for (key,location) in self.indexlist:
|
|
|
|
key = self.codeexpand(key)
|
|
|
|
location = makefile(location)
|
|
|
|
location = self.dirname + '/' + location
|
2007-08-03 14:06:41 -03:00
|
|
|
print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
|
|
|
|
print('<param name="Name" value="' + key + '">', end=' ', file=outfile)
|
|
|
|
print('<param name="Local" value="' + location + '">', end=' ', file=outfile)
|
|
|
|
print('</OBJECT>', file=outfile)
|
|
|
|
print('</UL>', file=outfile)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
|
|
|
|
def codeexpand(self, line):
|
|
|
|
co = self.codeprog.match(line)
|
|
|
|
if not co:
|
|
|
|
return line
|
|
|
|
bgn, end = co.span(0)
|
|
|
|
a, b = co.span(1)
|
|
|
|
line = line[:bgn] + line[a:b] + line[end:]
|
|
|
|
return line
|
|
|
|
|
|
|
|
|
1995-03-15 07:26:05 -04:00
|
|
|
# Put @var{} around alphabetic substrings
|
|
|
|
def makevar(str):
|
1996-09-13 11:44:34 -03:00
|
|
|
return '@var{'+str+'}'
|
1995-03-15 07:26:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Split a string in "words" according to findwordend
|
|
|
|
def splitwords(str, minlength):
|
1996-09-13 11:44:34 -03:00
|
|
|
words = []
|
|
|
|
i = 0
|
|
|
|
n = len(str)
|
|
|
|
while i < n:
|
1998-09-14 13:03:02 -03:00
|
|
|
while i < n and str[i] in ' \t\n': i = i+1
|
|
|
|
if i >= n: break
|
|
|
|
start = i
|
|
|
|
i = findwordend(str, i, n)
|
|
|
|
words.append(str[start:i])
|
1996-09-13 11:44:34 -03:00
|
|
|
while len(words) < minlength: words.append('')
|
|
|
|
return words
|
1995-03-15 07:26:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Find the end of a "word", matching braces and interpreting @@ @{ @}
|
1998-04-23 19:59:33 -03:00
|
|
|
fwprog = re.compile('[@{} ]')
|
1995-03-15 07:26:05 -04:00
|
|
|
def findwordend(str, i, n):
|
1996-09-13 11:44:34 -03:00
|
|
|
level = 0
|
|
|
|
while i < n:
|
1998-04-23 19:59:33 -03:00
|
|
|
mo = fwprog.search(str, i)
|
|
|
|
if not mo:
|
|
|
|
break
|
|
|
|
i = mo.start()
|
1998-09-14 13:03:02 -03:00
|
|
|
c = str[i]; i = i+1
|
|
|
|
if c == '@': i = i+1 # Next character is not special
|
|
|
|
elif c == '{': level = level+1
|
|
|
|
elif c == '}': level = level-1
|
|
|
|
elif c == ' ' and level <= 0: return i-1
|
1996-09-13 11:44:34 -03:00
|
|
|
return n
|
1995-03-15 07:26:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Convert a node name into a file name
|
|
|
|
def makefile(nodename):
|
2002-06-18 12:37:05 -03:00
|
|
|
nodename = nodename.strip()
|
1996-09-13 11:44:34 -03:00
|
|
|
return fixfunnychars(nodename) + '.html'
|
1995-03-15 07:26:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Characters that are perfectly safe in filenames and hyperlinks
|
2001-07-20 16:05:50 -03:00
|
|
|
goodchars = string.ascii_letters + string.digits + '!@-=+.'
|
1995-03-15 07:26:05 -04:00
|
|
|
|
1995-08-28 00:01:00 -03:00
|
|
|
# Replace characters that aren't perfectly safe by dashes
|
|
|
|
# Underscores are bad since Cern HTTPD treats them as delimiters for
|
|
|
|
# encoding times, so you get mismatches if you compress your files:
|
|
|
|
# a.html.gz will map to a_b.html.gz
|
1995-03-15 07:26:05 -04:00
|
|
|
def fixfunnychars(addr):
|
1996-09-13 11:44:34 -03:00
|
|
|
i = 0
|
|
|
|
while i < len(addr):
|
1998-09-14 13:03:02 -03:00
|
|
|
c = addr[i]
|
|
|
|
if c not in goodchars:
|
|
|
|
c = '-'
|
|
|
|
addr = addr[:i] + c + addr[i+1:]
|
|
|
|
i = i + len(c)
|
1996-09-13 11:44:34 -03:00
|
|
|
return addr
|
1995-03-15 07:26:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
# Increment a string used as an enumeration
|
|
|
|
def increment(s):
|
1996-09-13 11:44:34 -03:00
|
|
|
if not s:
|
1998-09-14 13:03:02 -03:00
|
|
|
return '1'
|
1996-09-13 11:44:34 -03:00
|
|
|
for sequence in string.digits, string.lowercase, string.uppercase:
|
1998-09-14 13:03:02 -03:00
|
|
|
lastc = s[-1]
|
|
|
|
if lastc in sequence:
|
2002-06-18 12:37:05 -03:00
|
|
|
i = sequence.index(lastc) + 1
|
1998-09-14 13:03:02 -03:00
|
|
|
if i >= len(sequence):
|
|
|
|
if len(s) == 1:
|
|
|
|
s = sequence[0]*2
|
|
|
|
if s == '00':
|
|
|
|
s = '10'
|
|
|
|
else:
|
|
|
|
s = increment(s[:-1]) + sequence[0]
|
|
|
|
else:
|
|
|
|
s = s[:-1] + sequence[i]
|
|
|
|
return s
|
1996-09-13 11:44:34 -03:00
|
|
|
return s # Don't increment
|
1995-03-15 07:26:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
def test():
|
1996-09-13 11:44:34 -03:00
|
|
|
import sys
|
1996-10-09 16:05:12 -03:00
|
|
|
debugging = 0
|
|
|
|
print_headers = 0
|
|
|
|
cont = 0
|
|
|
|
html3 = 0
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
htmlhelp = ''
|
2001-01-17 04:48:39 -04:00
|
|
|
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
while sys.argv[1] == ['-d']:
|
1998-09-14 13:03:02 -03:00
|
|
|
debugging = debugging + 1
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
del sys.argv[1]
|
1996-10-09 16:05:12 -03:00
|
|
|
if sys.argv[1] == '-p':
|
1998-09-14 13:03:02 -03:00
|
|
|
print_headers = 1
|
|
|
|
del sys.argv[1]
|
1996-09-13 11:44:34 -03:00
|
|
|
if sys.argv[1] == '-c':
|
1998-09-14 13:03:02 -03:00
|
|
|
cont = 1
|
|
|
|
del sys.argv[1]
|
1996-10-09 16:05:12 -03:00
|
|
|
if sys.argv[1] == '-3':
|
1998-09-14 13:03:02 -03:00
|
|
|
html3 = 1
|
|
|
|
del sys.argv[1]
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
if sys.argv[1] == '-H':
|
|
|
|
helpbase = sys.argv[2]
|
|
|
|
del sys.argv[1:3]
|
1996-09-13 11:44:34 -03:00
|
|
|
if len(sys.argv) <> 3:
|
2007-08-03 14:06:41 -03:00
|
|
|
print('usage: texi2hh [-d [-d]] [-p] [-c] [-3] [-H htmlhelp]', \
|
|
|
|
'inputfile outputdirectory')
|
1998-09-14 13:03:02 -03:00
|
|
|
sys.exit(2)
|
1996-10-09 16:05:12 -03:00
|
|
|
|
|
|
|
if html3:
|
1998-09-14 13:03:02 -03:00
|
|
|
parser = TexinfoParserHTML3()
|
1996-10-09 16:05:12 -03:00
|
|
|
else:
|
1998-09-14 13:03:02 -03:00
|
|
|
parser = TexinfoParser()
|
1996-10-09 16:05:12 -03:00
|
|
|
parser.cont = cont
|
|
|
|
parser.debugging = debugging
|
|
|
|
parser.print_headers = print_headers
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
file = sys.argv[1]
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
dirname = sys.argv[2]
|
|
|
|
parser.setdirname(dirname)
|
2004-07-18 02:31:31 -03:00
|
|
|
parser.setincludedir(os.path.dirname(file))
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
|
|
|
|
htmlhelp = HTMLHelp(helpbase, dirname)
|
|
|
|
parser.sethtmlhelp(htmlhelp)
|
|
|
|
|
2004-07-18 02:31:31 -03:00
|
|
|
try:
|
|
|
|
fp = open(file, 'r')
|
2007-01-10 12:19:56 -04:00
|
|
|
except IOError as msg:
|
2007-08-03 14:06:41 -03:00
|
|
|
print(file, ':', msg)
|
2004-07-18 02:31:31 -03:00
|
|
|
sys.exit(1)
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
parser.parse(fp)
|
|
|
|
fp.close()
|
|
|
|
parser.report()
|
|
|
|
|
SF patch #552837, submitted by Robert Pyron:
1. BUGFIX: In function makefile(), strip blanks from the nodename.
This is necesary to match the behavior of parser.makeref() and
parser.do_node().
2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
it go away, rather than fix it)
3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
4. Support added for:
@uref URL reference
@image image file reference (see note below)
@multitable output an HTML table
@vtable
5. Partial support for accents, to match MAKEINFO output
6. I added a new command-line option, '-H basename', to specify
HTML Help output. This will cause three files to be created
in the current directory:
`basename`.hhp HTML Help Workshop project file
`basename`.hhc Contents file for the project
`basename`.hhk Index file for the project
When fed into HTML Help Workshop, the resulting file will be
named `basename`.chm.
7. A new class, HTMLHelp, to accomplish item 6.
8. Various calls to HTMLHelp functions.
A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
running this program, all referenced images must already exist
in outputdirectory.
FLD: wrapped some long lines.
2002-06-18 12:21:21 -03:00
|
|
|
htmlhelp.finalize()
|
|
|
|
|
1996-09-13 11:44:34 -03:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
test()
|