Mercurial > genshi > genshi-test
comparison doc/filters.txt @ 519:9f1d90d6abd4
Cut and copy transformer operations can now operate on selected attributes.
Also added an example of inserting content to the documentation.
author | athomas |
---|---|
date | Thu, 07 Jun 2007 18:03:02 +0000 |
parents | ca7d707d51b0 |
children | dfb45908fadc |
comparison
equal
deleted
inserted
replaced
518:97cdadc17e20 | 519:9f1d90d6abd4 |
---|---|
162 ... <body> | 162 ... <body> |
163 ... Some <em>body</em> text. | 163 ... Some <em>body</em> text. |
164 ... </body> | 164 ... </body> |
165 ... </html>''') | 165 ... </html>''') |
166 | 166 |
167 >>> print html | Transformer('body//em').apply(unicode.upper, TEXT) \ | 167 >>> print html | Transformer('body/em').apply(unicode.upper, TEXT) \ |
168 ... .unwrap().wrap(tag.u) | 168 ... .unwrap().wrap(tag.u).end() \ |
169 ... .select('body/u') \ | |
170 ... .prepend('underlined ') | |
169 <html> | 171 <html> |
170 <head><title>Some Title</title></head> | 172 <head><title>Some Title</title></head> |
171 <body> | 173 <body> |
172 Some <u>BODY</u> text. | 174 Some <u>underlined BODY</u> text. |
173 </body> | 175 </body> |
174 </html> | 176 </html> |
175 | 177 |
176 This example sets up a transformation that: | 178 This example sets up a transformation that: |
177 | 179 |
178 1. matches any `<em>` element anywhere in the body, | 180 1. matches any `<em>` element anywhere in the body, |
179 2. uppercases any text nodes in the element, | 181 2. uppercases any text nodes in the element, |
180 3. strips off the `<em>` start and close tags, and | 182 3. strips off the `<em>` start and close tags, |
181 4. wraps the content in a `<u>` tag. | 183 4. wraps the content in a `<u>` tag, and |
184 5. inserts the text `underlind` inside the `<u>` tag. | |
182 | 185 |
183 A number of commonly useful transformations are available for this filter. | 186 A number of commonly useful transformations are available for this filter. |
184 Please consult the API documentation a complete list. | 187 Please consult the API documentation a complete list. |
185 | 188 |
186 In addition, you can also perform custom transformations. For example, the | 189 In addition, you can also perform custom transformations. For example, the |