Edgewall Software

source: tags/0.3.5/genshi/__init__.py

Last change on this file was 299, checked in by cmlenz, 17 years ago

Fixed EOL style.

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# Copyright (C) 2006 Edgewall Software
4# All rights reserved.
5#
6# This software is licensed as described in the file COPYING, which
7# you should have received as part of this distribution. The terms
8# are also available at http://genshi.edgewall.org/wiki/License.
9#
10# This software consists of voluntary contributions made by many
11# individuals. For the exact contribution history, see the revision
12# history and logs, available at http://genshi.edgewall.org/log/.
13
14"""This package provides various means for generating and processing web markup
15(XML or HTML).
16
17The design is centered around the concept of streams of markup events (similar
18in concept to SAX parsing events) which can be processed in a uniform manner
19independently of where or how they are produced.
20
21
22Generating content
23------------------
24
25Literal XML and HTML text can be used to easily produce markup streams
26via helper functions in the `genshi.input` module:
27
28>>> from genshi.input import XML
29>>> doc = XML('<html lang="en"><head><title>My document</title></head></html>')
30
31This results in a `Stream` object that can be used in a number of way.
32
33>>> doc.render(method='html', encoding='utf-8')
34'<html lang="en"><head><title>My document</title></head></html>'
35
36>>> from genshi.input import HTML
37>>> doc = HTML('<HTML lang=en><HEAD><TITLE>My document</HTML>')
38>>> doc.render(method='html', encoding='utf-8')
39'<html lang="en"><head><title>My document</title></head></html>'
40
41>>> title = doc.select('head/title')
42>>> title.render(method='html', encoding='utf-8')
43'<title>My document</title>'
44
45
46Markup streams can also be generated programmatically using the
47`genshi.builder` module:
48
49>>> from genshi.builder import tag
50>>> doc = tag.doc(tag.title('My document'), lang='en')
51>>> doc.generate().render(method='html')
52'<doc lang="en"><title>My document</title></doc>'
53"""
54
55from genshi.core import *
56from genshi.input import ParseError, XML, HTML
Note: See TracBrowser for help on using the repository browser.