view markup/__init__.py @ 27:b4f78c05e5c9 trunk

* Fix the boilerplate in the Python source files. * Some more docstrings and cosmetic fixes.
author cmlenz
date Wed, 28 Jun 2006 09:28:09 +0000
parents 5a4d45703319
children 59eb24184e9c
line wrap: on
line source
# -*- coding: utf-8 -*-
#
# Copyright (C) 2006 Christopher Lenz
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://markup.cmlenz.net/wiki/License.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://markup.cmlenz.net/log/.

"""This package provides various means for generating and processing web markup
(XML or HTML).

The design is centered around the concept of streams of markup events (similar
in concept to SAX parsing events) which can be processed in a uniform manner
independently of where or how they are produced.


Generating content
------------------

Literal XML and HTML text can be used to easily produce markup streams
via helper functions in the `markup.input` module:

>>> from markup.input import XML
>>> doc = XML('<html lang="en"><head><title>My document</title></head></html>')

This results in a `Stream` object that can be used in a number of way.

>>> doc.render(method='html', encoding='utf-8')
'<html lang="en"><head><title>My document</title></head></html>'

>>> from markup.input import HTML
>>> doc = HTML('<HTML lang=en><HEAD><TITLE>My document</HTML>')
>>> doc.render(method='html', encoding='utf-8')
'<html lang="en"><head><title>My document</title></head></html>'

>>> title = doc.select('head/title')
>>> title.render(method='html', encoding='utf-8')
'<title>My document</title>'


Markup streams can also be generated programmatically using the
`markup.builder` module:

>>> from markup.builder import tag
>>> doc = tag.doc(tag.title('My document'), lang='en')
>>> doc.generate().render(method='html')
'<doc lang="en"><title>My document</title></doc>'
"""

from markup.core import *
from markup.input import ParseError, XML, HTML
Copyright (C) 2012-2017 Edgewall Software