Mercurial > genshi > mirror
diff doc/filters.txt @ 533:4d486f15c986 trunk
Thanks to Dave Abrahams for pointing out some deficiencies in the transformer
filter:
- `apply()` has been renamed to `map()`.
- `filter()` applies a normal stream filter to the selection.
- To reduce confusion with normal stream filter pipelines the `__or__`
operator, which previously applied a custom transform, has been renamed to
`apply()`.
Also added a `substitute()` transformation that applies regex replacement to
`TEXT` events.
author | athomas |
---|---|
date | Fri, 22 Jun 2007 16:42:38 +0000 |
parents | 9e11fa7f4603 |
children | 0fcb1c0d7c20 |
line wrap: on
line diff
--- a/doc/filters.txt +++ b/doc/filters.txt @@ -164,7 +164,7 @@ ... </body> ... </html>''') - >>> print html | Transformer('body/em').apply(unicode.upper, TEXT) \ + >>> print html | Transformer('body/em').map(unicode.upper, TEXT) \ ... .unwrap().wrap(tag.u).end() \ ... .select('body/u') \ ... .prepend('underlined ') @@ -181,7 +181,7 @@ 2. uppercases any text nodes in the element, 3. strips off the `<em>` start and close tags, 4. wraps the content in a `<u>` tag, and - 5. inserts the text `underlind` inside the `<u>` tag. + 5. inserts the text `underlined` inside the `<u>` tag. A number of commonly useful transformations are available for this filter. Please consult the API documentation a complete list. @@ -209,13 +209,13 @@ stream. In this case we define a class, so that we can initialize it with the tag name. -Custom transformations can be applied using the `|` operator on the transformer -instance: +Custom transformations can be applied using the `apply()` method of a +transformer instance: .. code-block:: pycon - >>> xform = Transformer('body//em').apply(unicode.upper, TEXT) - >>> xform |= RenameTransformation('u') + >>> xform = Transformer('body//em').map(unicode.upper, TEXT) \ + >>> xform = xform.apply(RenameTransformation('u')) >>> print html | xform <html> <head><title>Some Title</title></head>