annotate markup/__init__.py @ 113:d10fbba1d5e0 trunk

Removed the `sanitize()` method from the `Markup` class, and migrate the existing unit tests to `markup.tests.filters`. Provide a `Stream.filter()` method instead which can be used to conveniently apply a filter to a stream.
author cmlenz
date Mon, 31 Jul 2006 23:00:06 +0000
parents 59eb24184e9c
children
rev   line source
1
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
1 # -*- coding: utf-8 -*-
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
2 #
66
59eb24184e9c Switch copyright to Edgewall and URLs to markup.edgewall.org.
cmlenz
parents: 27
diff changeset
3 # Copyright (C) 2006 Edgewall Software
1
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
4 # All rights reserved.
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
5 #
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
6 # This software is licensed as described in the file COPYING, which
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
7 # you should have received as part of this distribution. The terms
66
59eb24184e9c Switch copyright to Edgewall and URLs to markup.edgewall.org.
cmlenz
parents: 27
diff changeset
8 # are also available at http://markup.edgewall.org/wiki/License.
1
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
9 #
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
10 # This software consists of voluntary contributions made by many
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
11 # individuals. For the exact contribution history, see the revision
66
59eb24184e9c Switch copyright to Edgewall and URLs to markup.edgewall.org.
cmlenz
parents: 27
diff changeset
12 # history and logs, available at http://markup.edgewall.org/log/.
1
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
13
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
14 """This package provides various means for generating and processing web markup
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
15 (XML or HTML).
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
16
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
17 The design is centered around the concept of streams of markup events (similar
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
18 in concept to SAX parsing events) which can be processed in a uniform manner
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
19 independently of where or how they are produced.
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
20
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
21
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
22 Generating content
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
23 ------------------
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
24
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
25 Literal XML and HTML text can be used to easily produce markup streams
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
26 via helper functions in the `markup.input` module:
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
27
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
28 >>> from markup.input import XML
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
29 >>> doc = XML('<html lang="en"><head><title>My document</title></head></html>')
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
30
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
31 This results in a `Stream` object that can be used in a number of way.
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
32
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
33 >>> doc.render(method='html', encoding='utf-8')
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
34 '<html lang="en"><head><title>My document</title></head></html>'
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
35
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
36 >>> from markup.input import HTML
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
37 >>> doc = HTML('<HTML lang=en><HEAD><TITLE>My document</HTML>')
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
38 >>> doc.render(method='html', encoding='utf-8')
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
39 '<html lang="en"><head><title>My document</title></head></html>'
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
40
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
41 >>> title = doc.select('head/title')
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
42 >>> title.render(method='html', encoding='utf-8')
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
43 '<title>My document</title>'
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
44
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
45
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
46 Markup streams can also be generated programmatically using the
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
47 `markup.builder` module:
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
48
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
49 >>> from markup.builder import tag
20
cc92d74ce9e5 Fix tests broken in [20].
cmlenz
parents: 1
diff changeset
50 >>> doc = tag.doc(tag.title('My document'), lang='en')
1
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
51 >>> doc.generate().render(method='html')
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
52 '<doc lang="en"><title>My document</title></doc>'
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
53 """
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
54
5479aae32f5a Initial import.
cmlenz
parents:
diff changeset
55 from markup.core import *
21
b4d17897d053 * Include paths are now interpreted relative to the path of the including template. Closes #3.
cmlenz
parents: 20
diff changeset
56 from markup.input import ParseError, XML, HTML
Copyright (C) 2012-2017 Edgewall Software