trac.wiki.formatter¶
-
trac.wiki.formatter.wiki_to_outline(wikitext, env, db=None, absurls=False, max_depth=None, min_depth=None, req=None)¶ Deprecated: will be removed in 1.0 and replaced by something else
-
class
trac.wiki.formatter.Formatter(env, context)¶ Bases:
objectBase Wiki formatter.
Parses and formats wiki text, in a given
RenderingContext.-
close_tag(open_tag, close_tag=None)¶ Open a inline style tag.
If
close_tagis not specified, it’s an indirect tag (0.12)
-
open_tag(tag_open, tag_close=None)¶ Open an inline style tag.
If
tag_closeis not specified,tag_openis an indirect tag (0.12)
-
replace(fullmatch)¶ Replace one match with its corresponding expansion
-
simple_tag_handler(match, open_tag, close_tag)¶ Generic handler for simple binary style tags
-
tag_open_p(tag)¶ Do we currently have any open tag with
tagas end-tag?
-
-
trac.wiki.formatter.split_url_into_path_query_fragment(target)¶ Split a target along
?and#in(path, query, fragment).>>> split_url_into_path_query_fragment('http://path?a=1&b=2#frag?ment') ('http://path', '?a=1&b=2', '#frag?ment') >>> split_url_into_path_query_fragment('http://path#frag?ment') ('http://path', '', '#frag?ment') >>> split_url_into_path_query_fragment('http://path?a=1&b=2') ('http://path', '?a=1&b=2', '') >>> split_url_into_path_query_fragment('http://path') ('http://path', '', '')
-
trac.wiki.formatter.concat_path_query_fragment(path, query, fragment=None)¶ Assemble
path,queryandfragmentinto a proper URL.Can be used to re-assemble an URL decomposed using
split_url_into_path_query_fragmentafter modification.>>> concat_path_query_fragment('/wiki/page', '?version=1') '/wiki/page?version=1' >>> concat_path_query_fragment('/wiki/page#a', '?version=1', '#b') '/wiki/page?version=1#b' >>> concat_path_query_fragment('/wiki/page?version=1#a', '?format=txt') '/wiki/page?version=1&format=txt#a' >>> concat_path_query_fragment('/wiki/page?version=1', '&format=txt') '/wiki/page?version=1&format=txt' >>> concat_path_query_fragment('/wiki/page?version=1', 'format=txt') '/wiki/page?version=1&format=txt' >>> concat_path_query_fragment('/wiki/page?version=1#a', '?format=txt', '#') '/wiki/page?version=1&format=txt'
Components¶
-
class
trac.wiki.formatter.HtmlFormatter(env, context, wikidom)¶ Bases:
objectFormat parsed wiki text to HTML
-
generate(escape_newlines=False)¶ Generate HTML elements.
newlines in the wikidom will be preserved if
escape_newlinesis set.
-
-
class
trac.wiki.formatter.InlineHtmlFormatter(env, context, wikidom)¶ Bases:
objectFormat parsed wiki text to inline elements HTML.
Block level content will be discarded or compacted.
-
generate(shorten=False)¶ Generate HTML inline elements.
If
shortenis set, the generation will stop once enough characters have been emitted.
-
-
class
trac.wiki.formatter.LinkFormatter(env, context)¶ Bases:
trac.wiki.formatter.OutlineFormatterSpecial formatter that focuses on TracLinks.
-
match(wikitext)¶ Return the Wiki match found at the beginning of the
wikitext
-
-
class
trac.wiki.formatter.OneLinerFormatter(env, context)¶ Bases:
trac.wiki.formatter.FormatterA special version of the wiki formatter that only implement a subset of the wiki formatting functions. This version is useful for rendering short wiki-formatted messages on a single line
-
class
trac.wiki.formatter.OutlineFormatter(env, context)¶ Bases:
trac.wiki.formatter.FormatterSpecial formatter that generates an outline of all the headings.