"""

    TextOnRight is a MoinMoin 1.1 Processor that creates a simple table
    with a picture on the left and text on the right.

    At Geary Central (http://www.geary.com), I often use a bit of page
    layout that looks like this:

    +-------+
    | photo |   Text on the right.
    | photo |   More text.
    | photo |
    | photo |   And more.
    +-------+

    This can be coded with standard MoinMoin tables, but it is fairly
    painful. This example has a line break added--the actual text has
    to be all on one line:

    ||<tableborder=0 valign=top>http://www.example.com/photo.jpg||<width=8>
    ||<valign=top>Text on the right.[[BR]]More text.[[BR]][[BR]]And more.||

    The TextOnRight processor provides a much cleaner way to code this layout:

    {{{#!TextOnRight
    http://www.sample.com/photo.jpg
    Text on the right.
    More text.
    
    And more.
    }}}

    At the moment, this macro has no parameters, no complications.
    Life is simple.

    Public domain code by Michael Geary
    mailto:Mike@Geary.com
    http://www.geary.com
"""

from MoinMoin.parser import wiki

def process( request, formatter, lines ):

    last = len(lines) - 1
    if last < 2:
        output = 'ERROR: The TextOnRight macro requires at least two lines.'

    else:
        output = '||<tableborder=0 valign=top>' + lines[1] + '||<width=8> ||<valign=top>'

        for r in range( 2, last ):
            output += lines[r] + '[[BR]]'
    
        output += lines[last] + '||\n'

    wikiizer = wiki.Parser( output, request )
    wikiizer.format( formatter )

