Module q3html
source code
This program takes files named *.q in the current directory, and
converts them to HTML. To do that, it looks for a python script called
'headfoot.py' or '../headfoot.py' or ... . This script needs to define
one variable ( server ) and two functions (header and footer).
The .q files have the following format:
TITLE title string
OTHER_HEADER_KEYWORD header info
P
Text is 3>5 ?
A ref="foo.html" No!
More text inside the link.
IMG ref="foo.gif"
UL
LI List item
LI Another List item
The header info is separated from the body with a blank line. HTML
tags are always the first thing on a line. Line continuations and
enclosures are indicated with indentation. Tags automatically close when
the indentation gets smaller.
The PRE tag is the only exception. You have to close it with a line
beginning '/PRE'. No indenting is needed inside a PRE /PRE pair.
The user needs to define one thing: the address of the web server.
This address is prepended to all hyperlinks and image references that
aren't absolute.
All the header information gets put into a dictionary, and is passed
into the header() and footer() functions. That dictionary has 'filename'
and '_server_root' entries added.
The user can also define three things:
DEFAULT_HEADER, a dictionary passed to the header() and footer
functions(). Useful things to put in DEFAULT_HEADER are:
-
'lang': 'en' # appears in the <html lang="en"> tag
-
'stylesheet': url becomes a link to a stylesheet: <link
rel="stylesheet" type="text/css"
href="url">
-
Anything in the form M.x:y becomes a <meta name="x"
content="y">
-
M.description and M.keywords are useful.
-
Anything in the form HTTP.x:y becomes a <meta
http-equiv="x" content="y">
Header(thd, hinfo) takes two arguments, a file descriptor to which it
should write the HTML, and a dictionary of header information.
Footer(thd, hinfo) takes the same arguments.
See _header() and _footer() below, for examples.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
needcopy(a,
b,
force=None)
Do we need to reconstruct file b from file a? Also reconstruct b if
it is older than the date in force. |
source code
|
|
|
file_only(url)
Given a URL, just return the file part, not the target specifier
inside the file. |
source code
|
|
|
|
|
|
|
|
|
XML = 0
|
|
POINTTAG = 1
|
|
LL = 60
|
|
TABW = 8
|
|
DEFAULT_TAG = ' P '
|
|
DEFAULT_INDENT = -1
|
|
MTIME = 8
|
|
DEFF = ' headfoot.py '
|
|
__package__ = None
hash(x)
|
|
nm = ' lang '
|
|
q = 9001
|
Imports:
os,
re,
time,
urlparse,
ED,
die,
g_pipe
Process a URL. Pathnames are prepended with the server root. Complete
URLs are untouched.
|