# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - MiniPage Macro

    PURPOSE:
        This macro is used to get the possibility to write inside a wiki table normal wiki code.
	This code is parsed by the wiki parser and is then displayed.

    CALLING SEQUENCE:
        [[MiniPage(wikicode)]]

    INPUTS:
        wikicode: e.g. * item1
    EXAMPLE:
       ||Buttons ||[[MiniPage( * Redo\n * Undo)]][[MiniPage( * Quit)]]||
       ||Section ||[[MiniPage(= heading 1 =)]][[MiniPage(== heading 2 ==)]]||

    PROCEDURE:
       The \n mark is used for a line break.

       Please remove the Version number from the code!

    MODIFICATION HISTORY:
        Version 1.3.3.-1
        Version 1.3.3.-2 Updated for Moin1.6
        Version 1.6.0.-3 refactored
        @copyright: 2005-2007 by Reimar Bauer (R.Bauer@fz-juelich.de)
        @license: GNU GPL, see COPYING for details.

"""
from MoinMoin import wikiutil
import string

def execute(macro, text):
     request = macro.request
     text = ''.join(text)
     # XXX FIXME line break correctly used here or just a workaround?
     text = string.replace(text, '\\n', '\n \n')
     Parser = wikiutil.getParser(request, text)
     # XXX FIXME parser injects unwanted opening (closing missing!)
     # of paragraph <p class="line862">
     return wikiutil.renderText(request, Parser, text, line_anchors=False).replace('<p class="line862">', '')

