[Moin-user] TableOfContents suggestion

Nir Soffer nirs at freeshell.org
Fri Dec 16 03:09:02 EST 2005


On 16 Dec, 2005, at 6:39, Michael Matthews wrote:

>         attr =  
> self.macro.formatter.langAttr(self.macro.request.content_lang)
>          attr['id'] = 'table-of-contents'
>          self.result.append(self.macro.formatter.open('div',  
> newline=1, attr=attr))
>          
> self.process_lines(self.pre_re.sub('',self.macro.parser.raw).split('\n' 
> ),
>                             self.macro.formatter.page.page_name)
>          # Close pending lists
>          for i in range(self.baseindent, self.indent):
>              self.result.append(self.macro.formatter.listitem(0))
>              self.result.append(self.macro.formatter.number_list(0))
>         self.result.append(self.macro.formatter.close('div'))
>

Dont do that! formatter.open and close are private formatter methods,  
and are not part of the formatter public interface, which is all  
methods in formatter/base.py. Using these methods will break with  
AttributeError when using different formatter.

Since there is way to create div currently, you have to do something  
like this:

	formatter.rawHTML('<div id="foo">')
	...
	formatter.rawHTML('</div>')

Non html formatters will ignore raw HTML calls.


Best Regards,

Nir Soffer





More information about the Moin-user mailing list