With the introduction of the Genshi template engine in Trac 0.11, most of the (X)HTML content is produced directly using Genshi facilities, like the builder or snippet templates. The old html tag building facility is now not much more than an alias to the tag ElementFactory, and most of the code uses directly the latter.
A TransposingElementFactory using str.lower transformation.
A genshi.builder.ElementFactory which applies func to the named attributes before creating a genshi.builder.Element.
Sanitize HTML constructions which are potentially vector of phishing or XSS attacks, in user-supplied HTML.
See also genshi.HTMLSanitizer.
Help base class used for cleaning up HTML riddled with <FONT COLOR=...> tags and replace them with appropriate <span class="...">.
The subclass must define a rules() static method returning a list of regular expression fragments, each defining a capture group in which the name will be reused for the span’s class. Two special group names, font and endfont are used to emit <span> and </span>, respectively.
See some usage examples in tracopt.mimeview.enscript.EnscriptDeuglifier and tracopt.mimeview.php.PhpDeuglifier.
Create a Markup instance from a string and escape special characters it may contain (<, >, & and ”).
>>> escape('"1 < 2"')
<Markup u'"1 < 2"'>
If the quotes parameter is set to False, the ” character is left as is. Escaping quotes is generally only required for strings that are to be used in attribute values.
>>> escape('"1 < 2"', quotes=False)
<Markup u'"1 < 2"'>
Parameters: |
|
---|---|
Returns: | the escaped Markup string |
Return type: | Markup |
Reverse-escapes &, <, >, and ” and returns a unicode object.
>>> unescape(Markup('1 < 2'))
u'1 < 2'
If the provided text object is not a Markup instance, it is returned unchanged.
>>> unescape('1 < 2')
'1 < 2'
Parameters: | text – the text to unescape |
---|---|
Returns: | the unescsaped string |
Return type: | unicode |
Identify and protect forms from CSRF attacks.
This filter works by adding a input type=hidden field to POST forms.
A Genshi stream filter for expanding genshi.Markup events.
Note: Expansion may not be possible if the fragment is badly formed, or partial.
Return the first element in the fragment having the given attribute, class or tag, using a preorder depth-first search.