The Html Class

Contents:

class gramps.plugins.lib.libhtml.Html(tag='html', *args, **keywargs)[source]

Bases: list

HTML class: Manages a rooted tree of HTML objects

addDOCTYPE(name='html', public='PUBLIC', external_id='', *args)[source]

Add a DOCTYPE statement to the start of the list

Parameters:
  • name (string) – name of this DOCTYPE. Defaults to “html”
  • external_id (string) – external identifier of this DOCTYPE. Defaults to XHTML 1.0 STRICT
  • args (object) – 0 or more positional parameters to be added to this DOCTYPE.
addXML(version=1.0, encoding='UTF-8', standalone='no')[source]

Add an XML statement to the start of the list for this object

Parameters:
  • version (decimal number) – version of XML to be used. Defaults to 1.0
  • encoding (string) – encoding method to be used. Defaults to “UTF-8”
  • standalone (string) – “yes” or “no”. Defaults to “no”
append(value)[source]

Append a new value

attr

Returns HTML attributes for this object

Return type:string
Returns:HTML attributes
close
static doctype(name='HTML', public='', external_id='')[source]

Build and return a DOCTYPE statement

Parameters:
  • name (string) – name of this DOCTYPE. Defaults to “html”
  • public (string) – class of this DOCTYPE. Defaults to ‘PUBLIC
  • external_id (string) – external identifier of this DOCTYPE. Defaults to XHTML 1.0 STRICT
  • args (object) – 0 or more positional parameters to be added to this DOCTYPE.
extend(value)

Append a new value

static head(title=None, encoding='utf-8', html5=True, *args, **keywargs)[source]

Build and return a properly-formated <head> object

Parameters:
  • title (string or None) – title for HTML page. Default=None. If None no title tag is written
  • encoding (string) – encoding to be used. Default = ‘utf-8’
  • html5 – generate html5 syntax. Default = True. Set to False if pre-html5 syntax required
Return type:

reference to new Html instance

Returns:

reference to the newly-created Html instances for <head> object

static html(xmlns='http://www.w3.org/1999/xhtml', lang='en', *args, **keywargs)[source]

Build and return a properly-formated <html> object

Parameters:
  • xmlns (string) – XML namespace string. Default = ‘http://www.w3.org/1999/xhtml
  • lang (string) – language to be used. Defaul = ‘en’
Return type:

reference to new Html instance

Returns:

reference to the newly-created Html instances for <html> object

indent
inline
inside

Returns list of items between opening and closing tags

Return type:list
Returns:list of items between opening and closing HTML tags
items
iteritems()

Iterator function: returns a generator that performs an insertion-order tree traversal and yields each item found.

iterkeys()

Iterator function: returns a generator that performs an insertion-order tree traversal and yields each item found.

itervalues()

Iterator function: returns a generator that performs an insertion-order tree traversal and yields each item found.

static page(title=None, encoding='utf-8', lang='en', html5=True, *args, **keywargs)[source]

This function prepares a new Html class based page and returns

Parameters:
  • title (string) – title for HTML page. Default=None
  • encoding (string) – encoding to be used. Default = ‘utf-8’
  • lang (string) – language to be used. Defaul = ‘en’
  • html5 – generate html5 syntax. Default = True. Set to False if pre-html5 syntax required
Return type:

three object references

Returns:

references to the newly-created Html instances for page, head and body

remove(value)

Overload function for - and -= operators :type value: object :param value: object to be removed

Return type:object reference
Returns:reference to object with value removed
replace(cur_value, value)[source]

Replace current value with new value

Parameters:
  • cur_value (object) – value of object to be replaced
  • value (object) – replacement value
Return type:

object reference

Returns:

reference to object with new value added

tag

Returns HTML tag for this object

Return type:string
Returns:HTML tag
write(method=<built-in function print>, indent='\t', tabs='')[source]

Output function: performs an insertion-order tree traversal and calls supplied method for each item found.

Parameters:
  • method (function reference) – function to call with each item found
  • indenf – string to use for indentation. Default = ‘ ‘ (tab)
  • tabs (string) – starting indentation
static xmldecl(version=1.0, encoding='UTF-8', standalone='no')[source]

Build and return an XML declaration statement

Parameters:
  • version (decimal number) – version of XML to be used. Defaults to 1.0
  • encoding (string) – encoding method to be used. Defaults to “UTF-8”
  • standalone (string) – “yes” or “no”. Defaults to “no”

Previous topic

The Simple Classes

This Page