|
|
8c93bb |
# Copyright (C) 2011 The CentOS Project
|
|
|
8c93bb |
#
|
|
|
8c93bb |
# This program is free software; you can redistribute it and/or modify
|
|
|
8c93bb |
# it under the terms of the GNU General Public License as published by
|
|
|
8c93bb |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
8c93bb |
# (at your option) any later version.
|
|
|
8c93bb |
#
|
|
|
8c93bb |
# This program is distributed in the hope that it will be useful, but
|
|
|
8c93bb |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
8c93bb |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
8c93bb |
# General Public License for more details.
|
|
|
8c93bb |
#
|
|
|
8c93bb |
# You should have received a copy of the GNU General Public License
|
|
|
8c93bb |
# along with this program; if not, write to the Free Software
|
|
|
8c93bb |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
8c93bb |
#
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# $Id$
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
d1936d |
"""Support XHTML construction.
|
|
|
fb06c9 |
|
|
|
fb06c9 |
XHTML construction, as set here, uses the Extensible HTML version 1.0
|
|
|
fb06c9 |
DTDs (/usr/share/sgml/xhtml1/xhtml1-20020801/DTD/) as reference. XHTML
|
|
|
fb06c9 |
construction is required by page module.
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
class Strict:
|
|
|
8c93bb |
"""Implements XHTML strict document type definition."""
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# Core attributes common to most elements.
|
|
|
76d303 |
coreattrs = ['id', # document-wide unique id
|
|
|
76d303 |
'class', # space separated list of classes
|
|
|
76d303 |
'style', # associated style info
|
|
|
76d303 |
'title' # advisory title/amplification
|
|
|
76d303 |
]
|
|
|
8c93bb |
|
|
|
76d303 |
# Internationalization attributes.
|
|
|
76d303 |
i18n = ['lang', # language code (backwards compatible)
|
|
|
76d303 |
'xml:lang', # language code (as per XML 1.0 spec)
|
|
|
76d303 |
'dir' # direction for weak/neutral text
|
|
|
76d303 |
]
|
|
|
8c93bb |
|
|
|
76d303 |
# Attributes for common UI events.
|
|
|
76d303 |
events = ['onclick', # a pointer button was clicked
|
|
|
76d303 |
'ondblclick', # a pointer button was double clicked
|
|
|
76d303 |
'onmousedown', # a pointer button was pressed down
|
|
|
76d303 |
'onmouseup', # a pointer button was released
|
|
|
76d303 |
'onmousemove', # a pointer was moved onto the element
|
|
|
76d303 |
'onmouseout', # a pointer was moved away from the element
|
|
|
76d303 |
'onkeypress', # a key was pressed and released
|
|
|
76d303 |
'onkeydown', # a key was pressed down
|
|
|
76d303 |
'onkeyup' # a key was released
|
|
|
76d303 |
]
|
|
|
8c93bb |
|
|
|
76d303 |
# Attributes for elements that can get the focus.
|
|
|
76d303 |
focus = ['accesskey', # accessibility key character
|
|
|
76d303 |
'tabindex', # position in tabbing order
|
|
|
76d303 |
'onfocus', # the element got the focus
|
|
|
76d303 |
'onblur' # the element lost the focus
|
|
|
76d303 |
]
|
|
|
8c93bb |
|
|
|
76d303 |
# Attributes generic format.
|
|
|
76d303 |
attrs = coreattrs + i18n + events
|
|
|
76d303 |
|
|
|
76d303 |
|
|
|
76d303 |
def __init__(self):
|
|
|
76d303 |
"""Initialize class data."""
|
|
|
76d303 |
pass
|
|
|
76d303 |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag(self, name, attrs, indent=[8,1], content="", has_child=0):
|
|
|
8c93bb |
"""Returns generic XHTML tag definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
Arguments:
|
|
|
8c93bb |
|
|
|
8c93bb |
name: The XHTML tag's name. Notice that this function doesn't
|
|
|
8c93bb |
verify nor validate the XHTML tags you provide. It is up
|
|
|
8c93bb |
to you write them correctly considering the XHTML standard
|
|
|
8c93bb |
definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
attrs: The XHTML tag's attribute. Notice that this function
|
|
|
8c93bb |
doesn't verify the attributes assignation to tags. You
|
|
|
8c93bb |
need to know what attributes are considered valid to the
|
|
|
8c93bb |
tag you are creating in order to build a well-formed XHTML
|
|
|
8c93bb |
document. Such verification can be achived inside firefox
|
|
|
8c93bb |
browser through the `firebug' plugin.
|
|
|
8c93bb |
|
|
|
8c93bb |
indent: The XHTML tag's indentation (Optional). This argument
|
|
|
8c93bb |
is a list of two numerical values. The first value in the
|
|
|
8c93bb |
list represents the amount of horizontal spaces between
|
|
|
8c93bb |
the beginning of line and the opening tag. The second
|
|
|
8c93bb |
value in the list represents the amount of vertical spaces
|
|
|
8c93bb |
(new lines) between tags.
|
|
|
8c93bb |
|
|
|
8c93bb |
content: The XHTML tag's content (Optional). This argument
|
|
|
8c93bb |
provides the information the tag encloses. When this
|
|
|
8c93bb |
argument is empty, tag is rendered without content.
|
|
|
8c93bb |
|
|
|
8c93bb |
has_child: The XHTML tag has a child? (Optional). This
|
|
|
8c93bb |
argument is specifies whether a tag has another tag inside
|
|
|
8c93bb |
(1) or not (0). When a tag has not a child tag,
|
|
|
8c93bb |
indentation is applied between the tag content and the
|
|
|
8c93bb |
closing tag provoking an unecessary spaces to be shown.
|
|
|
8c93bb |
Such kind of problems are prevented by setting this option
|
|
|
8c93bb |
to `0'. On the other hand, when a tag has a child tag
|
|
|
8c93bb |
inside, using the value `1' will keep the closing tag
|
|
|
8c93bb |
indentation aligned with the opening one.
|
|
|
8c93bb |
|
|
|
8c93bb |
This function encapsulates the construction of XHTML tags.
|
|
|
8c93bb |
Use this function wherever you need to create XHTML tags. It
|
|
|
8c93bb |
helps to standardize tag constructions and their final output
|
|
|
8c93bb |
and. This function provides a consistent way of producing
|
|
|
8c93bb |
output for XHTML documents.
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
if indent[0] > 0:
|
|
|
8c93bb |
h_indent = ' '*indent[0]
|
|
|
8c93bb |
else:
|
|
|
8c93bb |
h_indent = ''
|
|
|
8c93bb |
|
|
|
8c93bb |
if indent[1] > 0:
|
|
|
8c93bb |
v_indent = "\n"*indent[1]
|
|
|
8c93bb |
else:
|
|
|
8c93bb |
v_indent = ''
|
|
|
8c93bb |
|
|
|
8c93bb |
output = v_indent + h_indent + '<' + str(name)
|
|
|
8c93bb |
if len(attrs) > 0:
|
|
|
8c93bb |
attr_names = attrs.keys()
|
|
|
8c93bb |
attr_names.sort()
|
|
|
8c93bb |
for attr_name in attr_names:
|
|
|
8c93bb |
output += ' ' + str(attr_name) + '="' + str(attrs[attr_name]) + '"'
|
|
|
8c93bb |
if content == '':
|
|
|
8c93bb |
output += ' />'
|
|
|
8c93bb |
else:
|
|
|
8c93bb |
output += '>'
|
|
|
8c93bb |
output += str(content)
|
|
|
8c93bb |
if has_child == 1:
|
|
|
8c93bb |
output += h_indent + '</' + str(name) + '>'
|
|
|
8c93bb |
else:
|
|
|
8c93bb |
output += '</' + str(name) + '>'
|
|
|
8c93bb |
output += v_indent
|
|
|
8c93bb |
|
|
|
8c93bb |
return output
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
76d303 |
# Document Type Definition
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
76d303 |
|
|
|
125760 |
def doctype(self):
|
|
|
76d303 |
"""Return document type definition."""
|
|
|
76d303 |
output = '' + "\n"
|
|
|
76d303 |
output += '
|
|
|
76d303 |
output += ' '*4 + 'PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' + "\n"
|
|
|
76d303 |
output += ' '*4 + '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' + "\n"
|
|
|
76d303 |
|
|
|
76d303 |
return output
|
|
|
76d303 |
|
|
|
76d303 |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Document Structure
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_html(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns document structure definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%i18n;
|
|
|
8c93bb |
id ID #IMPLIED
|
|
|
8c93bb |
xmlns %URI; #FIXED 'http://www.w3.org/1999/xhtml'
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
The namespace URI designates the document profile.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('html', attrs, indent, content, has_child=1)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Document Head
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_head(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns document head definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
((title, %head.misc;, (base, %head.misc;)?) |
|
|
|
8c93bb |
(base, %head.misc;, (title, %head.misc;))))>
|
|
|
8c93bb |
|
|
|
8c93bb |
%i18n;
|
|
|
8c93bb |
id ID #IMPLIED
|
|
|
8c93bb |
profile %URI; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Content model is %head.misc; combined with a single title and
|
|
|
8c93bb |
an optional base element in any order.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('head', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_title(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns title definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%i18n;
|
|
|
8c93bb |
id ID #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
The title element is not considered part of the flow of text.
|
|
|
8c93bb |
It should be displayed, for example as the page header or
|
|
|
8c93bb |
window title. Exactly one title is required per document.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('title', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_base(self, attrs, indent):
|
|
|
8c93bb |
"""Returns document base URI.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
href %URI; #REQUIRED
|
|
|
8c93bb |
id ID #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('base', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_meta(self, attrs, indent):
|
|
|
8c93bb |
"""Returns generic metainformation.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%i18n;
|
|
|
8c93bb |
id ID #IMPLIED
|
|
|
8c93bb |
http-equiv CDATA #IMPLIED
|
|
|
8c93bb |
name CDATA #IMPLIED
|
|
|
8c93bb |
content CDATA #REQUIRED
|
|
|
8c93bb |
scheme CDATA #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('meta', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_link(self, attrs, indent):
|
|
|
8c93bb |
"""Returns relationship values.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
charset %Charset; #IMPLIED
|
|
|
8c93bb |
href %URI; #IMPLIED
|
|
|
8c93bb |
hreflang %LanguageCode; #IMPLIED
|
|
|
8c93bb |
type %ContentType; #IMPLIED
|
|
|
8c93bb |
rel %LinkTypes; #IMPLIED
|
|
|
8c93bb |
rev %LinkTypes; #IMPLIED
|
|
|
8c93bb |
media %MediaDesc; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Relationship values can be used in principle:
|
|
|
8c93bb |
|
|
|
8c93bb |
a) for document specific toolbars/menus when used with the
|
|
|
8c93bb |
link element in document head e.g. start, contents,
|
|
|
8c93bb |
previous, next, index, end, help.
|
|
|
8c93bb |
|
|
|
8c93bb |
b) to link to a separate style sheet (rel="stylesheet").
|
|
|
8c93bb |
|
|
|
8c93bb |
c) to make a link to a script (rel="script").
|
|
|
8c93bb |
|
|
|
8c93bb |
d) by stylesheets to control how collections of html nodes
|
|
|
8c93bb |
are rendered into printed documents.
|
|
|
8c93bb |
|
|
|
8c93bb |
e) to make a link to a printable version of this document
|
|
|
8c93bb |
e.g. a PostScript or PDF version (rel="alternate"
|
|
|
8c93bb |
media="print").
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('link', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_style(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns style info.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%i18n;
|
|
|
8c93bb |
id ID #IMPLIED
|
|
|
8c93bb |
type %ContentType; #REQUIRED
|
|
|
8c93bb |
media %MediaDesc; #IMPLIED
|
|
|
8c93bb |
title %Text; #IMPLIED
|
|
|
8c93bb |
xml:space (preserve) #FIXED 'preserve'
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('style', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
1236a9 |
def tag_script(self, attrs, indent, content="", has_child=0):
|
|
|
8c93bb |
"""Returns script statement.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
id ID #IMPLIED
|
|
|
8c93bb |
charset %Charset; #IMPLIED
|
|
|
8c93bb |
type %ContentType; #REQUIRED
|
|
|
8c93bb |
src %URI; #IMPLIED
|
|
|
8c93bb |
defer (defer) #IMPLIED
|
|
|
8c93bb |
xml:space (preserve) #FIXED 'preserve'
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('script', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_noscript(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns alternate content container for non script-based
|
|
|
8c93bb |
rendering.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag(self, attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Document Body
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_body(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns document body definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
onload %Script; #IMPLIED
|
|
|
8c93bb |
onunload %Script; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('body', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_div(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns generic language/style container.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('div', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Paragraphs
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_p(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns paragraph definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
fb06c9 |
When content is introduced inside the database, it goes
|
|
|
fb06c9 |
without any XHTML markup. This method transforms newline
|
|
|
fb06c9 |
separated strings into XHTML paragraphs.
|
|
|
fb06c9 |
|
|
|
8c93bb |
"""
|
|
|
fb06c9 |
output = ''
|
|
|
fb06c9 |
for line in content.splitlines():
|
|
|
fb06c9 |
if line == '': continue
|
|
|
fb06c9 |
output += self.tag('p', attrs, indent, line.strip(), has_child)
|
|
|
fb06c9 |
return output
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Headings
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# There are six levels of headings from h1 (the most important) to
|
|
|
8c93bb |
# h6 (the least important).
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_h1(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns h1 definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('h1', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_h2(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns h2 definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('h2', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_h3(self, attrs, indent, content, has_child):
|
|
|
8c93bb |
"""Returns h3 definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('h3', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_h4(self, attrs, indent, content, has_child):
|
|
|
8c93bb |
"""Returns h4 definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('h4', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_h5(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns h5 definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('h5', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_h6(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns h6 definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('h6', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Lists
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_ul(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns unordered list definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('ul', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_ol(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns ordered (numbered) list definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('ol', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_li(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns item definition for both ordered (ol) and unordered
|
|
|
8c93bb |
(ul) lists.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('li', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_dl(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns definition list definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('dl', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_dt(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns term of definition lists.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('dt', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_dd(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns definition of definition lists.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('dd', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Address
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_address(self, attrs, indent, content='', has_child=0):
|
|
|
8c93bb |
"""Returns information on author.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('address', attrs, indent, content)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Horizontal Rule
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_hr(self, attrs, indent):
|
|
|
8c93bb |
"""Returns horizontal rule.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('hr', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Preformatted text
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_pre(self, attrs, indent, content):
|
|
|
8c93bb |
"""Returns preformatted text.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
xml:space (preserve) #FIXED 'preserve'
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
content is %Inline; excluding "img|object|big|small|sub|sup"
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('pre', attrs, indent, content)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Block-line Quotes
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_blockquote(self, attrs, indent, content):
|
|
|
8c93bb |
"""Returns block-line quote.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
cite %URI; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('blockquote', attrs, indent, content)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Inserted/Deleted Text
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_ins(self, attrs, indent, content):
|
|
|
8c93bb |
"""Returns inserted text.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
cite %URI; #IMPLIED
|
|
|
8c93bb |
datetime %Datetime; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Inserted texts are allowed in block and inline content, but
|
|
|
8c93bb |
its inappropriate to include block content within an ins
|
|
|
8c93bb |
element occurring in inline content.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('ins', attrs, indent, content)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_del(self, attrs, indent, content):
|
|
|
8c93bb |
"""Returns deleted text.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
cite %URI; #IMPLIED
|
|
|
8c93bb |
datetime %Datetime; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Deleted texts are allowed in block and inline content, but its
|
|
|
8c93bb |
inappropriate to include block content within an ins element
|
|
|
8c93bb |
occurring in inline content.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('ins', attrs, indent, content)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# The Anchor Element
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_a(self, attrs, indent, content='', has_child=0):
|
|
|
8c93bb |
"""Returns the anchor element.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
%focus;
|
|
|
8c93bb |
charset %Charset; #IMPLIED
|
|
|
8c93bb |
type %ContentType; #IMPLIED
|
|
|
8c93bb |
name NMTOKEN #IMPLIED
|
|
|
8c93bb |
href %URI; #IMPLIED
|
|
|
8c93bb |
hreflang %LanguageCode; #IMPLIED
|
|
|
8c93bb |
rel %LinkTypes; #IMPLIED
|
|
|
8c93bb |
rev %LinkTypes; #IMPLIED
|
|
|
8c93bb |
shape %Shape; "rect"
|
|
|
8c93bb |
coords %Coords; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
content is %Inline; except that anchors shouldn't be nested.
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('a', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Inline Elements
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_span(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns span definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('span', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_dbo(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns dbo definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%coreattrs;
|
|
|
8c93bb |
%events;
|
|
|
8c93bb |
lang %LanguageCode; #IMPLIED
|
|
|
8c93bb |
xml:lang %LanguageCode; #IMPLIED
|
|
|
8c93bb |
dir (ltr|rtl) #REQUIRED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('dbo', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_br(self, attrs, indent):
|
|
|
8c93bb |
"""Returns break definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%coreattrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('br', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_em(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns emphasis definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('em', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_strong(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns strong emphasis definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('strong', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_dfn(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns definitional definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('dfn', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_code(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns program code definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('code', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_samp(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns sample definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('samp', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_kbd(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns definition for something user would type.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('kbd', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_var(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns variable definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('var', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_cite(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns citation definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('cite', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_abbr(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns abbreviation definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('abbr', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_acronym(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns the acronym definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('acronym', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_q(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns inline quote definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
cite %URI; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('q', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_sub(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns subscript definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('sub', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_sup(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns superscript definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('sup', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_tt(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns fixed pitch font definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('tt', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_i(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns italic font definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('i', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_b(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns bold font definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('b', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_big(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns bigger font definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('big', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_small(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns smaller font definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('small', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Object
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_object(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns object definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
| %misc;)*>
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
declare (declare) #IMPLIED
|
|
|
8c93bb |
classid %URI; #IMPLIED
|
|
|
8c93bb |
codebase %URI; #IMPLIED
|
|
|
8c93bb |
data %URI; #IMPLIED
|
|
|
8c93bb |
type %ContentType; #IMPLIED
|
|
|
8c93bb |
codetype %ContentType; #IMPLIED
|
|
|
8c93bb |
archive %UriList; #IMPLIED
|
|
|
8c93bb |
standby %Text; #IMPLIED
|
|
|
8c93bb |
height %Length; #IMPLIED
|
|
|
8c93bb |
width %Length; #IMPLIED
|
|
|
8c93bb |
usemap %URI; #IMPLIED
|
|
|
8c93bb |
name NMTOKEN #IMPLIED
|
|
|
8c93bb |
tabindex %Number;
|
|
|
8c93bb |
#IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
The object definition is used to embed objects as part of HTML
|
|
|
8c93bb |
pages. param elements should precede other content.
|
|
|
8c93bb |
Parameters can also be expressed as attribute/value pairs on
|
|
|
8c93bb |
the object element itself when brevity is desired.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('object', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_param(self, attrs, indent):
|
|
|
8c93bb |
"""Returns param definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
id ID #IMPLIED
|
|
|
8c93bb |
name CDATA #IMPLIED
|
|
|
8c93bb |
value CDATA #IMPLIED
|
|
|
8c93bb |
valuetype (data|ref|object) "data"
|
|
|
8c93bb |
type %ContentType; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
The param definition is used to supply a named property value.
|
|
|
8c93bb |
In XML it would seem natural to follow RDF and support an
|
|
|
8c93bb |
abbreviated syntax where the param elements are replaced by
|
|
|
8c93bb |
attribute value pairs on the object start tag.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('object', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Images
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_img(self, attrs, indent):
|
|
|
8c93bb |
"""Returns image definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
src %URI; #REQUIRED
|
|
|
8c93bb |
alt %Text; #REQUIRED
|
|
|
8c93bb |
longdesc %URI; #IMPLIED
|
|
|
8c93bb |
height %Length; #IMPLIED
|
|
|
8c93bb |
width %Length; #IMPLIED
|
|
|
8c93bb |
usemap %URI; #IMPLIED
|
|
|
8c93bb |
ismap (ismap) #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
To avoid accessibility problems for people who aren't able to
|
|
|
8c93bb |
see the image, you should provide a text description using the
|
|
|
8c93bb |
alt and longdesc attributes. In addition, avoid the use of
|
|
|
8c93bb |
server-side image maps. Note that in this DTD there is no
|
|
|
8c93bb |
name attribute. That is only available in the transitional
|
|
|
8c93bb |
and frameset DTD.
|
|
|
8c93bb |
|
|
|
8c93bb |
usemap points to a map element which may be in this document
|
|
|
8c93bb |
or an external document, although the latter is not widely
|
|
|
8c93bb |
supported.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('img', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Client-side image maps
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_map(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns map definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%i18n;
|
|
|
8c93bb |
%events;
|
|
|
8c93bb |
id ID #REQUIRED
|
|
|
8c93bb |
class CDATA #IMPLIED
|
|
|
8c93bb |
style %StyleSheet; #IMPLIED
|
|
|
8c93bb |
title %Text; #IMPLIED
|
|
|
8c93bb |
name NMTOKEN #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
This can be placed in the same document or grouped in a
|
|
|
8c93bb |
separate document although this isn't yet widely supported.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('map', attrs, indent, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_area(self, attrs, indent):
|
|
|
8c93bb |
"""Returns area definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
%focus;
|
|
|
8c93bb |
shape %Shape; "rect"
|
|
|
8c93bb |
coords %Coords; #IMPLIED
|
|
|
8c93bb |
href %URI; #IMPLIED
|
|
|
8c93bb |
nohref (nohref) #IMPLIED
|
|
|
8c93bb |
alt %Text; #REQUIRED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
This can be placed in the same document or grouped in a
|
|
|
8c93bb |
separate document although this isn't yet widely supported.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('area', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
# Forms
|
|
|
76d303 |
# ------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_form(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns form definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
action %URI; #REQUIRED
|
|
|
8c93bb |
method (get|post) "get"
|
|
|
8c93bb |
enctype %ContentType; "application/x-www-form-urlencoded"
|
|
|
8c93bb |
onsubmit %Script; #IMPLIED
|
|
|
8c93bb |
onreset %Script; #IMPLIED
|
|
|
8c93bb |
accept %ContentTypes; #IMPLIED
|
|
|
8c93bb |
accept-charset %Charsets; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
95f8a5 |
return self.tag('form', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_label(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns label definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
for IDREF #IMPLIED
|
|
|
8c93bb |
accesskey %Character; #IMPLIED
|
|
|
8c93bb |
onfocus %Script; #IMPLIED
|
|
|
8c93bb |
onblur %Script; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Each label must not contain more than ONE field Label elements
|
|
|
8c93bb |
shouldn't be nested.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('label', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_input(self, attrs, indent):
|
|
|
8c93bb |
"""Returns input definition for form control.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"(text | password | checkbox | radio | submit | reset |
|
|
|
8c93bb |
file | hidden | image | button)"
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
%focus;
|
|
|
8c93bb |
type %InputType; "text"
|
|
|
8c93bb |
name CDATA #IMPLIED
|
|
|
8c93bb |
value CDATA #IMPLIED
|
|
|
8c93bb |
checked (checked) #IMPLIED
|
|
|
8c93bb |
disabled (disabled) #IMPLIED
|
|
|
8c93bb |
readonly (readonly) #IMPLIED
|
|
|
8c93bb |
size CDATA #IMPLIED
|
|
|
8c93bb |
maxlength %Number; #IMPLIED
|
|
|
8c93bb |
src %URI; #IMPLIED
|
|
|
8c93bb |
alt CDATA #IMPLIED
|
|
|
8c93bb |
usemap %URI; #IMPLIED
|
|
|
8c93bb |
onselect %Script; #IMPLIED
|
|
|
8c93bb |
onchange %Script; #IMPLIED
|
|
|
8c93bb |
accept %ContentTypes; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
The name attribute is required for all but submit & reset.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('input', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_select(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns select definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
name CDATA #IMPLIED
|
|
|
8c93bb |
size %Number; #IMPLIED
|
|
|
8c93bb |
multiple (multiple) #IMPLIED
|
|
|
8c93bb |
disabled (disabled) #IMPLIED
|
|
|
8c93bb |
tabindex %Number; #IMPLIED
|
|
|
8c93bb |
onfocus %Script; #IMPLIED
|
|
|
8c93bb |
onblur %Script; #IMPLIED
|
|
|
8c93bb |
onchange %Script; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('select', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_optgroup(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns option group definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
disabled (disabled) #IMPLIED
|
|
|
8c93bb |
label %Text; #REQUIRED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('optgroup', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_option(self, attrs, indent, content, has_child=0):
|
|
|
8c93bb |
"""Returns option definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
selected (selected) #IMPLIED
|
|
|
8c93bb |
disabled (disabled) #IMPLIED
|
|
|
8c93bb |
label %Text; #IMPLIED
|
|
|
8c93bb |
value CDATA #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('option', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_textarea(self, attrs, indent, content):
|
|
|
8c93bb |
"""Returns textarea definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
%focus;
|
|
|
8c93bb |
name CDATA #IMPLIED
|
|
|
8c93bb |
rows %Number; #REQUIRED
|
|
|
8c93bb |
cols %Number; #REQUIRED
|
|
|
8c93bb |
disabled (disabled) #IMPLIED
|
|
|
8c93bb |
readonly (readonly) #IMPLIED
|
|
|
8c93bb |
onselect %Script; #IMPLIED
|
|
|
8c93bb |
onchange %Script; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.textarea('textarea', attrs, indent, content)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_fieldset(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns fieldset definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
The fieldset element is used to group form fields. Only one
|
|
|
8c93bb |
legend element should occur in the content and if present
|
|
|
8c93bb |
should only be preceded by whitespace.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('filedset', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_legend(self, attrs, indent, content):
|
|
|
8c93bb |
"""Retruns legend definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
accesskey %Character; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('legend', attrs, indent, content)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_button(self, attrs, indent, content):
|
|
|
8c93bb |
"""Returns button definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
%focus;
|
|
|
8c93bb |
name CDATA #IMPLIED
|
|
|
8c93bb |
value CDATA #IMPLIED
|
|
|
8c93bb |
type (button|submit|reset) "submit"
|
|
|
8c93bb |
disabled (disabled) #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
content is %Flow; excluding a, form and form controls.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('button', attrs, indent, content)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_table(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns table definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
"align (left|center|right|justify|char) #IMPLIED
|
|
|
8c93bb |
char %Character; #IMPLIED
|
|
|
8c93bb |
charoff %Length; #IMPLIED"
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
(caption?, (col*|colgroup*), thead?, tfoot?,
|
|
|
8c93bb |
(tbody+|tr+))>
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
summary %Text; #IMPLIED
|
|
|
8c93bb |
width %Length; #IMPLIED
|
|
|
8c93bb |
border %Pixels; #IMPLIED
|
|
|
8c93bb |
frame %TFrame; #IMPLIED
|
|
|
8c93bb |
rules %TRules; #IMPLIED
|
|
|
8c93bb |
cellspacing %Length; #IMPLIED
|
|
|
8c93bb |
cellpadding %Length; #IMPLIED
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Derived from IETF HTML table standard, see [RFC1942]
|
|
|
8c93bb |
|
|
|
8c93bb |
The border attribute sets the thickness of the frame around
|
|
|
8c93bb |
the table. The default units are screen pixels. The frame
|
|
|
8c93bb |
attribute specifies which parts of the frame around the table
|
|
|
8c93bb |
should be rendered. The values are not the same as CALS to
|
|
|
8c93bb |
avoid a name clash with the valign attribute. The rules
|
|
|
8c93bb |
attribute defines which rules to draw between cells: If rules
|
|
|
8c93bb |
is absent then assume: "none" if border is absent or
|
|
|
8c93bb |
border="0" otherwise "all". Horizontal alignment attributes
|
|
|
8c93bb |
for cell contents:
|
|
|
8c93bb |
char alignment char, e.g. char=':'
|
|
|
8c93bb |
charoff offset for alignment char
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('table', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_caption(self, attrs, indent, content):
|
|
|
8c93bb |
"""Returns caption definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('caption', attrs, indent, content)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_thead(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns thead definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
%cellhalign;
|
|
|
8c93bb |
%cellvalign;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Use thead to duplicate headers when breaking table across page
|
|
|
8c93bb |
boundaries, or for static headers when tbody sections are
|
|
|
8c93bb |
rendered in scrolling panel.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('thead', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_tbody(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns tbody definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
%cellhalign;
|
|
|
8c93bb |
%cellvalign;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Use tbody to duplicate footers when breaking table across page
|
|
|
8c93bb |
boundaries, or for static footers when tbody sections are
|
|
|
8c93bb |
rendered in scrolling panel.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('tbody', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_tbody(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns tbody definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
%cellhalign;
|
|
|
8c93bb |
%cellvalign;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Use multiple tbody sections when rules are needed between
|
|
|
8c93bb |
groups of table rows.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('tbody', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_colgroup(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns colgroup definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
span %Number; "1"
|
|
|
8c93bb |
width %MultiLength; #IMPLIED
|
|
|
8c93bb |
%cellhalign;
|
|
|
8c93bb |
%cellvalign;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
colgroup groups a set of col elements. It allows you to group
|
|
|
8c93bb |
several semantically related columns together.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('colgroup', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_col(self, attrs, indent):
|
|
|
8c93bb |
"""Returns col definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
span %Number; "1"
|
|
|
8c93bb |
width %MultiLength; #IMPLIED
|
|
|
8c93bb |
%cellhalign;
|
|
|
8c93bb |
%cellvalign;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
col elements define the alignment properties for cells in one
|
|
|
8c93bb |
or more columns. The width attribute specifies the width of
|
|
|
8c93bb |
the columns, e.g.
|
|
|
8c93bb |
|
|
|
8c93bb |
width=64 width in screen pixels
|
|
|
8c93bb |
width=0.5* relative width of 0.5
|
|
|
8c93bb |
|
|
|
8c93bb |
The span attribute causes the attributes of one col element to
|
|
|
8c93bb |
apply to more than one column.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('col', attrs, indent)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_tr(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns table row definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
%cellhalign;
|
|
|
8c93bb |
%cellvalign;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('tr', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_th(self, attrs, indent, content, has_child):
|
|
|
8c93bb |
"""Returns table header definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
abbr %Text; #IMPLIED
|
|
|
8c93bb |
axis CDATA #IMPLIED
|
|
|
8c93bb |
headers IDREFS #IMPLIED
|
|
|
8c93bb |
scope %Scope; #IMPLIED
|
|
|
8c93bb |
rowspan %Number; "1"
|
|
|
8c93bb |
colspan %Number; "1"
|
|
|
8c93bb |
%cellhalign;
|
|
|
8c93bb |
%cellvalign;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
Scope is simpler than headers attribute for common tables. th
|
|
|
8c93bb |
is for headers, td for data and for cells acting as both.
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tab('th', attrs, indent, content, has_child)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def tag_td(self, attrs, indent, content, has_child=1):
|
|
|
8c93bb |
"""Returns table data definition.
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
%attrs;
|
|
|
8c93bb |
abbr %Text; #IMPLIED
|
|
|
8c93bb |
axis CDATA #IMPLIED
|
|
|
8c93bb |
headers IDREFS #IMPLIED
|
|
|
8c93bb |
scope %Scope; #IMPLIED
|
|
|
8c93bb |
rowspan %Number; "1"
|
|
|
8c93bb |
colspan %Number; "1"
|
|
|
8c93bb |
%cellhalign;
|
|
|
8c93bb |
%cellvalign;
|
|
|
8c93bb |
>
|
|
|
8c93bb |
|
|
|
8c93bb |
"""
|
|
|
8c93bb |
return self.tag('td', attrs, indent, content, has_child)
|