#-*- coding: utf-8 -*-
""" 
SortText to sort one level of input
===================================

This parser is used to sort text lines
    

Install
-------

remove the version number 
Put it in your wiki/data/plugin/parser/


Example
-------

{{{
#!SortText
 * B
 * A
 * D
 * C
}}}
 

Result::

 * A
 * B
 * C
 * D
    
Compatibility
--------------
Tested with release 1.3.5, should work with any 1.3 release.


Legal
-----
@copyright © 2005 ReimarBauer <R.Bauer@fz-juelich.de>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
"""



Dependencies = []
import string
from MoinMoin.parser import wiki
class Parser:
        
   def __init__(self, raw, request, **kw):
        self.raw = raw
        self.request = request
        self.form = request.form
        self._ = request.getText
        
        
   def format(self, formatter):
       
        Dict = {}
        raw = self.raw.split('\n')
        raw.sort()
        
        wikiizer = wiki.Parser(string.join(raw,"\n"),self.request) 
        wikiizer.format(formatter)
        
        
