Hi

The attached patch adds txt2tags support to txt2tags!
Think of it as a nice way to resolve PreProc's and includes for
further distribution without losing the flexibility of the t2t format.
There is much room for improvement, but the basic support is already
there - sample.t2t was correctly rendered. Table alignment and
enconding are the main things still missing, in my opinion.

The patch is against SVN head.

Cheers
Leandro Penz
PS: Last email had no attachment.
diff --git a/txt2tags b/txt2tags
index d190bba..c0218d2 100755
--- a/txt2tags
+++ b/txt2tags
@@ -139,7 +139,7 @@ else:
 # first file and gui for the second. There is no --no-<action>.
 # --version and --help inside %!options are also odd
 #
-TARGETS  = 'html xhtml sgml dbk tex lout man mgp wiki gwiki doku pmw moin pm6 txt art adoc'.split()
+TARGETS  = 'html xhtml sgml dbk tex lout man mgp wiki gwiki doku pmw moin pm6 txt art adoc t2t'.split()
 
 FLAGS    = {'headers'    :1 , 'enum-title' :0 , 'mask-email' :0 ,
             'toc-only'   :0 , 'toc'        :0 , 'rc'         :1 ,
@@ -179,6 +179,7 @@ TARGET_NAMES = {
   'txt'  : _('Plain Text'),
   'art'  : _('Ascii Art'),
   'adoc' : _('AsciiDoc'),
+  't2t'  : _('txt2tags'),
 }
 
 DEBUG = 0     # do not edit here, please use --debug
@@ -525,6 +526,13 @@ r"""\documentclass{article}
 @Display @I { %(HEADER2)s }
 @Display { %(HEADER3)s }
 #...@np                               # Break page after Headers
+""",
+
+	't2t': """\
+%(HEADER1)s
+%(HEADER2)s
+%(HEADER3)s
+
 """
 # @SysInclude { tbl }                   # Tables support
 # setup: @MakeContents { Yes }          # show TOC
@@ -1341,6 +1349,41 @@ def getTags(config):
 		'email'                 : '\a'            ,
 		'emailMark'             : '\a \a'         ,
 		'img'                   : '\a'
+	},
+
+	't2t': {
+		'title1'               : '= \a =~A~' ,
+		'title2'               : '== \a ==~A~' ,
+		'title3'               : '=== \a ===~A~' ,
+		'title4'               : '==== \a ====~A~' ,
+		'title5'               : '===== \a =====~A~',
+		'anchor'               : '[\a]',
+		'blockVerbOpen'        : '```',
+		'blockVerbClose'       : '```',
+		'fontMonoOpen'         : '``',
+		'fontMonoClose'        : '``',
+		'fontBoldOpen'         : "**",
+		'fontBoldClose'        : "**",
+		'fontItalicOpen'       : '//',
+		'fontItalicClose'      : '//',
+		'fontUnderlineOpen'    : '__',
+		'fontUnderlineClose'   : '__',
+		'fontStrikeOpen'       : '--',
+		'fontStrikeClose'      : '--',
+		'listItemOpen'         : '-',
+		'numlistItemOpen'      : '+',
+		'deflistItem1Open'     : ':',
+		'bar1'                 : '--------------------\n',
+		'bar2'                 : '====================\n',
+		'email'                : '\a',
+		'url'                   : '\a',
+		'urlMark'               : '[\a \a]',
+		'img'                   : '[\a]',
+		'tableTitleRowOpen'     : '|| ',
+		'tableRowOpen'          : '| ',
+		'tableCellSep'          : ' | ',
+		'tableRowClose'          : ' |',
+		'comment'              : '% \a',
 	}
 	}
 	
@@ -1434,6 +1477,7 @@ def getRules(config):
 		'tagnotindentable',     # tags must be placed at the line begining
 		'spacedlistitemopen',   # append a space after the list item open tag
 		'spacednumlistitemopen',# append a space after the numlist item open tag
+		'spaceddeflistitemopen',# append a space after the deflist item open tag
 		'deflisttextstrip',     # strip the contents of the deflist text
 		'blanksaroundpara',     # put a blank line before and after paragraphs
 		'blanksaroundverb',     # put a blank line before and after verb blocks
@@ -1794,6 +1838,24 @@ def getRules(config):
 			# 'blanksaroundbar':1,
 			'blanksaroundtitle':1,
 			'blanksaroundnumtitle':1,
+		},
+		't2t': {
+			'linkable':1,
+			'tableable':1,
+			'labelbeforelink':1,
+			'blanksaroundpara':1,
+			'blanksaroundtable':1,
+			'tablecellspannable':1,
+			'tablecellmulticol':1,
+			'keepquoteindent':1,
+			'keeplistindent':1,
+			'spacedlistitemopen':1,
+			'blanksaroundlist':1,
+			'blanksaroundnumlist':1,
+			'spacednumlistitemopen':1,
+			'spaceddeflistitemopen':1,
+			'tablecellspannable':1,
+			'tablecellmulticol':1,
 		}
 	}
 	
@@ -3818,6 +3880,7 @@ class BlockMaster:
 		
 		# Adds trailing space on opening tags
 		if (name == 'list'    and rules['spacedlistitemopen']) or \
+		   (name == 'deflist' and rules['spaceddeflistitemopen']) or \
 		   (name == 'numlist' and rules['spacednumlistitemopen']):
 			itemopen = itemopen + ' '
 			
@@ -3900,6 +3963,10 @@ class BlockMaster:
 		# Blank line after?
 		if self._should_add_blank_line('after', name): result.append('')
 
+		# Hack to provide the extra blank line after upper list ends.
+		if TARGET == 't2t' and self.depth == 1:
+			result.append('\n')
+
 		return result
 
 
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
txt2tags-list mailing list
https://lists.sourceforge.net/lists/listinfo/txt2tags-list

Reply via email to