comparison mercurial/minirst.py @ 10447:e957cc7cbd14

minirst: support line blocks
author Martin Geisler <mg@lazybytes.net>
date Sat, 13 Feb 2010 21:21:40 +0100
parents e99e0e077bc4
children 2853c891ac41 db2897926d14
comparison
equal deleted inserted replaced
10446:a565a2445eb5 10447:e957cc7cbd14
109 blocks[i + 1]['indent'] -= adjustment 109 blocks[i + 1]['indent'] -= adjustment
110 i += 1 110 i += 1
111 i += 1 111 i += 1
112 return blocks 112 return blocks
113 113
114 _bulletre = re.compile(r'(-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)) ') 114 _bulletre = re.compile(r'(-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)|\|) ')
115 _optionre = re.compile(r'^(--[a-z-]+)((?:[ =][a-zA-Z][\w-]*)? +)(.*)$') 115 _optionre = re.compile(r'^(--[a-z-]+)((?:[ =][a-zA-Z][\w-]*)? +)(.*)$')
116 _fieldre = re.compile(r':(?![: ])([^:]*)(?<! ):[ ]+(.*)') 116 _fieldre = re.compile(r':(?![: ])([^:]*)(?<! ):[ ]+(.*)')
117 _definitionre = re.compile(r'[^ ]') 117 _definitionre = re.compile(r'[^ ]')
118 118
119 def splitparagraphs(blocks): 119 def splitparagraphs(blocks):
289 return "%s\n%s" % (term, textwrap.fill(text, width=width, 289 return "%s\n%s" % (term, textwrap.fill(text, width=width,
290 initial_indent=defindent, 290 initial_indent=defindent,
291 subsequent_indent=defindent)) 291 subsequent_indent=defindent))
292 initindent = subindent = indent 292 initindent = subindent = indent
293 if block['type'] == 'bullet': 293 if block['type'] == 'bullet':
294 m = _bulletre.match(block['lines'][0]) 294 if block['lines'][0].startswith('| '):
295 subindent = indent + m.end() * ' ' 295 # Remove bullet for line blocks and add no extra
296 # indention.
297 block['lines'][0] = block['lines'][0][2:]
298 else:
299 m = _bulletre.match(block['lines'][0])
300 subindent = indent + m.end() * ' '
296 elif block['type'] == 'field': 301 elif block['type'] == 'field':
297 keywidth = block['keywidth'] 302 keywidth = block['keywidth']
298 key = block['key'] 303 key = block['key']
299 304
300 subindent = indent + _fieldwidth * ' ' 305 subindent = indent + _fieldwidth * ' '