I haven't tried any development with Trac for a couple of years, and
even then, to be honest, I was pretty confused....
I would like to take a table in trac wiki markup, and make it
sortable, ala Ticket #8949 and the Trac ProcessorBazaar sortedtable
processor.
So I install the plugin, and it doesn't work, because it's a 0.8
plugin in a 0.11 world and it needs to be rewritten to use the 0.11
interface.
I understand how the 0.8 plugin works. It works on strings. It
searches for table and basically adds class=sortable to it.
I understand how the 0.11 plugin for LegendBox works. It works on
genshi Markup objects and genshi tag objects and trac wiki.formatter
objects.
What I don't understand is how in the 0.11 trac and genshi world, how
I get the html string, and/or manipulate the various markup and tag
objects to do that search for table and addition of the class=sortable
attribute.
(The script header to add the sorttable.js javascript is added via the
AddHeaders plug in)
The code would basically look like this (with thanks and apologies to
Stefan Schwarzer and Christian Boos)
def make_table_sortable(html):
"""
Takes a string of html code.
Return the string of HTML code for the table where the table tag
contains
the "sortable" CSS class. The argument "html" is the HTML code as
received from "WikiFormatter.wiki_to_html".
. . .
replacement = '<table class="sortable" id="%s">' % id
return html.replace('<table>', replacement)
class Sortedtable(WikiMacroBase):
"""Processor to make a table sortable"""
def expand_macro(self, formatter, name, args)
html = format_to_html(self.env, formatter.context, content)
# add the sortable class to the table tag
html = make_table_sortable(html)
return html
I don't think this will work, because format_to_html seems to return
genshi.core.Markup object, and I don't know how to get the string out
of that.
And I also don't think this code will work, because it seems that the
processor needs to return not a string, but a genshi xml object, and I
don't know how to do that.
So...
Can someone clue me in a bit on how the genshi should work, what a
trac processor should return, or what I should be doing instead?
Thanks,
Jerry
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en.