Hello,
> > Could it be that the string resulting from a proc rule isn't split?
> Definitely there is a problem here.
> [...]
> I have filled a report on the tracker:
> http://code.google.com/p/txt2tags/issues/detail?id=25
>
> Please feel free to add and comment on it,
>
There isn't much to add to your report...
Here is a quick and dirty (??) patch. No promise, but it seems to works
for me and it doesn't seem to break anything.*
If anyone cares to test it on other platforms, it'd be great...
*: well, 38 tests from the test suite fail, but this is exactly like the
official svn version of txt2tags. I haven't looked more into it...
Is that important?
One slight problem is that the line numbers in Debug messages (line 4753
in svn, or line 4757 in patched version) correspond to the line number
of the original file. This is probably the best solution, but it might
look strange.
Trick question for the developers: is line 4740 (svn version) really
useful?
line = re.sub('[\n\r]+$','',untouchedline) # del line break
I kept it in the patch, but I don't see why we could need it...
Pierre
--
All generalizations are false, including this one.
-- Mark Twain
diff -rupN txt2tags-read-only/txt2tags txt2tags-work/txt2tags
--- txt2tags-read-only/txt2tags 2010-02-16 17:55:11.000000000 +0100
+++ txt2tags-work/txt2tags 2010-02-16 18:53:27.000000000 +0100
@@ -4738,458 +4738,464 @@ def convert(bodylines, config, firstline
dump_source.append(untouchedline)
line = re.sub('[\n\r]+$','',untouchedline) # del line break
+ lines = line.split(LB)
# Apply PreProc filters
if pre_filter:
errmsg = _('Invalid PreProc filter replacement')
for rgx,repl in pre_filter:
- try: line = rgx.sub(repl, line)
+ try:
+ lines_aux = map(lambda l: rgx.sub(repl, l), lines)
+ lines = []
+ for line in lines_aux:
+ lines.extend(line.split(LB))
except: Error("%s: '%s'"%(errmsg, repl))
- line = maskEscapeChar(line) # protect \ char
linenr += 1
lineref += 1
- Debug(repr(line), 2, linenr) # heavy debug: show each line
-
- #------------------[ Comment Block ]------------------------
-
- # We're already on a comment block
- if BLOCK.block() == 'comment':
-
- # Closing comment
- if regex['blockCommentClose'].search(line):
- ret.extend(BLOCK.blockout() or [])
+ for line_aux in lines:
+ line = maskEscapeChar(line_aux) # protect \ char
+ Debug(repr(line), 2, linenr) # heavy debug: show each line
+
+ #------------------[ Comment Block ]------------------------
+
+ # We're already on a comment block
+ if BLOCK.block() == 'comment':
+
+ # Closing comment
+ if regex['blockCommentClose'].search(line):
+ ret.extend(BLOCK.blockout() or [])
+ continue
+
+ # Normal comment-inside line. Ignore it.
continue
- # Normal comment-inside line. Ignore it.
- continue
-
- # Detecting comment block init
- if regex['blockCommentOpen'].search(line) \
- and BLOCK.block() not in BLOCK.exclusive:
- ret.extend(BLOCK.blockin('comment'))
- continue
+ # Detecting comment block init
+ if regex['blockCommentOpen'].search(line) \
+ and BLOCK.block() not in BLOCK.exclusive:
+ ret.extend(BLOCK.blockin('comment'))
+ continue
- #-------------------------[ Tagged Text ]----------------------
+ #-------------------------[ Tagged Text ]----------------------
- # We're already on a tagged block
- if BLOCK.block() == 'tagged':
-
- # Closing tagged
- if regex['blockTaggedClose'].search(line):
- ret.extend(BLOCK.blockout())
- continue
+ # We're already on a tagged block
+ if BLOCK.block() == 'tagged':
- # Normal tagged-inside line
- BLOCK.holdadd(line)
- continue
-
- # Detecting tagged block init
- if regex['blockTaggedOpen'].search(line) \
- and BLOCK.block() not in BLOCK.exclusive:
- ret.extend(BLOCK.blockin('tagged'))
- continue
-
- # One line tagged text
- if regex['1lineTagged'].search(line) \
- and BLOCK.block() not in BLOCK.exclusive:
- ret.extend(BLOCK.blockin('tagged'))
- line = regex['1lineTagged'].sub('',line)
- BLOCK.holdadd(line)
- ret.extend(BLOCK.blockout())
- continue
-
- #-------------------------[ Raw Text ]----------------------
-
- # We're already on a raw block
- if BLOCK.block() == 'raw':
-
- # Closing raw
- if regex['blockRawClose'].search(line):
- ret.extend(BLOCK.blockout())
+ # Closing tagged
+ if regex['blockTaggedClose'].search(line):
+ ret.extend(BLOCK.blockout())
+ continue
+
+ # Normal tagged-inside line
+ BLOCK.holdadd(line)
continue
- # Normal raw-inside line
- BLOCK.holdadd(line)
- continue
-
- # Detecting raw block init
- if regex['blockRawOpen'].search(line) \
- and BLOCK.block() not in BLOCK.exclusive:
- ret.extend(BLOCK.blockin('raw'))
- continue
-
- # One line raw text
- if regex['1lineRaw'].search(line) \
- and BLOCK.block() not in BLOCK.exclusive:
- ret.extend(BLOCK.blockin('raw'))
- line = regex['1lineRaw'].sub('',line)
- BLOCK.holdadd(line)
- ret.extend(BLOCK.blockout())
- continue
-
- #------------------------[ Verbatim ]----------------------
-
- #TIP We'll never support beautifiers inside verbatim
-
- # Closing table mapped to verb
- if BLOCK.block() == 'verb' \
- and BLOCK.prop('mapped') == 'table' \
- and not regex['table'].search(line):
- ret.extend(BLOCK.blockout())
-
- # We're already on a verb block
- if BLOCK.block() == 'verb':
+ # Detecting tagged block init
+ if regex['blockTaggedOpen'].search(line) \
+ and BLOCK.block() not in BLOCK.exclusive:
+ ret.extend(BLOCK.blockin('tagged'))
+ continue
- # Closing verb
- if regex['blockVerbClose'].search(line):
+ # One line tagged text
+ if regex['1lineTagged'].search(line) \
+ and BLOCK.block() not in BLOCK.exclusive:
+ ret.extend(BLOCK.blockin('tagged'))
+ line = regex['1lineTagged'].sub('',line)
+ BLOCK.holdadd(line)
ret.extend(BLOCK.blockout())
continue
- # Normal verb-inside line
- BLOCK.holdadd(line)
- continue
-
- # Detecting verb block init
- if regex['blockVerbOpen'].search(line) \
- and BLOCK.block() not in BLOCK.exclusive:
- ret.extend(BLOCK.blockin('verb'))
- f_lastwasblank = 0
- continue
-
- # One line verb-formatted text
- if regex['1lineVerb'].search(line) \
- and BLOCK.block() not in BLOCK.exclusive:
- ret.extend(BLOCK.blockin('verb'))
- line = regex['1lineVerb'].sub('',line)
- BLOCK.holdadd(line)
- ret.extend(BLOCK.blockout())
- f_lastwasblank = 0
- continue
-
- # Tables are mapped to verb when target is not table-aware
- if not rules['tableable'] and regex['table'].search(line):
- if not BLOCK.isblock('verb'):
- ret.extend(BLOCK.blockin('verb'))
- BLOCK.propset('mapped', 'table')
+ #-------------------------[ Raw Text ]----------------------
+
+ # We're already on a raw block
+ if BLOCK.block() == 'raw':
+
+ # Closing raw
+ if regex['blockRawClose'].search(line):
+ ret.extend(BLOCK.blockout())
+ continue
+
+ # Normal raw-inside line
BLOCK.holdadd(line)
continue
-
- #---------------------[ blank lines ]-----------------------
-
- if regex['blankline'].search(line):
- # Close open paragraph
- if BLOCK.isblock('para'):
- ret.extend(BLOCK.blockout())
- f_lastwasblank = 1
+ # Detecting raw block init
+ if regex['blockRawOpen'].search(line) \
+ and BLOCK.block() not in BLOCK.exclusive:
+ ret.extend(BLOCK.blockin('raw'))
continue
- # Close all open tables
- if BLOCK.isblock('table'):
+ # One line raw text
+ if regex['1lineRaw'].search(line) \
+ and BLOCK.block() not in BLOCK.exclusive:
+ ret.extend(BLOCK.blockin('raw'))
+ line = regex['1lineRaw'].sub('',line)
+ BLOCK.holdadd(line)
ret.extend(BLOCK.blockout())
- f_lastwasblank = 1
continue
- # Close all open quotes
- while BLOCK.isblock('quote'):
+ #------------------------[ Verbatim ]----------------------
+
+ #TIP We'll never support beautifiers inside verbatim
+
+ # Closing table mapped to verb
+ if BLOCK.block() == 'verb' \
+ and BLOCK.prop('mapped') == 'table' \
+ and not regex['table'].search(line):
ret.extend(BLOCK.blockout())
- # Closing all open lists
- if f_lastwasblank: # 2nd consecutive blank
- if BLOCK.block().endswith('list'):
- BLOCK.holdaddsub('') # helps parser
- while BLOCK.depth: # closes list (if any)
+ # We're already on a verb block
+ if BLOCK.block() == 'verb':
+
+ # Closing verb
+ if regex['blockVerbClose'].search(line):
ret.extend(BLOCK.blockout())
- continue # ignore consecutive blanks
+ continue
+
+ # Normal verb-inside line
+ BLOCK.holdadd(line)
+ continue
- # Paragraph (if any) is wanted inside lists also
- if BLOCK.block().endswith('list'):
- BLOCK.holdaddsub('')
+ # Detecting verb block init
+ if regex['blockVerbOpen'].search(line) \
+ and BLOCK.block() not in BLOCK.exclusive:
+ ret.extend(BLOCK.blockin('verb'))
+ f_lastwasblank = 0
+ continue
- f_lastwasblank = 1
- continue
-
-
- #---------------------[ special ]---------------------------
-
- if regex['special'].search(line):
- # Include command
- targ, key, val = ConfigLines().parse_line(line, 'include', target)
- if key:
- Debug("Found config '%s', value '%s'" % (key, val), 1, linenr)
-
- incpath = os.path.dirname(CONF['sourcefile'])
- incfile = val
- err = _('A file cannot include itself (loop!)')
- if CONF['sourcefile'] == incfile:
- Error("%s: %s"%(err,incfile))
- inctype, inclines = get_include_contents(incfile, incpath)
- # Verb, raw and tagged are easy
- if inctype != 't2t':
- ret.extend(BLOCK.blockin(inctype))
- BLOCK.holdextend(inclines)
+ # One line verb-formatted text
+ if regex['1lineVerb'].search(line) \
+ and BLOCK.block() not in BLOCK.exclusive:
+ ret.extend(BLOCK.blockin('verb'))
+ line = regex['1lineVerb'].sub('',line)
+ BLOCK.holdadd(line)
+ ret.extend(BLOCK.blockout())
+ f_lastwasblank = 0
+ continue
+
+ # Tables are mapped to verb when target is not table-aware
+ if not rules['tableable'] and regex['table'].search(line):
+ if not BLOCK.isblock('verb'):
+ ret.extend(BLOCK.blockin('verb'))
+ BLOCK.propset('mapped', 'table')
+ BLOCK.holdadd(line)
+ continue
+
+ #---------------------[ blank lines ]-----------------------
+
+ if regex['blankline'].search(line):
+
+ # Close open paragraph
+ if BLOCK.isblock('para'):
+ ret.extend(BLOCK.blockout())
+ f_lastwasblank = 1
+ continue
+
+ # Close all open tables
+ if BLOCK.isblock('table'):
+ ret.extend(BLOCK.blockout())
+ f_lastwasblank = 1
+ continue
+
+ # Close all open quotes
+ while BLOCK.isblock('quote'):
ret.extend(BLOCK.blockout())
+
+ # Closing all open lists
+ if f_lastwasblank: # 2nd consecutive blank
+ if BLOCK.block().endswith('list'):
+ BLOCK.holdaddsub('') # helps parser
+ while BLOCK.depth: # closes list (if any)
+ ret.extend(BLOCK.blockout())
+ continue # ignore consecutive blanks
+
+ # Paragraph (if any) is wanted inside lists also
+ if BLOCK.block().endswith('list'):
+ BLOCK.holdaddsub('')
+
+ f_lastwasblank = 1
+ continue
+
+
+ #---------------------[ special ]---------------------------
+
+ if regex['special'].search(line):
+ # Include command
+ targ, key, val = ConfigLines().parse_line(line, 'include', target)
+ if key:
+ Debug("Found config '%s', value '%s'" % (key, val), 1, linenr)
+
+ incpath = os.path.dirname(CONF['sourcefile'])
+ incfile = val
+ err = _('A file cannot include itself (loop!)')
+ if CONF['sourcefile'] == incfile:
+ Error("%s: %s"%(err,incfile))
+ inctype, inclines = get_include_contents(incfile, incpath)
+ # Verb, raw and tagged are easy
+ if inctype != 't2t':
+ ret.extend(BLOCK.blockin(inctype))
+ BLOCK.holdextend(inclines)
+ ret.extend(BLOCK.blockout())
+ else:
+ # Insert include lines into body
+ #TODO include maxdepth limit
+ bodylines = bodylines[:lineref] + inclines + bodylines[lineref:]
+ #TODO fix path if incl...@include
+ # Remove %!include call
+ if CONF['dump-source']:
+ dump_source.pop()
+ continue
else:
- # Insert include lines into body
- #TODO include maxdepth limit
- bodylines = bodylines[:lineref] + inclines + bodylines[lineref:]
- #TODO fix path if incl...@include
- # Remove %!include call
- if CONF['dump-source']:
- dump_source.pop()
+ Debug('Bogus Special Line',1,linenr)
+
+ #---------------------[ dump-source ]-----------------------
+
+ # We don't need to go any further
+ if CONF['dump-source']:
continue
- else:
- Debug('Bogus Special Line',1,linenr)
-
- #---------------------[ dump-source ]-----------------------
-
- # We don't need to go any further
- if CONF['dump-source']:
- continue
-
- #---------------------[ Comments ]--------------------------
-
- # Just skip them (if not macro)
- if regex['comment'].search(line) and not \
- regex['macros'].match(line) and not \
- regex['toc'].match(line):
- continue
-
- #---------------------[ Triggers ]--------------------------
-
- # Valid line, reset blank status
- f_lastwasblank = 0
-
- # Any NOT quote line closes all open quotes
- if BLOCK.isblock('quote') and not regex['quote'].search(line):
- while BLOCK.isblock('quote'):
+
+ #---------------------[ Comments ]--------------------------
+
+ # Just skip them (if not macro)
+ if regex['comment'].search(line) and not \
+ regex['macros'].match(line) and not \
+ regex['toc'].match(line):
+ continue
+
+ #---------------------[ Triggers ]--------------------------
+
+ # Valid line, reset blank status
+ f_lastwasblank = 0
+
+ # Any NOT quote line closes all open quotes
+ if BLOCK.isblock('quote') and not regex['quote'].search(line):
+ while BLOCK.isblock('quote'):
+ ret.extend(BLOCK.blockout())
+
+ # Any NOT table line closes an open table
+ if BLOCK.isblock('table') and not regex['table'].search(line):
ret.extend(BLOCK.blockout())
-
- # Any NOT table line closes an open table
- if BLOCK.isblock('table') and not regex['table'].search(line):
- ret.extend(BLOCK.blockout())
-
-
- #---------------------[ Horizontal Bar ]--------------------
+
+
+ #---------------------[ Horizontal Bar ]--------------------
- if regex['bar'].search(line):
+ if regex['bar'].search(line):
- # Bars inside quotes are handled on the Quote processing
- # Otherwise we parse the bars right here
- #
- if not (BLOCK.isblock('quote') or regex['quote'].search(line)) \
- or (BLOCK.isblock('quote') and not rules['barinsidequote']):
+ # Bars inside quotes are handled on the Quote processing
+ # Otherwise we parse the bars right here
+ #
+ if not (BLOCK.isblock('quote') or regex['quote'].search(line)) \
+ or (BLOCK.isblock('quote') and not rules['barinsidequote']):
- # Close all the opened blocks
- ret.extend(BLOCK.blockin('bar'))
+ # Close all the opened blocks
+ ret.extend(BLOCK.blockin('bar'))
- # Extract the bar chars (- or =)
- m = regex['bar'].search(line)
- bar_chars = m.group(2)
+ # Extract the bar chars (- or =)
+ m = regex['bar'].search(line)
+ bar_chars = m.group(2)
- # Process and dump the tagged bar
- BLOCK.holdadd(bar_chars)
- ret.extend(BLOCK.blockout())
- Debug("BAR: %s"%line, 6)
-
- # We're done, nothing more to process
- continue
+ # Process and dump the tagged bar
+ BLOCK.holdadd(bar_chars)
+ ret.extend(BLOCK.blockout())
+ Debug("BAR: %s"%line, 6)
+ # We're done, nothing more to process
+ continue
- #---------------------[ Title ]-----------------------------
-
- if (regex['title'].search(line) or regex['numtitle'].search(line)) \
- and not BLOCK.block().endswith('list'):
- if regex['title'].search(line):
- name = 'title'
- else:
- name = 'numtitle'
-
- # Close all the opened blocks
- ret.extend(BLOCK.blockin(name))
-
- # Process title
- TITLE.add(line)
- ret.extend(BLOCK.blockout())
+ #---------------------[ Title ]-----------------------------
- # We're done, nothing more to process
- continue
-
- #---------------------[ %%toc ]-----------------------
-
- # %%toc line closes paragraph
- if BLOCK.block() == 'para' and regex['toc'].search(line):
- ret.extend(BLOCK.blockout())
-
- #---------------------[ apply masks ]-----------------------
-
- line = MASK.mask(line)
-
- #XXX from here, only block-inside lines will pass
-
- #---------------------[ Quote ]-----------------------------
-
- if regex['quote'].search(line):
+ if (regex['title'].search(line) or regex['numtitle'].search(line)) \
+ and not BLOCK.block().endswith('list'):
+
+ if regex['title'].search(line):
+ name = 'title'
+ else:
+ name = 'numtitle'
+
+ # Close all the opened blocks
+ ret.extend(BLOCK.blockin(name))
+
+ # Process title
+ TITLE.add(line)
+ ret.extend(BLOCK.blockout())
+
+ # We're done, nothing more to process
+ continue
- # Store number of leading TABS
- quotedepth = len(regex['quote'].search(line).group(0))
+ #---------------------[ %%toc ]-----------------------
- # SGML doesn't support nested quotes
- if rules['quotenotnested']: quotedepth = 1
+ # %%toc line closes paragraph
+ if BLOCK.block() == 'para' and regex['toc'].search(line):
+ ret.extend(BLOCK.blockout())
- # Don't cross depth limit
- maxdepth = rules['quotemaxdepth']
- if maxdepth and quotedepth > maxdepth:
- quotedepth = maxdepth
+ #---------------------[ apply masks ]-----------------------
- # New quote
- if not BLOCK.isblock('quote'):
- ret.extend(BLOCK.blockin('quote'))
+ line = MASK.mask(line)
- # New subquotes
- while BLOCK.depth < quotedepth:
- BLOCK.blockin('quote')
+ #XXX from here, only block-inside lines will pass
- # Closing quotes
- while quotedepth < BLOCK.depth:
- ret.extend(BLOCK.blockout())
+ #---------------------[ Quote ]-----------------------------
- # Bar inside quote
- if regex['bar'].search(line) and rules['barinsidequote']:
- tempBlock = BlockMaster()
- tagged_bar = []
- tagged_bar.extend(tempBlock.blockin('bar'))
- tempBlock.holdadd(line)
- tagged_bar.extend(tempBlock.blockout())
- BLOCK.holdextend(tagged_bar)
- continue
-
- #---------------------[ Lists ]-----------------------------
-
- # An empty item also closes the current list
- if BLOCK.block().endswith('list'):
- m = regex['listclose'].match(line)
- if m:
- listindent = m.group(1)
- listtype = m.group(2)
- currlisttype = BLOCK.prop('type')
- currlistindent = BLOCK.prop('indent')
- if listindent == currlistindent and \
- listtype == currlisttype:
+ if regex['quote'].search(line):
+
+ # Store number of leading TABS
+ quotedepth = len(regex['quote'].search(line).group(0))
+
+ # SGML doesn't support nested quotes
+ if rules['quotenotnested']: quotedepth = 1
+
+ # Don't cross depth limit
+ maxdepth = rules['quotemaxdepth']
+ if maxdepth and quotedepth > maxdepth:
+ quotedepth = maxdepth
+
+ # New quote
+ if not BLOCK.isblock('quote'):
+ ret.extend(BLOCK.blockin('quote'))
+
+ # New subquotes
+ while BLOCK.depth < quotedepth:
+ BLOCK.blockin('quote')
+
+ # Closing quotes
+ while quotedepth < BLOCK.depth:
ret.extend(BLOCK.blockout())
+
+ # Bar inside quote
+ if regex['bar'].search(line) and rules['barinsidequote']:
+ tempBlock = BlockMaster()
+ tagged_bar = []
+ tagged_bar.extend(tempBlock.blockin('bar'))
+ tempBlock.holdadd(line)
+ tagged_bar.extend(tempBlock.blockout())
+ BLOCK.holdextend(tagged_bar)
continue
-
- if regex['list'].search(line) or \
- regex['numlist'].search(line) or \
- regex['deflist'].search(line):
-
- listindent = BLOCK.prop('indent')
- listids = ''.join(LISTNAMES.keys())
- m = re.match('^( *)([%s]) '%listids, line)
- listitemindent = m.group(1)
- listtype = m.group(2)
- listname = LISTNAMES[listtype]
- results_box = BLOCK.holdadd
-
- # Del list ID (and separate term from definition)
- if listname == 'deflist':
- term = parse_deflist_term(line)
- line = regex['deflist'].sub(
- SEPARATOR+term+SEPARATOR,line)
- else:
- line = regex[listname].sub(SEPARATOR,line)
-
- # Don't cross depth limit
- maxdepth = rules['listmaxdepth']
- if maxdepth and BLOCK.depth == maxdepth:
- if len(listitemindent) > len(listindent):
- listitemindent = listindent
-
- # List bumping (same indent, diff mark)
- # Close the currently open list to clear the mess
- if BLOCK.block().endswith('list') \
- and listname != BLOCK.block() \
- and len(listitemindent) == len(listindent):
- ret.extend(BLOCK.blockout())
+
+ #---------------------[ Lists ]-----------------------------
+
+ # An empty item also closes the current list
+ if BLOCK.block().endswith('list'):
+ m = regex['listclose'].match(line)
+ if m:
+ listindent = m.group(1)
+ listtype = m.group(2)
+ currlisttype = BLOCK.prop('type')
+ currlistindent = BLOCK.prop('indent')
+ if listindent == currlistindent and \
+ listtype == currlisttype:
+ ret.extend(BLOCK.blockout())
+ continue
+
+ if regex['list'].search(line) or \
+ regex['numlist'].search(line) or \
+ regex['deflist'].search(line):
+
listindent = BLOCK.prop('indent')
+ listids = ''.join(LISTNAMES.keys())
+ m = re.match('^( *)([%s]) '%listids, line)
+ listitemindent = m.group(1)
+ listtype = m.group(2)
+ listname = LISTNAMES[listtype]
+ results_box = BLOCK.holdadd
+
+ # Del list ID (and separate term from definition)
+ if listname == 'deflist':
+ term = parse_deflist_term(line)
+ line = regex['deflist'].sub(
+ SEPARATOR+term+SEPARATOR,line)
+ else:
+ line = regex[listname].sub(SEPARATOR,line)
+
+ # Don't cross depth limit
+ maxdepth = rules['listmaxdepth']
+ if maxdepth and BLOCK.depth == maxdepth:
+ if len(listitemindent) > len(listindent):
+ listitemindent = listindent
+
+ # List bumping (same indent, diff mark)
+ # Close the currently open list to clear the mess
+ if BLOCK.block().endswith('list') \
+ and listname != BLOCK.block() \
+ and len(listitemindent) == len(listindent):
+ ret.extend(BLOCK.blockout())
+ listindent = BLOCK.prop('indent')
+
+ # Open mother list or sublist
+ if not BLOCK.block().endswith('list') or \
+ len(listitemindent) > len(listindent):
+ ret.extend(BLOCK.blockin(listname))
+ BLOCK.propset('indent',listitemindent)
+ BLOCK.propset('type',listtype)
+
+ # Closing sublists
+ while len(listitemindent) < len(BLOCK.prop('indent')):
+ ret.extend(BLOCK.blockout())
+
+ # O-oh, sublist before list ("\n\n - foo\n- foo")
+ # Fix: close sublist (as mother), open another list
+ if not BLOCK.block().endswith('list'):
+ ret.extend(BLOCK.blockin(listname))
+ BLOCK.propset('indent',listitemindent)
+ BLOCK.propset('type',listtype)
+
+ #---------------------[ Table ]-----------------------------
+
+ #TODO escape undesired format inside table
+ #TODO add pm6 target
+ if regex['table'].search(line):
+
+ if not BLOCK.isblock('table'): # first table line!
+ ret.extend(BLOCK.blockin('table'))
+ BLOCK.tableparser.__init__(line)
+
+ tablerow = TableMaster().parse_row(line)
+ BLOCK.tableparser.add_row(tablerow) # save config
+
+ # Maintain line to unmask and inlines
+ # XXX Bug: | **bo | ld** | turns **bo\x01ld** and gets converted :(
+ # TODO isolate unmask+inlines parsing to use here
+ line = SEPARATOR.join(tablerow['cells'])
- # Open mother list or sublist
- if not BLOCK.block().endswith('list') or \
- len(listitemindent) > len(listindent):
- ret.extend(BLOCK.blockin(listname))
- BLOCK.propset('indent',listitemindent)
- BLOCK.propset('type',listtype)
+ #---------------------[ Paragraph ]-------------------------
- # Closing sublists
- while len(listitemindent) < len(BLOCK.prop('indent')):
- ret.extend(BLOCK.blockout())
+ if not BLOCK.block() and \
+ not line.count(MASK.tocmask): # new para!
+ ret.extend(BLOCK.blockin('para'))
- # O-oh, sublist before list ("\n\n - foo\n- foo")
- # Fix: close sublist (as mother), open another list
- if not BLOCK.block().endswith('list'):
- ret.extend(BLOCK.blockin(listname))
- BLOCK.propset('indent',listitemindent)
- BLOCK.propset('type',listtype)
-
- #---------------------[ Table ]-----------------------------
-
- #TODO escape undesired format inside table
- #TODO add pm6 target
- if regex['table'].search(line):
-
- if not BLOCK.isblock('table'): # first table line!
- ret.extend(BLOCK.blockin('table'))
- BLOCK.tableparser.__init__(line)
-
- tablerow = TableMaster().parse_row(line)
- BLOCK.tableparser.add_row(tablerow) # save config
-
- # Maintain line to unmask and inlines
- # XXX Bug: | **bo | ld** | turns **bo\x01ld** and gets converted :(
- # TODO isolate unmask+inlines parsing to use here
- line = SEPARATOR.join(tablerow['cells'])
-
- #---------------------[ Paragraph ]-------------------------
-
- if not BLOCK.block() and \
- not line.count(MASK.tocmask): # new para!
- ret.extend(BLOCK.blockin('para'))
-
-
- ############################################################
- ############################################################
- ############################################################
-
-
- #---------------------[ Final Parses ]----------------------
-
- # The target-specific special char escapes for body lines
- line = doEscape(target,line)
-
- line = add_inline_tags(line)
- line = MASK.undo(line)
-
-
- #---------------------[ Hold or Return? ]-------------------
-
- ### Now we must choose where to put the parsed line
- #
- if not results_box:
- # List item extra lines
- if BLOCK.block().endswith('list'):
- results_box = BLOCK.holdaddsub
- # Other blocks
- elif BLOCK.block():
- results_box = BLOCK.holdadd
- # No blocks
- else:
- line = doFinalEscape(target, line)
- results_box = ret.append
-
- results_box(line)
+
+ ############################################################
+ ############################################################
+ ############################################################
+
+
+ #---------------------[ Final Parses ]----------------------
+
+ # The target-specific special char escapes for body lines
+ line = doEscape(target,line)
+
+ line = add_inline_tags(line)
+ line = MASK.undo(line)
+
+
+ #---------------------[ Hold or Return? ]-------------------
+
+ ### Now we must choose where to put the parsed line
+ #
+ if not results_box:
+ # List item extra lines
+ if BLOCK.block().endswith('list'):
+ results_box = BLOCK.holdaddsub
+ # Other blocks
+ elif BLOCK.block():
+ results_box = BLOCK.holdadd
+ # No blocks
+ else:
+ line = doFinalEscape(target, line)
+ results_box = ret.append
+
+ results_box(line)
# EOF: close any open para/verb/lists/table/quotes
Debug('EOF',7)
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
txt2tags-list mailing list
https://lists.sourceforge.net/lists/listinfo/txt2tags-list