Index: /trunk/ChangeLog
===================================================================
--- /trunk/ChangeLog	(revision 502)
+++ /trunk/ChangeLog	(revision 503)
@@ -10,5 +10,6 @@
    * Support for parentdir. Can be used to avoid sections for each project
      or if all projects have a common parent directory, you can leave out
-     the project drectory setting for each project. 
+     the project drectory setting for each project, eg:
+      * parentdir: /data/trac/oss/projects
 
      If an section defines a project directory then this can NOT be overriden 
@@ -44,7 +45,7 @@
    * Fixed some bugs in function update_ticket_fields:
        - Can not clear values, repoterd by thomas dot moschny add gmx dot de
-	     closes #228
+     closes #228
        - Values were updated regardless if there are not allowed for the ticket
-	     field.
+     field.
      Author: Bas van der Vlies
 
@@ -60,4 +61,7 @@
    * Added html conversion via external commmand: eg email2trac.conf
       - html2text_cmd: /usr/bin/html2text -nobs
+      - html2text_cmd: /usr/bin/w3m -dump
+      - html2text_cmd: /usr/bin/lynx -dump
+      - html2text_cmd: /usr/bin/links -dump
      closes #218
      Author: Bas van der Vlies
@@ -75,18 +79,18 @@
      also honour the permission model if set, closes #198
      an example how to use it:
-	email2trac.conf:
+    email2trac.conf:
         	[project]
-		workflow_closed: reopen
-		workflow_infoneeded: provideinfo
-
-	trac.ini:
-		[ticket-workflow]
-		reopen = closed -> reopened 
-		reopen.permissions = TICKET_CREATE 
-		reopen.operations = del_resolution 
-		
-		provideinfo = infoneeded -> moreinfo
-		provideinfo.permissions = TICKET_CREATE
-		provideinfo.name = info provided
+            workflow_closed: reopen
+            xworkflow_infoneeded: provideinfo
+
+    trac.ini:
+    [ticket-workflow]
+    reopen = closed -> reopened 
+    reopen.permissions = TICKET_CREATE 
+    reopen.operations = del_resolution 
+
+    provideinfo = infoneeded -> moreinfo
+    provideinfo.permissions = TICKET_CREATE
+    provideinfo.name = info provided
 
      Authors: kroseneg add schmidham dot net and Bas van der Vlies
Index: /trunk/email2trac.py.in
===================================================================
--- /trunk/email2trac.py.in	(revision 502)
+++ /trunk/email2trac.py.in	(revision 503)
@@ -585,4 +585,52 @@
 			self.logger.debug(util.text.unicode_quote(s))
 
+
+	def html_2_txt(self, data):
+		"""
+		Various routines to convert html syntax to valid trac wiki syntax
+		""" 
+		self.logger.debug('function html_2_txt')
+
+		## This routine make an safe html that can be include
+		#  in trac, but no further text processing can be done
+		#
+#		try:
+#			from lxml.html.clean import Cleaner
+#			tags_rm = list()
+#			tags_rm.append('body')
+#
+#			cleaner = Cleaner(remove_tags=tags_rm )
+#			parsed_data = cleaner.clean_html(data)
+#			parsed_data = '\n{{{\n#!html\n' + parsed_data + '\n}}}\n'
+#
+#			return parsed_data
+#			
+#		except ImportError::
+#			pass
+
+		parsed_data = None
+		if self.parameters.html2text_cmd: 
+			tmp_file = tempfile.mktemp('email2trac.html')
+			cmd = '%s %s' %(self.parameters.html2text_cmd, tmp_file) 
+			self.logger.debug('\t html2text conversion %s'%(cmd)) 
+	
+			if self.parameters.dry_run:
+				print 'DRY_RUN: html2text conversion command: %s\n' %(cmd)
+
+			else: 
+				f = open(tmp_file, "w+")
+				f.write(data)
+				f.close()
+
+				lines = os.popen(cmd).readlines()
+				parsed_data =  ''.join(lines)
+
+				os.unlink(tmp_file)
+
+		else:
+			self.logger.debug('\t No html2text conversion tool specified in email2trac.conf') 
+
+		return parsed_data
+
 ########## TRAC ticket functions  ###########################################################
 
@@ -1833,24 +1881,6 @@
 			if content_type == 'text/html':
 
-				if self.parameters.html2text_cmd:
-
-					tmp_file = tempfile.mktemp('.email2trac')
-					cmd = '%s %s' %(self.parameters.html2text_cmd, tmp_file) 
-					self.logger.debug('\t html2text conversion %s'%(cmd)) 
-					
-					if self.parameters.dry_run:
-						print 'DRY_RUN: html2text conversion command: %s\n' %(cmd)
-					else:
-						f = open(tmp_file, "w+")
-						f.write(body_text)
-						f.close()
-
-						lines = os.popen(cmd).readlines()
-						body_text = ''.join(lines)
-
-						os.unlink(tmp_file)
-
-				else:
-					self.logger.debug('\t No html2text conversion tool specified in email2trac.conf') 
+				body_text = self.html_2_txt(body_text)
+				if not body_text:
 					continue
 
